diff options
Diffstat (limited to 'continuedev')
| -rw-r--r-- | continuedev/main.py | 5 | ||||
| -rw-r--r-- | continuedev/pyproject.toml | 2 | ||||
| -rw-r--r-- | continuedev/requirements.txt | 20 | ||||
| -rw-r--r-- | continuedev/src/.gitignore | 4 | ||||
| -rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 9 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/constants/default_config.py (renamed from continuedev/src/continuedev/libs/constants/default_config.py.txt) | 38 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/llm/anthropic.py | 1 | ||||
| -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 | 28 | ||||
| -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 | 
14 files changed, 78 insertions, 109 deletions
diff --git a/continuedev/main.py b/continuedev/main.py new file mode 100644 index 00000000..3cf4e817 --- /dev/null +++ b/continuedev/main.py @@ -0,0 +1,5 @@ +from .src.continuedev.server.main import run_server + + +def main(): +    run_server() diff --git a/continuedev/pyproject.toml b/continuedev/pyproject.toml index d7505e2b..7355beb0 100644 --- a/continuedev/pyproject.toml +++ b/continuedev/pyproject.toml @@ -7,7 +7,6 @@ readme = "README.md"  [tool.poetry.dependencies]  python = "^3.8.1" -diff-match-patch = "^20230430"  fastapi = "^0.95.1"  typer = "^0.7.0"  openai = "^0.27.5" @@ -18,7 +17,6 @@ python-dotenv = "^1.0.0"  nest-asyncio = "^1.5.6"  websockets = "^11.0.2"  urllib3 = "1.26.15" -gpt-index = "^0.6.8"  posthog = "^3.0.1"  tiktoken = "^0.4.0"  jsonref = "^1.1.0" diff --git a/continuedev/requirements.txt b/continuedev/requirements.txt new file mode 100644 index 00000000..6a776a62 --- /dev/null +++ b/continuedev/requirements.txt @@ -0,0 +1,20 @@ +fastapi==0.95.1 +typer==0.7.0 +openai==0.27.5 +boltons==23.0.0 +pydantic==1.10.7 +uvicorn==0.21.1 +python-dotenv==1.0.0 +nest-asyncio==1.5.6 +websockets==11.0.2 +urllib3==1.26.15 +posthog==3.0.1 +tiktoken==0.4.0 +jsonref==1.1.0 +jsonschema==4.17.3 +directory-tree==0.0.3.1 +anthropic==0.3.4 +chevron==0.14.0 +psutil==5.9.5 +pygithub==1.59.0 +meilisearch-python-async==1.4.8 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 30fcc144..60a390ac 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -1,7 +1,7 @@ -from functools import cached_property  import traceback -from typing import Coroutine, Dict, Literal, Union +from typing import Coroutine, Union  import os +import importlib  from ..plugins.steps.core.core import DefaultModelEditCodeStep  from ..models.main import Range @@ -46,7 +46,8 @@ class ContinueSDK(AbstractContinueSDK):              config = sdk._load_config_dot_py()              sdk.config = config          except Exception as e: -            logger.error(f"Failed to load config.py: {e}") +            logger.error( +                f"Failed to load config.py: {traceback.format_exception(e)}")              sdk.config = ContinueConfig(              ) if sdk._last_valid_config is None else sdk._last_valid_config @@ -54,7 +55,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..238dc1da 100644 --- a/continuedev/src/continuedev/libs/constants/default_config.py.txt +++ b/continuedev/src/continuedev/libs/constants/default_config.py @@ -1,34 +1,35 @@ -""" +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.src.continuedev.core.main import Step +from continuedev.src.continuedev.core.sdk import ContinueSDK +from continuedev.src.continuedev.core.models import Models +from continuedev.src.continuedev.core.config import CustomCommand, SlashCommand, ContinueConfig +from continuedev.src.continuedev.plugins.context_providers.github import GitHubIssuesContextProvider +from continuedev.src.continuedev.plugins.context_providers.google import GoogleContextProvider +from continuedev.src.continuedev.libs.llm.maybe_proxy_openai import MaybeProxyOpenAI +from continuedev.src.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 +from continuedev.src.continuedev.plugins.steps.open_config import OpenConfigStep +from continuedev.src.continuedev.plugins.steps.clear_history import ClearHistoryStep +from continuedev.src.continuedev.plugins.steps.feedback import FeedbackStep +from continuedev.src.continuedev.plugins.steps.comment_code import CommentCodeStep +from continuedev.src.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 @@ -41,7 +42,7 @@ class CommitMessageStep(Step):          # 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:") +            f"{diff}\\n\\nWrite a short, specific (less than 50 chars) commit message about the above changes:")  config = ContinueConfig( @@ -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/anthropic.py b/continuedev/src/continuedev/libs/llm/anthropic.py index 8a548223..ac5c56a4 100644 --- a/continuedev/src/continuedev/libs/llm/anthropic.py +++ b/continuedev/src/continuedev/libs/llm/anthropic.py @@ -1,4 +1,3 @@ -  from functools import cached_property  import time  from typing import Any, Callable, Coroutine, Dict, Generator, List, Optional, Union diff --git a/continuedev/src/continuedev/libs/llm/openai.py b/continuedev/src/continuedev/libs/llm/openai.py index 99c851ca..30343331 100644 --- a/continuedev/src/continuedev/libs/llm/openai.py +++ b/continuedev/src/continuedev/libs/llm/openai.py @@ -26,12 +26,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 @@ -40,7 +34,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..83a472ad 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,24 @@ 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) +    else: +        with open(path, 'r') as f: +            existing_content = f.read() + +        if existing_content.strip() == "": +            with open(path, 'w') as f: +                f.write(default_config) +        elif " continuedev.core" in existing_content: +            with open(path, 'w') as f: +                f.write(existing_content.replace(" continuedev.", +                                                 " continuedev.src.continuedev."))      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", -        ])  | 
