diff options
-rw-r--r-- | continuedev/pyproject.toml | 3 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/agent.py | 1 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 32 | ||||
-rw-r--r-- | continuedev/src/continuedev/libs/llm/openai.py | 10 | ||||
-rw-r--r-- | continuedev/src/continuedev/models/generate_json_schema.py | 8 | ||||
-rw-r--r-- | extension/package-lock.json | 4 | ||||
-rw-r--r-- | extension/package.json | 6 | ||||
-rw-r--r-- | extension/scripts/continuedev-0.1.0-py3-none-any.whl | bin | 51468 -> 53104 bytes | |||
-rw-r--r-- | extension/scripts/install_from_source.py | 45 | ||||
-rw-r--r-- | schema/json/FileEdit.json | 4 | ||||
-rw-r--r-- | schema/json/FileEditWithFullContents.json | 4 | ||||
-rw-r--r-- | schema/json/History.json | 4 | ||||
-rw-r--r-- | schema/json/HistoryNode.json | 4 | ||||
-rw-r--r-- | schema/json/Position.json | 4 | ||||
-rw-r--r-- | schema/json/Range.json | 4 | ||||
-rw-r--r-- | schema/json/RangeInFile.json | 4 | ||||
-rw-r--r-- | schema/json/Traceback.json | 4 | ||||
-rw-r--r-- | schema/json/TracebackFrame.json | 4 |
18 files changed, 109 insertions, 36 deletions
diff --git a/continuedev/pyproject.toml b/continuedev/pyproject.toml index 5c224c9c..8ed8f268 100644 --- a/continuedev/pyproject.toml +++ b/continuedev/pyproject.toml @@ -20,6 +20,9 @@ urllib3 = "1.26.15" gpt-index = "^0.6.8" setuptools = "^67.7.2" +[tool.poetry.scripts] +typegen = "src.continuedev.models.generate_json_schema:main" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/continuedev/src/continuedev/core/agent.py b/continuedev/src/continuedev/core/agent.py index 509a54b3..6d1f542e 100644 --- a/continuedev/src/continuedev/core/agent.py +++ b/continuedev/src/continuedev/core/agent.py @@ -17,7 +17,6 @@ class Agent(ContinueBaseModel): policy: Policy ide: AbstractIdeProtocolServer history: History = History.from_empty() - continue_sdk: "ContinueSDK" _on_update_callbacks: List[Callable[[FullState], None]] = [] _active: bool = False diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index ff62a2b1..3559e9d7 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -1,5 +1,6 @@ +import os from typing import Coroutine, Union -from ..models.filesystem_edit import FileSystemEdit +from ..models.filesystem_edit import FileSystemEdit, AddFile, DeleteFile, AddDirectory, DeleteDirectory from ..models.filesystem import RangeInFile from ..libs.llm import LLM from .observation import Observation @@ -37,11 +38,16 @@ class ContinueSDK: def history(self) -> History: return self.__agent.history + async def _ensure_absolute_path(self, path: str) -> str: + if os.path.isabs(path): + return path + return os.path.join(await self.ide.getWorkspaceDirectory(), path) + async def run_step(self, step: Step) -> Coroutine[Observation, None, None]: return await self.__agent._run_singular_step(step) async def apply_filesystem_edit(self, edit: FileSystemEdit): - await self.run_step(FileSystemEditStep(edit=edit)) + return await self.run_step(FileSystemEditStep(edit=edit)) async def wait_for_user_input(self) -> str: return await self.__agent.wait_for_user_input() @@ -51,12 +57,26 @@ class ContinueSDK: async def run(self, commands: List[str] | str, cwd: str = None): commands = commands if isinstance(commands, List) else [commands] - return self.run_step(ShellCommandsStep(commands=commands, cwd=cwd)) + return await self.run_step(ShellCommandsStep(commands=commands, cwd=cwd)) async def edit_file(self, filename: str, prompt: str): - await self.ide.setFileOpen(filename) - contents = await self.ide.readFile(filename) + filepath = await self._ensure_absolute_path(filename) + + await self.ide.setFileOpen(filepath) + contents = await self.ide.readFile(filepath) await self.run_step(EditCodeStep( - range_in_files=[RangeInFile.from_entire_file(filename, contents)], + range_in_files=[RangeInFile.from_entire_file(filepath, contents)], prompt=f'Here is the code before:\n\n{{code}}\n\nHere is the user request:\n\n{prompt}\n\nHere is the code edited to perfectly solve the user request:\n\n' )) + + async def add_file(self, filename: str, content: str | None): + return await self.run_step(FileSystemEditStep(edit=AddFile(filename=filename, content=content))) + + async def delete_file(self, filename: str): + return await self.run_step(FileSystemEditStep(edit=DeleteFile(filepath=filename))) + + async def add_directory(self, path: str): + return await self.run_step(FileSystemEditStep(edit=AddDirectory(path=path))) + + async def delete_directory(self, path: str): + return await self.run_step(FileSystemEditStep(edit=DeleteDirectory(path=path))) diff --git a/continuedev/src/continuedev/libs/llm/openai.py b/continuedev/src/continuedev/libs/llm/openai.py index bb745e75..10801465 100644 --- a/continuedev/src/continuedev/libs/llm/openai.py +++ b/continuedev/src/continuedev/libs/llm/openai.py @@ -6,6 +6,8 @@ import aiohttp from ..llm import LLM from pydantic import BaseModel, validator +DEFAULT_MAX_TOKENS = 2048 + class OpenAI(LLM): api_key: str @@ -22,7 +24,7 @@ class OpenAI(LLM): def stream_chat(self, messages, **kwargs) -> Generator[Union[Any, List, Dict], None, None]: self.completion_count += 1 - args = {"max_tokens": 512, "temperature": 0.5, "top_p": 1, + args = {"max_tokens": DEFAULT_MAX_TOKENS, "temperature": 0.5, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0} | kwargs args["stream"] = True args["model"] = "gpt-3.5-turbo" @@ -38,7 +40,7 @@ class OpenAI(LLM): def stream_complete(self, prompt: str, **kwargs) -> Generator[Union[Any, List, Dict], None, None]: self.completion_count += 1 - args = {"model": self.default_model, "max_tokens": 512, "temperature": 0.5, + args = {"model": self.default_model, "max_tokens": DEFAULT_MAX_TOKENS, "temperature": 0.5, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "suffix": None} | kwargs args["stream"] = True @@ -64,7 +66,7 @@ class OpenAI(LLM): t1 = time.time() self.completion_count += 1 - args = {"model": self.default_model, "max_tokens": 512, "temperature": 0.5, "top_p": 1, + args = {"model": self.default_model, "max_tokens": DEFAULT_MAX_TOKENS, "temperature": 0.5, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "stream": False} | kwargs if args["model"] == "gpt-3.5-turbo": @@ -132,7 +134,7 @@ class OpenAI(LLM): def parallel_complete(self, prompts: list[str], suffixes: Union[list[str], None] = None, **kwargs) -> list[str]: self.completion_count += len(prompts) - args = {"model": self.default_model, "max_tokens": 512, "temperature": 0.5, + args = {"model": self.default_model, "max_tokens": DEFAULT_MAX_TOKENS, "temperature": 0.5, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0} | kwargs async def fn(): diff --git a/continuedev/src/continuedev/models/generate_json_schema.py b/continuedev/src/continuedev/models/generate_json_schema.py index 07337029..080787a5 100644 --- a/continuedev/src/continuedev/models/generate_json_schema.py +++ b/continuedev/src/continuedev/models/generate_json_schema.py @@ -19,7 +19,7 @@ RENAMES = { "ExampleClass": "RenamedName" } -SCHEMA_DIR = "schema/json" +SCHEMA_DIR = "../schema/json" def clear_schemas(): @@ -28,7 +28,7 @@ def clear_schemas(): os.remove(os.path.join(SCHEMA_DIR, filename)) -if __name__ == "__main__": +def main(): clear_schemas() for model in MODELS_TO_GENERATE: title = RENAMES.get(model.__name__, model.__name__) @@ -40,3 +40,7 @@ if __name__ == "__main__": with open(f"{SCHEMA_DIR}/{title}.json", "w") as f: f.write(json) + + +if __name__ == "__main__": + main() diff --git a/extension/package-lock.json b/extension/package-lock.json index a90827d8..faa07b57 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@electron/rebuild": "^3.2.10", "@reduxjs/toolkit": "^1.9.3", diff --git a/extension/package.json b/extension/package.json index 525ec075..40d56fb7 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "Refine code 10x faster", - "version": "0.0.2", + "version": "0.0.3", "publisher": "Continue", "engines": { "vscode": "^1.74.0" @@ -23,7 +23,7 @@ "Other" ], "activationEvents": [ - "*" + "onStartupFinished" ], "main": "./out/extension.js", "contributes": { @@ -160,7 +160,7 @@ "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", "test": "node ./out/test/runTest.js", - "package": "cp ./config/prod_config.json ./config/config.json && npm run compile && mkdir -p ./build && vsce package --out ./build && chmod 777 ./build/continue-0.0.1.vsix && cp ./config/dev_config.json ./config/config.json", + "package": "cp ./config/prod_config.json ./config/config.json && mkdir -p ./build && vsce package --out ./build && chmod 777 ./build/continue-0.0.2.vsix && cp ./config/dev_config.json ./config/config.json", "full-package": "cd ../continuedev && poetry build && cp ./dist/continuedev-0.1.0-py3-none-any.whl ../extension/scripts/continuedev-0.1.0-py3-none-any.whl && cd ../extension && npm run typegen && npm run clientgen && cd react-app && npm run build && cd .. && npm run package", "install-extension": "code --install-extension ./build/continue-0.0.1.vsix", "uninstall": "code --uninstall-extension .continue", diff --git a/extension/scripts/continuedev-0.1.0-py3-none-any.whl b/extension/scripts/continuedev-0.1.0-py3-none-any.whl Binary files differindex 68457b3e..d1483db9 100644 --- a/extension/scripts/continuedev-0.1.0-py3-none-any.whl +++ b/extension/scripts/continuedev-0.1.0-py3-none-any.whl diff --git a/extension/scripts/install_from_source.py b/extension/scripts/install_from_source.py new file mode 100644 index 00000000..4fe903ed --- /dev/null +++ b/extension/scripts/install_from_source.py @@ -0,0 +1,45 @@ +import subprocess + + +def run(cmd: str): + return subprocess.run(cmd, shell=True, capture_output=True) + + +def main(): + # Check for Python and Node - we won't install them, but will warn + out, err1 = run("python --version") + out, err2 = run("python3 --version") + if err1 and err2: + print("Python is required for Continue but is not installed on your machine. See https://www.python.org/downloads/ to download the latest version, then try again.") + return + + out, err = run("node --version") + if err: + print("Node is required for Continue but is not installed on your machine. See https://nodejs.org/en/download/ to download the latest version, then try again.") + return + + out, err = run("npm --version") + if err: + print("NPM is required for Continue but is not installed on your machine. See https://nodejs.org/en/download/ to download the latest version, then try again.") + return + + out, err = run("poetry --version") + if err: + print("Poetry is required for Continue but is not installed on your machine. See https://python-poetry.org/docs/#installation to download the latest version, then try again.") + return + + out, err = run("cd ../../continuedev; poetry run typegen") + + out, err = run( + "cd ..; npm i; cd react-app; npm i; cd ..; npm run full-package\r y\r npm run install-extension") + + if err: + print("Error installing the extension. Please try again.") + print("This was the error: ", err) + return + + print("Continue VS Code extension installed successfully. Please restart VS Code to use it.") + + +if __name__ == "__main__": + main() diff --git a/schema/json/FileEdit.json b/schema/json/FileEdit.json index 1f7dcb64..011e0462 100644 --- a/schema/json/FileEdit.json +++ b/schema/json/FileEdit.json @@ -1,6 +1,6 @@ { "title": "FileEdit", - "$ref": "#/definitions/continuedev__src__continuedev__models__filesystem_edit__FileEdit", + "$ref": "#/definitions/src__continuedev__models__filesystem_edit__FileEdit", "definitions": { "Position": { "title": "Position", @@ -37,7 +37,7 @@ "end" ] }, - "continuedev__src__continuedev__models__filesystem_edit__FileEdit": { + "src__continuedev__models__filesystem_edit__FileEdit": { "title": "FileEdit", "type": "object", "properties": { diff --git a/schema/json/FileEditWithFullContents.json b/schema/json/FileEditWithFullContents.json index 571ea1d3..2ea75bab 100644 --- a/schema/json/FileEditWithFullContents.json +++ b/schema/json/FileEditWithFullContents.json @@ -1,6 +1,6 @@ { "title": "FileEditWithFullContents", - "$ref": "#/definitions/continuedev__src__continuedev__models__filesystem_edit__FileEditWithFullContents", + "$ref": "#/definitions/src__continuedev__models__filesystem_edit__FileEditWithFullContents", "definitions": { "Position": { "title": "Position", @@ -59,7 +59,7 @@ "replacement" ] }, - "continuedev__src__continuedev__models__filesystem_edit__FileEditWithFullContents": { + "src__continuedev__models__filesystem_edit__FileEditWithFullContents": { "title": "FileEditWithFullContents", "type": "object", "properties": { diff --git a/schema/json/History.json b/schema/json/History.json index 7691c7dd..14b82d6d 100644 --- a/schema/json/History.json +++ b/schema/json/History.json @@ -1,6 +1,6 @@ { "title": "History", - "$ref": "#/definitions/continuedev__src__continuedev__core__main__History", + "$ref": "#/definitions/src__continuedev__core__main__History", "definitions": { "Step": { "title": "Step", @@ -47,7 +47,7 @@ "depth" ] }, - "continuedev__src__continuedev__core__main__History": { + "src__continuedev__core__main__History": { "title": "History", "description": "A history of steps taken and their results", "type": "object", diff --git a/schema/json/HistoryNode.json b/schema/json/HistoryNode.json index f58b8038..87a8729f 100644 --- a/schema/json/HistoryNode.json +++ b/schema/json/HistoryNode.json @@ -1,6 +1,6 @@ { "title": "HistoryNode", - "$ref": "#/definitions/continuedev__src__continuedev__core__main__HistoryNode", + "$ref": "#/definitions/src__continuedev__core__main__HistoryNode", "definitions": { "Step": { "title": "Step", @@ -26,7 +26,7 @@ "type": "object", "properties": {} }, - "continuedev__src__continuedev__core__main__HistoryNode": { + "src__continuedev__core__main__HistoryNode": { "title": "HistoryNode", "description": "A point in history, a list of which make up History", "type": "object", diff --git a/schema/json/Position.json b/schema/json/Position.json index e550572e..6b272ce7 100644 --- a/schema/json/Position.json +++ b/schema/json/Position.json @@ -1,8 +1,8 @@ { "title": "Position", - "$ref": "#/definitions/continuedev__src__continuedev__models__main__Position", + "$ref": "#/definitions/src__continuedev__models__main__Position", "definitions": { - "continuedev__src__continuedev__models__main__Position": { + "src__continuedev__models__main__Position": { "title": "Position", "type": "object", "properties": { diff --git a/schema/json/Range.json b/schema/json/Range.json index 52953837..75675183 100644 --- a/schema/json/Range.json +++ b/schema/json/Range.json @@ -1,6 +1,6 @@ { "title": "Range", - "$ref": "#/definitions/continuedev__src__continuedev__models__main__Range", + "$ref": "#/definitions/src__continuedev__models__main__Range", "definitions": { "Position": { "title": "Position", @@ -20,7 +20,7 @@ "character" ] }, - "continuedev__src__continuedev__models__main__Range": { + "src__continuedev__models__main__Range": { "title": "Range", "description": "A range in a file. 0-indexed.", "type": "object", diff --git a/schema/json/RangeInFile.json b/schema/json/RangeInFile.json index 022ca1a8..1f5afaa3 100644 --- a/schema/json/RangeInFile.json +++ b/schema/json/RangeInFile.json @@ -1,6 +1,6 @@ { "title": "RangeInFile", - "$ref": "#/definitions/continuedev__src__continuedev__models__filesystem__RangeInFile", + "$ref": "#/definitions/src__continuedev__models__filesystem__RangeInFile", "definitions": { "Position": { "title": "Position", @@ -37,7 +37,7 @@ "end" ] }, - "continuedev__src__continuedev__models__filesystem__RangeInFile": { + "src__continuedev__models__filesystem__RangeInFile": { "title": "RangeInFile", "type": "object", "properties": { diff --git a/schema/json/Traceback.json b/schema/json/Traceback.json index c3e0e416..45606a2b 100644 --- a/schema/json/Traceback.json +++ b/schema/json/Traceback.json @@ -1,6 +1,6 @@ { "title": "Traceback", - "$ref": "#/definitions/continuedev__src__continuedev__models__main__Traceback", + "$ref": "#/definitions/src__continuedev__models__main__Traceback", "definitions": { "TracebackFrame": { "title": "TracebackFrame", @@ -29,7 +29,7 @@ "function" ] }, - "continuedev__src__continuedev__models__main__Traceback": { + "src__continuedev__models__main__Traceback": { "title": "Traceback", "type": "object", "properties": { diff --git a/schema/json/TracebackFrame.json b/schema/json/TracebackFrame.json index 6321e08c..1907430a 100644 --- a/schema/json/TracebackFrame.json +++ b/schema/json/TracebackFrame.json @@ -1,8 +1,8 @@ { "title": "TracebackFrame", - "$ref": "#/definitions/continuedev__src__continuedev__models__main__TracebackFrame", + "$ref": "#/definitions/src__continuedev__models__main__TracebackFrame", "definitions": { - "continuedev__src__continuedev__models__main__TracebackFrame": { + "src__continuedev__models__main__TracebackFrame": { "title": "TracebackFrame", "type": "object", "properties": { |