diff options
Diffstat (limited to 'continuedev/src')
| -rw-r--r-- | continuedev/src/.gitignore | 4 | ||||
| -rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 2 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/constants/default_config.py (renamed from continuedev/src/continuedev/libs/constants/default_config.py.txt) | 10 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/llm/openai.py | 7 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/util/calculate_diff.py | 35 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/util/count_tokens.py | 1 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/util/paths.py | 17 | ||||
| -rw-r--r-- | continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py | 4 | ||||
| -rw-r--r-- | continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py | 3 | ||||
| -rw-r--r-- | continuedev/src/continuedev/plugins/steps/draft/migration.py | 30 | 
10 files changed, 24 insertions, 89 deletions
| diff --git a/continuedev/src/.gitignore b/continuedev/src/.gitignore new file mode 100644 index 00000000..7137bb08 --- /dev/null +++ b/continuedev/src/.gitignore @@ -0,0 +1,4 @@ +main.build +main.dist +run.build +run.dist
\ No newline at end of file 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.txt b/continuedev/src/continuedev/libs/constants/default_config.py index cf8b0324..9d6d4270 100644 --- a/continuedev/src/continuedev/libs/constants/default_config.py.txt +++ b/continuedev/src/continuedev/libs/constants/default_config.py @@ -1,9 +1,10 @@ -""" +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 @@ -24,11 +25,11 @@ 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 @@ -124,3 +125,4 @@ config = ContinueConfig(      # You can use them to design agents, or deeply customize Continue      policy=DefaultPolicy()  ) +""" diff --git a/continuedev/src/continuedev/libs/llm/openai.py b/continuedev/src/continuedev/libs/llm/openai.py index fce6e8ab..9591e824 100644 --- a/continuedev/src/continuedev/libs/llm/openai.py +++ b/continuedev/src/continuedev/libs/llm/openai.py @@ -28,12 +28,6 @@ MAX_TOKENS_FOR_MODEL = {  } -class AzureInfo(BaseModel): -    endpoint: str -    engine: str -    api_version: str - -  class OpenAI(LLM):      model: str      openai_server_info: Optional[OpenAIServerInfo] = None @@ -42,7 +36,6 @@ class OpenAI(LLM):      requires_write_log = True      system_message: Optional[str] = None -    azure_info: Optional[AzureInfo] = None      write_log: Optional[Callable[[str], None]] = None      api_key: str = None diff --git a/continuedev/src/continuedev/libs/util/calculate_diff.py b/continuedev/src/continuedev/libs/util/calculate_diff.py index 3e82bab3..e8e48839 100644 --- a/continuedev/src/continuedev/libs/util/calculate_diff.py +++ b/continuedev/src/continuedev/libs/util/calculate_diff.py @@ -2,41 +2,6 @@ import difflib  from typing import List  from ...models.main import Position, Range  from ...models.filesystem import FileEdit -from diff_match_patch import diff_match_patch - - -def calculate_diff_match_patch(filepath: str, original: str, updated: str) -> List[FileEdit]: -    dmp = diff_match_patch() -    diffs = dmp.diff_main(original, updated) -    dmp.diff_cleanupSemantic(diffs) - -    replacements = [] - -    current_index = 0 -    deleted_length = 0 - -    for diff in diffs: -        if diff[0] == diff_match_patch.DIFF_EQUAL: -            current_index += len(diff[1]) -            deleted_length = 0 -        elif diff[0] == diff_match_patch.DIFF_INSERT: -            current_index += deleted_length -            replacements.append((current_index, current_index, diff[1])) -            current_index += len(diff[1]) -            deleted_length = 0 -        elif diff[0] == diff_match_patch.DIFF_DELETE: -            replacements.append( -                (current_index, current_index + len(diff[1]), '')) -            deleted_length += len(diff[1]) -        elif diff[0] == diff_match_patch.DIFF_REPLACE: -            replacements.append( -                (current_index, current_index + len(diff[1]), '')) -            current_index += deleted_length -            replacements.append((current_index, current_index, diff[2])) -            current_index += len(diff[2]) -            deleted_length = 0 - -    return [FileEdit(filepath=filepath, range=Range.from_indices(original, r[0], r[1]), replacement=r[2]) for r in replacements]  def calculate_diff(filepath: str, original: str, updated: str) -> List[FileEdit]: diff --git a/continuedev/src/continuedev/libs/util/count_tokens.py b/continuedev/src/continuedev/libs/util/count_tokens.py index 6add7b1a..3b594036 100644 --- a/continuedev/src/continuedev/libs/util/count_tokens.py +++ b/continuedev/src/continuedev/libs/util/count_tokens.py @@ -3,6 +3,7 @@ from typing import Dict, List, Union  from ...core.main import ChatMessage  from .templating import render_templated_string  from ...libs.llm import LLM +from tiktoken_ext import openai_public  import tiktoken  # TODO move many of these into specific LLM.properties() function that diff --git a/continuedev/src/continuedev/libs/util/paths.py b/continuedev/src/continuedev/libs/util/paths.py index b08b0949..a659f044 100644 --- a/continuedev/src/continuedev/libs/util/paths.py +++ b/continuedev/src/continuedev/libs/util/paths.py @@ -1,6 +1,11 @@  import os -  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): +    datadir = os.path.dirname(__file__) +    return os.path.abspath(os.path.join(datadir, filename))  def getGlobalFolderPath(): @@ -27,21 +32,13 @@ def getSessionFilePath(session_id: str):      return path -def getDefaultConfigFile() -> str: -    current_path = os.path.dirname(os.path.realpath(__file__)) -    config_path = os.path.join( -        current_path, "..", "constants", "default_config.py.txt") -    with open(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 diff --git a/continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py b/continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py index 8c6446da..e589fc36 100644 --- a/continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py +++ b/continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py @@ -1,7 +1,9 @@  import os  from textwrap import dedent +  from ....plugins.steps.core.core import MessageStep +from ....libs.util.paths import find_data_file  from ....core.sdk import Models  from ....core.main import Step  from ....core.sdk import ContinueSDK @@ -54,7 +56,7 @@ class AddTransformStep(Step):                  - Load the data into a local DuckDB instance                  - Open up a Streamlit app for you to view the data"""), name="Write transformation function")) -        with open(os.path.join(os.path.dirname(__file__), 'dlt_transform_docs.md')) as f: +        with open(find_data_file('dlt_transform_docs.md')) as f:              dlt_transform_docs = f.read()          prompt = dedent(f"""\ diff --git a/continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py b/continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py index 767936b8..14972142 100644 --- a/continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py +++ b/continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py @@ -6,6 +6,7 @@ from ....plugins.steps.core.core import MessageStep  from ....core.sdk import Models  from ....core.main import Step  from ....core.sdk import ContinueSDK +from ....libs.util.paths import find_data_file  AI_ASSISTED_STRING = "(✨ AI-Assisted ✨)" @@ -72,7 +73,7 @@ class LoadDataStep(Step):          output = await sdk.run('.env/bin/python3 chess_pipeline.py', name="Load data to BigQuery", description="Running `.env/bin/python3 chess_pipeline.py` to load data to Google BigQuery")          if "Traceback" in output or "SyntaxError" in output: -            with open(os.path.join(os.path.dirname(__file__), "dlt_duckdb_to_bigquery_docs.md"), "r") as f: +            with open(find_data_file("dlt_duckdb_to_bigquery_docs.md"), "r") as f:                  docs = f.read()              output = "Traceback" + output.split("Traceback")[-1] diff --git a/continuedev/src/continuedev/plugins/steps/draft/migration.py b/continuedev/src/continuedev/plugins/steps/draft/migration.py deleted file mode 100644 index c38f54dc..00000000 --- a/continuedev/src/continuedev/plugins/steps/draft/migration.py +++ /dev/null @@ -1,30 +0,0 @@ -# When an edit is made to an existing class or a new sqlalchemy class is created, -# this should be kicked off. - -from ....core.main import Step - - -class MigrationStep(Step): -    name: str = "Create and run an alembic migration." - -    edited_file: str - -    async def run(self, sdk): -        recent_edits = await sdk.ide.get_recent_edits(self.edited_file) -        recent_edits_string = "\n\n".join( -            map(lambda x: x.to_string(), recent_edits)) -        description = await sdk.models.medium.complete(f"{recent_edits_string}\n\nGenerate a short description of the migration made in the above changes:\n") -        await sdk.run([ -            "cd libs", -            "poetry run alembic revision --autogenerate -m " + description, -        ]) -        migration_file = f"libs/alembic/versions/{?}.py" -        contents = await sdk.ide.readFile(migration_file) -        await sdk.run_step(EditCodeStep( -            range_in_files=[RangeInFile.from_entire_file(migration_file, contents)], -            prompt=f"Here are the changes made to the sqlalchemy classes:\n\n{recent_edits_string}\n\nThis is the generated migration file:\n\n{{code}}\n\nReview the migration file to make sure it correctly reflects the changes made to the sqlalchemy classes.", -        )) -        await sdk.run([ -            "cd libs", -            "poetry run alembic upgrade head", -        ]) | 
