From 48feeb55877aa95e91707beca228237fba74543a Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 1 Aug 2023 23:14:40 -0700 Subject: remove data file --- continuedev/src/continuedev/core/sdk.py | 2 +- .../continuedev/libs/constants/default_config.py | 128 +++++++++++++++++++++ .../libs/constants/default_config.py.txt | 126 -------------------- continuedev/src/continuedev/libs/util/paths.py | 11 +- 4 files changed, 131 insertions(+), 136 deletions(-) create mode 100644 continuedev/src/continuedev/libs/constants/default_config.py delete mode 100644 continuedev/src/continuedev/libs/constants/default_config.py.txt (limited to 'continuedev') diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index a5b16168..57e2c099 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -54,7 +54,7 @@ class ContinueSDK(AbstractContinueSDK): formatted_err = '\n'.join(traceback.format_exception(e)) msg_step = MessageStep( name="Invalid Continue Config File", message=formatted_err) - msg_step.description = f"Falling back to default config settings.\n```\n{formatted_err}\n```\n\nIt's possible this error was caused by an update to the Continue config format. If you'd like to see the new recommended default `config.py`, check [here](https://github.com/continuedev/continue/blob/main/continuedev/src/continuedev/libs/constants/default_config.py.txt)." + msg_step.description = f"Falling back to default config settings.\n```\n{formatted_err}\n```\n\nIt's possible this error was caused by an update to the Continue config format. If you'd like to see the new recommended default `config.py`, check [here](https://github.com/continuedev/continue/blob/main/continuedev/src/continuedev/libs/constants/default_config.py)." sdk.history.add_node(HistoryNode( step=msg_step, observation=None, diff --git a/continuedev/src/continuedev/libs/constants/default_config.py b/continuedev/src/continuedev/libs/constants/default_config.py new file mode 100644 index 00000000..9d6d4270 --- /dev/null +++ b/continuedev/src/continuedev/libs/constants/default_config.py @@ -0,0 +1,128 @@ +default_config = """\ +\"\"\" +This is the Continue configuration file. + +If you aren't getting strong typing on these imports, +be sure to select the Python interpreter in ~/.continue/server/env. +\"\"\" + +import subprocess + +from continuedev.core.main import Step +from continuedev.core.sdk import ContinueSDK +from continuedev.core.models import Models +from continuedev.core.config import CustomCommand, SlashCommand, ContinueConfig +from continuedev.plugins.context_providers.github import GitHubIssuesContextProvider +from continuedev.plugins.context_providers.google import GoogleContextProvider +from continuedev.libs.llm.maybe_proxy_openai import MaybeProxyOpenAI +from continuedev.plugins.policies.default import DefaultPolicy + +from continuedev.plugins.steps.open_config import OpenConfigStep +from continuedev.plugins.steps.clear_history import ClearHistoryStep +from continuedev.plugins.steps.feedback import FeedbackStep +from continuedev.plugins.steps.comment_code import CommentCodeStep +from continuedev.plugins.steps.main import EditHighlightedCodeStep + + +class CommitMessageStep(Step): + \"\"\" + This is a Step, the building block of Continue. + It can be used below as a slash command, so that + run will be called when you type '/commit'. + \"\"\" + async def run(self, sdk: ContinueSDK): + + # Get the root directory of the workspace + dir = sdk.ide.workspace_directory + + # Run git diff in that directory + diff = subprocess.check_output( + ["git", "diff"], cwd=dir).decode("utf-8") + + # Ask the LLM to write a commit message, + # and set it as the description of this step + self.description = await sdk.models.default.complete( + f"{diff}\n\nWrite a short, specific (less than 50 chars) commit message about the above changes:") + + +config = ContinueConfig( + + # If set to False, we will not collect any usage data + # See here to learn what anonymous data we collect: https://continue.dev/docs/telemetry + allow_anonymous_telemetry=True, + + models=Models( + default=MaybeProxyOpenAI(model="gpt-4"), + medium=MaybeProxyOpenAI(model="gpt-3.5-turbo") + ), + + # Set a system message with information that the LLM should always keep in mind + # E.g. "Please give concise answers. Always respond in Spanish." + system_message=None, + + # Set temperature to any value between 0 and 1. Higher values will make the LLM + # more creative, while lower values will make it more predictable. + temperature=0.5, + + # Custom commands let you map a prompt to a shortened slash command + # They are like slash commands, but more easily defined - write just a prompt instead of a Step class + # Their output will always be in chat form + custom_commands=[CustomCommand( + name="test", + description="This is an example custom command. Use /config to edit it and create more", + prompt="Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.", + )], + + # Slash commands let you run a Step from a slash command + slash_commands=[ + # SlashCommand( + # name="commit", + # description="This is an example slash command. Use /config to edit it and create more", + # step=CommitMessageStep, + # ) + SlashCommand( + name="edit", + description="Edit code in the current file or the highlighted code", + step=EditHighlightedCodeStep, + ), + SlashCommand( + name="config", + description="Open the config file to create new and edit existing slash commands", + step=OpenConfigStep, + ), + SlashCommand( + name="comment", + description="Write comments for the current file or highlighted code", + step=CommentCodeStep, + ), + SlashCommand( + name="feedback", + description="Send feedback to improve Continue", + step=FeedbackStep, + ), + SlashCommand( + name="clear", + description="Clear step history", + step=ClearHistoryStep, + ) + ], + + # Context providers let you quickly select context by typing '@' + # Uncomment the following to + # - quickly reference GitHub issues + # - show Google search results to the LLM + context_providers=[ + # GitHubIssuesContextProvider( + # repo_name="/", + # auth_token="" + # ), + # GoogleContextProvider( + # serper_api_key="" + # ) + ], + + # Policies hold the main logic that decides which Step to take next + # You can use them to design agents, or deeply customize Continue + policy=DefaultPolicy() +) +""" diff --git a/continuedev/src/continuedev/libs/constants/default_config.py.txt b/continuedev/src/continuedev/libs/constants/default_config.py.txt deleted file mode 100644 index cf8b0324..00000000 --- a/continuedev/src/continuedev/libs/constants/default_config.py.txt +++ /dev/null @@ -1,126 +0,0 @@ -""" -This is the Continue configuration file. - -If you aren't getting strong typing on these imports, -be sure to select the Python interpreter in ~/.continue/server/env. -""" - -import subprocess - -from continuedev.core.main import Step -from continuedev.core.sdk import ContinueSDK -from continuedev.core.models import Models -from continuedev.core.config import CustomCommand, SlashCommand, ContinueConfig -from continuedev.plugins.context_providers.github import GitHubIssuesContextProvider -from continuedev.plugins.context_providers.google import GoogleContextProvider -from continuedev.libs.llm.maybe_proxy_openai import MaybeProxyOpenAI -from continuedev.plugins.policies.default import DefaultPolicy - -from continuedev.plugins.steps.open_config import OpenConfigStep -from continuedev.plugins.steps.clear_history import ClearHistoryStep -from continuedev.plugins.steps.feedback import FeedbackStep -from continuedev.plugins.steps.comment_code import CommentCodeStep -from continuedev.plugins.steps.main import EditHighlightedCodeStep - - -class CommitMessageStep(Step): - """ - This is a Step, the building block of Continue. - It can be used below as a slash command, so that - run will be called when you type '/commit'. - """ - async def run(self, sdk: ContinueSDK): - - # Get the root directory of the workspace - dir = sdk.ide.workspace_directory - - # Run git diff in that directory - diff = subprocess.check_output( - ["git", "diff"], cwd=dir).decode("utf-8") - - # Ask the LLM to write a commit message, - # and set it as the description of this step - self.description = await sdk.models.default.complete( - f"{diff}\n\nWrite a short, specific (less than 50 chars) commit message about the above changes:") - - -config = ContinueConfig( - - # If set to False, we will not collect any usage data - # See here to learn what anonymous data we collect: https://continue.dev/docs/telemetry - allow_anonymous_telemetry=True, - - models=Models( - default=MaybeProxyOpenAI(model="gpt-4"), - medium=MaybeProxyOpenAI(model="gpt-3.5-turbo") - ), - - # Set a system message with information that the LLM should always keep in mind - # E.g. "Please give concise answers. Always respond in Spanish." - system_message=None, - - # Set temperature to any value between 0 and 1. Higher values will make the LLM - # more creative, while lower values will make it more predictable. - temperature=0.5, - - # Custom commands let you map a prompt to a shortened slash command - # They are like slash commands, but more easily defined - write just a prompt instead of a Step class - # Their output will always be in chat form - custom_commands=[CustomCommand( - name="test", - description="This is an example custom command. Use /config to edit it and create more", - prompt="Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.", - )], - - # Slash commands let you run a Step from a slash command - slash_commands=[ - # SlashCommand( - # name="commit", - # description="This is an example slash command. Use /config to edit it and create more", - # step=CommitMessageStep, - # ) - SlashCommand( - name="edit", - description="Edit code in the current file or the highlighted code", - step=EditHighlightedCodeStep, - ), - SlashCommand( - name="config", - description="Open the config file to create new and edit existing slash commands", - step=OpenConfigStep, - ), - SlashCommand( - name="comment", - description="Write comments for the current file or highlighted code", - step=CommentCodeStep, - ), - SlashCommand( - name="feedback", - description="Send feedback to improve Continue", - step=FeedbackStep, - ), - SlashCommand( - name="clear", - description="Clear step history", - step=ClearHistoryStep, - ) - ], - - # Context providers let you quickly select context by typing '@' - # Uncomment the following to - # - quickly reference GitHub issues - # - show Google search results to the LLM - context_providers=[ - # GitHubIssuesContextProvider( - # repo_name="/", - # auth_token="" - # ), - # GoogleContextProvider( - # serper_api_key="" - # ) - ], - - # Policies hold the main logic that decides which Step to take next - # You can use them to design agents, or deeply customize Continue - policy=DefaultPolicy() -) diff --git a/continuedev/src/continuedev/libs/util/paths.py b/continuedev/src/continuedev/libs/util/paths.py index 6385dc6f..a659f044 100644 --- a/continuedev/src/continuedev/libs/util/paths.py +++ b/continuedev/src/continuedev/libs/util/paths.py @@ -1,6 +1,6 @@ import os -import sys from ..constants.main import CONTINUE_SESSIONS_FOLDER, CONTINUE_GLOBAL_FOLDER, CONTINUE_SERVER_FOLDER +from ..constants.default_config import default_config def find_data_file(filename): @@ -32,20 +32,13 @@ def getSessionFilePath(session_id: str): return path -def getDefaultConfigFile() -> str: - default_config_path = find_data_file(os.path.join( - "..", "constants", "default_config.py.txt")) - with open(default_config_path, 'r') as f: - return f.read() - - def getConfigFilePath() -> str: path = os.path.join(getGlobalFolderPath(), "config.py") os.makedirs(os.path.dirname(path), exist_ok=True) if not os.path.exists(path): with open(path, 'w') as f: - f.write(getDefaultConfigFile()) + f.write(default_config) return path -- cgit v1.2.3-70-g09d2