bug fixes, build script, sdk methods
This commit is contained in:
parent
0564978010
commit
306ab404ce
18 changed files with 109 additions and 36 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Binary file not shown.
45
extension/scripts/install_from_source.py
Normal file
45
extension/scripts/install_from_source.py
Normal file
|
|
@ -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()
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue