summaryrefslogtreecommitdiff
path: root/continuedev
diff options
context:
space:
mode:
Diffstat (limited to 'continuedev')
-rw-r--r--continuedev/main.py5
-rw-r--r--continuedev/pyproject.toml2
-rw-r--r--continuedev/requirements.txt20
-rw-r--r--continuedev/src/.gitignore4
-rw-r--r--continuedev/src/continuedev/core/sdk.py2
-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.py7
-rw-r--r--continuedev/src/continuedev/libs/util/calculate_diff.py35
-rw-r--r--continuedev/src/continuedev/libs/util/count_tokens.py1
-rw-r--r--continuedev/src/continuedev/libs/util/paths.py17
-rw-r--r--continuedev/src/continuedev/plugins/recipes/AddTransformRecipe/steps.py4
-rw-r--r--continuedev/src/continuedev/plugins/recipes/DDtoBQRecipe/steps.py3
-rw-r--r--continuedev/src/continuedev/plugins/steps/draft/migration.py30
13 files changed, 49 insertions, 91 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 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",
- ])