summaryrefslogtreecommitdiff
path: root/continuedev/src/continuedev/steps
diff options
context:
space:
mode:
authorTy Dunn <ty@tydunn.com>2023-06-16 15:56:01 -0700
committerGitHub <noreply@github.com>2023-06-16 15:56:01 -0700
commitd9e576d0f81a22a0c6e7f0659e67f3fa38a0d1aa (patch)
tree7d798f83ae62f4d28dfb5c2256b01d52e9a5c2d3 /continuedev/src/continuedev/steps
parentc980e01d2f9328d5c37df14bea02f84a4890bc6a (diff)
parent3aa4f014608c09b8da2f4ab95137a959487af245 (diff)
downloadsncontinue-d9e576d0f81a22a0c6e7f0659e67f3fa38a0d1aa.tar.gz
sncontinue-d9e576d0f81a22a0c6e7f0659e67f3fa38a0d1aa.tar.bz2
sncontinue-d9e576d0f81a22a0c6e7f0659e67f3fa38a0d1aa.zip
Merge branch 'main' into too-large
Diffstat (limited to 'continuedev/src/continuedev/steps')
-rw-r--r--continuedev/src/continuedev/steps/chat.py8
-rw-r--r--continuedev/src/continuedev/steps/chroma.py2
-rw-r--r--continuedev/src/continuedev/steps/core/core.py11
-rw-r--r--continuedev/src/continuedev/steps/draft/migration.py2
-rw-r--r--continuedev/src/continuedev/steps/input/nl_multiselect.py2
-rw-r--r--continuedev/src/continuedev/steps/main.py29
-rw-r--r--continuedev/src/continuedev/steps/on_traceback.py23
-rw-r--r--continuedev/src/continuedev/steps/react.py2
-rw-r--r--continuedev/src/continuedev/steps/search_directory.py2
9 files changed, 40 insertions, 41 deletions
diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py
index 7cfe7e0c..90514ad6 100644
--- a/continuedev/src/continuedev/steps/chat.py
+++ b/continuedev/src/continuedev/steps/chat.py
@@ -10,10 +10,10 @@ class SimpleChatStep(Step):
name: str = "Chat"
async def run(self, sdk: ContinueSDK):
- self.description = f"## {self.user_input}\n\n"
- for chunk in sdk.models.default.stream_chat(self.user_input, with_history=await sdk.get_chat_context()):
+ self.description = f"```{self.user_input}```\n\n"
+ async for chunk in sdk.models.default.stream_chat(self.user_input, with_history=await sdk.get_chat_context()):
self.description += chunk
await sdk.update_ui()
- self.name = sdk.models.gpt35.complete(
- f"Write a short title for the following chat message: {self.description}").strip()
+ self.name = (await sdk.models.gpt35.complete(
+ f"Write a short title for the following chat message: {self.description}")).strip()
diff --git a/continuedev/src/continuedev/steps/chroma.py b/continuedev/src/continuedev/steps/chroma.py
index 058455b2..9d085981 100644
--- a/continuedev/src/continuedev/steps/chroma.py
+++ b/continuedev/src/continuedev/steps/chroma.py
@@ -56,7 +56,7 @@ class AnswerQuestionChroma(Step):
Here is the answer:""")
- answer = sdk.models.gpt35.complete(prompt)
+ answer = await sdk.models.gpt35.complete(prompt)
# Make paths relative to the workspace directory
answer = answer.replace(await sdk.ide.getWorkspaceDirectory(), "")
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py
index de6fa29a..d580e2d2 100644
--- a/continuedev/src/continuedev/steps/core/core.py
+++ b/continuedev/src/continuedev/steps/core/core.py
@@ -73,7 +73,7 @@ class ShellCommandsStep(Step):
return f"Error when running shell commands:\n```\n{self._err_text}\n```"
cmds_str = "\n".join(self.cmds)
- return models.gpt35.complete(f"{cmds_str}\n\nSummarize what was done in these shell commands, using markdown bullet points:")
+ return await models.gpt35.complete(f"{cmds_str}\n\nSummarize what was done in these shell commands, using markdown bullet points:")
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
cwd = await sdk.ide.getWorkspaceDirectory() if self.cwd is None else self.cwd
@@ -81,7 +81,7 @@ class ShellCommandsStep(Step):
for cmd in self.cmds:
output = await sdk.ide.runCommand(cmd)
if self.handle_error and output is not None and output_contains_error(output):
- suggestion = sdk.models.gpt35.complete(dedent(f"""\
+ suggestion = await sdk.models.gpt35.complete(dedent(f"""\
While running the command `{cmd}`, the following error occurred:
```ascii
@@ -152,10 +152,8 @@ class DefaultModelEditCodeStep(Step):
_prompt_and_completion: str = ""
async def describe(self, models: Models) -> Coroutine[str, None, None]:
- description = models.gpt35.complete(
+ description = await models.gpt35.complete(
f"{self._prompt_and_completion}\n\nPlease give brief a description of the changes made above using markdown bullet points. Be concise and only mention changes made to the commit before, not prefix or suffix:")
- # self.name = models.gpt35.complete(
- # f"Write a short title for this description: {description}")
return description
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
@@ -229,7 +227,8 @@ class DefaultModelEditCodeStep(Step):
prompt = self._prompt.format(
code=rif.contents, user_request=self.user_input, file_prefix=segs[0], file_suffix=segs[1])
- completion = str(model_to_use.complete(prompt, with_history=await sdk.get_chat_context()))
+ completion = str(await model_to_use.complete(prompt, with_history=await sdk.get_chat_context()))
+
eot_token = "<|endoftext|>"
completion = completion.removesuffix(eot_token)
diff --git a/continuedev/src/continuedev/steps/draft/migration.py b/continuedev/src/continuedev/steps/draft/migration.py
index 7c4b7eb5..f3b36b5e 100644
--- a/continuedev/src/continuedev/steps/draft/migration.py
+++ b/continuedev/src/continuedev/steps/draft/migration.py
@@ -13,7 +13,7 @@ class MigrationStep(Step):
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 = sdk.models.gpt35.complete(f"{recent_edits_string}\n\nGenerate a short description of the migration made in the above changes:\n")
+ description = await sdk.models.gpt35.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,
diff --git a/continuedev/src/continuedev/steps/input/nl_multiselect.py b/continuedev/src/continuedev/steps/input/nl_multiselect.py
index 36c489c7..aee22866 100644
--- a/continuedev/src/continuedev/steps/input/nl_multiselect.py
+++ b/continuedev/src/continuedev/steps/input/nl_multiselect.py
@@ -23,6 +23,6 @@ class NLMultiselectStep(Step):
if first_try is not None:
return first_try
- gpt_parsed = sdk.models.gpt35.complete(
+ gpt_parsed = await sdk.models.gpt35.complete(
f"These are the available options are: [{', '.join(self.options)}]. The user requested {user_response}. This is the exact string from the options array that they selected:")
return extract_option(gpt_parsed) or self.options[0]
diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py
index 0e42d8bf..5ba86c53 100644
--- a/continuedev/src/continuedev/steps/main.py
+++ b/continuedev/src/continuedev/steps/main.py
@@ -3,7 +3,6 @@ from typing import Coroutine, List, Union
from pydantic import BaseModel
-from ..libs.util.traceback_parsers import parse_python_traceback
from ..libs.llm import LLM
from ..models.main import Traceback, Range
from ..models.filesystem_edit import EditDiff, FileEdit
@@ -33,28 +32,6 @@ class SetupContinueWorkspaceStep(Step):
}"""))
-class RunCodeStep(Step):
- cmd: str
-
- async def describe(self, models: Models) -> Coroutine[str, None, None]:
- return f"Ran command: `{self.cmd}`"
-
- async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
- result = subprocess.run(
- self.cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout = result.stdout.decode("utf-8")
- stderr = result.stderr.decode("utf-8")
- print(stdout, stderr)
-
- # If it fails, return the error
- tb = parse_python_traceback(stdout) or parse_python_traceback(stderr)
- if tb:
- return TracebackObservation(traceback=tb)
- else:
- self.hide = True
- return None
-
-
class Policy(BaseModel):
pass
@@ -145,7 +122,7 @@ class FasterEditHighlightedCodeStep(Step):
for rif in rif_with_contents:
rif_dict[rif.filepath] = rif.contents
- completion = sdk.models.gpt35.complete(prompt)
+ completion = await sdk.models.gpt35.complete(prompt)
# Temporarily doing this to generate description.
self._prompt = prompt
@@ -213,7 +190,7 @@ class StarCoderEditHighlightedCodeStep(Step):
_prompt_and_completion: str = ""
async def describe(self, models: Models) -> Coroutine[str, None, None]:
- return models.gpt35.complete(f"{self._prompt_and_completion}\n\nPlease give brief a description of the changes made above using markdown bullet points:")
+ return await models.gpt35.complete(f"{self._prompt_and_completion}\n\nPlease give brief a description of the changes made above using markdown bullet points:")
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
range_in_files = await sdk.ide.getHighlightedCode()
@@ -247,7 +224,7 @@ class StarCoderEditHighlightedCodeStep(Step):
segs = full_file_contents.split(rif.contents)
prompt = f"<file_prefix>{segs[0]}<file_suffix>{segs[1]}" + prompt
- completion = str((await sdk.models.starcoder()).complete(prompt))
+ completion = str(await sdk.models.starcoder.complete(prompt))
eot_token = "<|endoftext|>"
completion = completion.removesuffix(eot_token)
diff --git a/continuedev/src/continuedev/steps/on_traceback.py b/continuedev/src/continuedev/steps/on_traceback.py
new file mode 100644
index 00000000..053b4ef4
--- /dev/null
+++ b/continuedev/src/continuedev/steps/on_traceback.py
@@ -0,0 +1,23 @@
+import os
+from ..core.main import Step
+from ..core.sdk import ContinueSDK
+from .chat import SimpleChatStep
+
+
+class DefaultOnTracebackStep(Step):
+ output: str
+ name: str = "Help With Traceback"
+ hide: bool = True
+
+ async def run(self, sdk: ContinueSDK):
+ # Add context for any files in the traceback that are in the workspace
+ for line in self.output.split("\n"):
+ segs = line.split(" ")
+ for seg in segs:
+ if seg.startswith(os.path.sep) and os.path.exists(seg) and os.path.commonprefix([seg, sdk.ide.workspace_directory]) == sdk.ide.workspace_directory:
+ file_contents = await sdk.ide.readFile(seg)
+ await sdk.add_chat_context(f"The contents of {seg}:\n```\n{file_contents}\n```", "", "user")
+
+ await sdk.run_step(SimpleChatStep(
+ name="Help With Traceback",
+ user_input=f"""I got the following error, can you please help explain how to fix it?\n\n{self.output}"""))
diff --git a/continuedev/src/continuedev/steps/react.py b/continuedev/src/continuedev/steps/react.py
index d825d424..4d310fc8 100644
--- a/continuedev/src/continuedev/steps/react.py
+++ b/continuedev/src/continuedev/steps/react.py
@@ -27,7 +27,7 @@ class NLDecisionStep(Step):
Select the step which should be taken next to satisfy the user input. Say only the name of the selected step. You must choose one:""")
- resp = sdk.models.gpt35.complete(prompt).lower()
+ resp = (await sdk.models.gpt35.complete(prompt)).lower()
step_to_run = None
for step in self.steps:
diff --git a/continuedev/src/continuedev/steps/search_directory.py b/continuedev/src/continuedev/steps/search_directory.py
index 9f4594b9..d2966f46 100644
--- a/continuedev/src/continuedev/steps/search_directory.py
+++ b/continuedev/src/continuedev/steps/search_directory.py
@@ -41,7 +41,7 @@ class WriteRegexPatternStep(Step):
async def run(self, sdk: ContinueSDK):
# Ask the user for a regex pattern
- pattern = sdk.models.gpt35.complete(dedent(f"""\
+ pattern = await sdk.models.gpt35.complete(dedent(f"""\
This is the user request:
{self.user_request}