diff options
author | Ty Dunn <ty@tydunn.com> | 2023-07-13 15:36:09 -0700 |
---|---|---|
committer | Ty Dunn <ty@tydunn.com> | 2023-07-13 15:36:09 -0700 |
commit | 3430de2b46b5c65c953b24dab5c31678a7bacc20 (patch) | |
tree | 100a18df6f60f15813659512b8dd5a6090fb1a3f | |
parent | f0ce0ad4537aadb8252cebd1b5ce25a91c60e392 (diff) | |
download | sncontinue-3430de2b46b5c65c953b24dab5c31678a7bacc20.tar.gz sncontinue-3430de2b46b5c65c953b24dab5c31678a7bacc20.tar.bz2 sncontinue-3430de2b46b5c65c953b24dab5c31678a7bacc20.zip |
adding /help command
-rw-r--r-- | continuedev/src/continuedev/core/config.py | 5 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/policy.py | 5 | ||||
-rw-r--r-- | continuedev/src/continuedev/libs/util/step_name_to_steps.py | 4 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/help.py | 57 |
4 files changed, 66 insertions, 5 deletions
diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py index f6167638..6e430c04 100644 --- a/continuedev/src/continuedev/core/config.py +++ b/continuedev/src/continuedev/core/config.py @@ -45,6 +45,11 @@ DEFAULT_SLASH_COMMANDS = [ step_name="OpenConfigStep", ), SlashCommand( + name="help", + description="Ask a question like '/help what is given to the llm as context?'", + step_name="HelpStep", + ), + SlashCommand( name="comment", description="Write comments for the current file or highlighted code", step_name="CommentCodeStep", diff --git a/continuedev/src/continuedev/core/policy.py b/continuedev/src/continuedev/core/policy.py index b8363df2..59ea78b1 100644 --- a/continuedev/src/continuedev/core/policy.py +++ b/continuedev/src/continuedev/core/policy.py @@ -60,10 +60,7 @@ class DemoPolicy(Policy): MessageStep(name="Welcome to Continue", message=dedent("""\ - Highlight code and ask a question or give instructions - Use `cmd+k` (Mac) / `ctrl+k` (Windows) to open Continue - - Use `cmd+shift+e` / `ctrl+shift+e` to open file Explorer - - Add your own OpenAI API key to VS Code Settings with `cmd+,` - - Use slash commands when you want fine-grained control - - Past steps are included as part of the context by default""")) >> + - Use `/help` to ask questions about how to use Continue""")) >> WelcomeStep() >> # SetupContinueWorkspaceStep() >> # CreateCodebaseIndexChroma() >> diff --git a/continuedev/src/continuedev/libs/util/step_name_to_steps.py b/continuedev/src/continuedev/libs/util/step_name_to_steps.py index d329e110..49056c81 100644 --- a/continuedev/src/continuedev/libs/util/step_name_to_steps.py +++ b/continuedev/src/continuedev/libs/util/step_name_to_steps.py @@ -13,6 +13,7 @@ from ...recipes.DeployPipelineAirflowRecipe.main import DeployPipelineAirflowRec from ...steps.on_traceback import DefaultOnTracebackStep from ...steps.clear_history import ClearHistoryStep from ...steps.open_config import OpenConfigStep +from ...steps.help import HelpStep # This mapping is used to convert from string in ContinueConfig json to corresponding Step class. # Used for example in slash_commands and steps_on_startup @@ -28,7 +29,8 @@ step_name_to_step_class = { "DeployPipelineAirflowRecipe": DeployPipelineAirflowRecipe, "DefaultOnTracebackStep": DefaultOnTracebackStep, "ClearHistoryStep": ClearHistoryStep, - "OpenConfigStep": OpenConfigStep + "OpenConfigStep": OpenConfigStep, + "HelpStep": HelpStep, } diff --git a/continuedev/src/continuedev/steps/help.py b/continuedev/src/continuedev/steps/help.py new file mode 100644 index 00000000..fdfb986f --- /dev/null +++ b/continuedev/src/continuedev/steps/help.py @@ -0,0 +1,57 @@ +from textwrap import dedent +from ..core.main import ChatMessage, Step +from ..core.sdk import ContinueSDK +from ..libs.util.telemetry import capture_event + +help = dedent("""\ + Continue is an open-source coding autopilot. It is a VS Code extension that brings the power of ChatGPT to your IDE. + + It gathers context for you and stores your interactions automatically, so that you can avoid copy/paste now and benefit from a customized LLM later. + + Continue can be used to... + 1. Edit chunks of code with specific instructions (e.g. "/edit migrate this digital ocean terraform file into one that works for GCP") + 2. Get answers to questions without switching windows (e.g. "how do I find running process on port 8000?") + 3. Generate files from scratch (e.g. "/edit Create a Python CLI tool that uses the posthog api to get events from DAUs") + + You tell Continue to edit a specific section of code by highlighting it. If you highlight multiple code sections, then it will only edit the one with the purple glow around it. You can switch which one has the purple glow by clicking the paint brush. + + If you don't highlight any code, then Continue will insert at the location of your cursor. + + Continue passes all of the sections of code you highlight, the code above and below the to-be edited highlighted code section, and all previous steps above input box as context to the LLM. + + You can use cmd+k (Mac) / ctrl+k (Windows) to open Continue. You can use cmd+shift+e / ctrl+shift+e to open file Explorer. You can add your own OpenAI API key to VS Code Settings with `cmd+,` + + If Continue is stuck loading, try using `cmd+shift+p` to open the command palette, search "Reload Window", and then select it. This will reload VS Code and Continue and often fixes issues. + + If you have feedback, please use /feedback to let us know how you would like to use Continue. We are excited to hear from you!""") + +class HelpStep(Step): + + name: str = "Help" + user_input: str + manage_own_chat_context: bool = True + description: str = "" + + async def run(self, sdk: ContinueSDK): + + question = self.user_input + + prompt = dedent(f"""Please us the information below to provide a succinct answer to the following quesiton: {question} + + Information: + + {help}""") + + self.chat_context.append(ChatMessage( + role="user", + content=prompt, + summary="Help" + )) + messages = await sdk.get_chat_context() + generator = sdk.models.gpt4.stream_chat(messages) + async for chunk in generator: + if "content" in chunk: + self.description += chunk["content"] + await sdk.update_ui() + + capture_event(sdk.ide.unique_id, "help", {"question": question, "answer": self.description})
\ No newline at end of file |