diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-29 17:32:03 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-29 17:32:03 -0700 |
commit | 45e483ef6168f46dd8ec17b7c4b2d27cd950ea8d (patch) | |
tree | fb6d027b87f22602dddf783c151ff67677cfb81f /continuedev/src | |
parent | 9df27293326b26a78eeaf7e3fbbb2dcae56899d6 (diff) | |
download | sncontinue-45e483ef6168f46dd8ec17b7c4b2d27cd950ea8d.tar.gz sncontinue-45e483ef6168f46dd8ec17b7c4b2d27cd950ea8d.tar.bz2 sncontinue-45e483ef6168f46dd8ec17b7c4b2d27cd950ea8d.zip |
small fixes
Diffstat (limited to 'continuedev/src')
-rw-r--r-- | continuedev/src/continuedev/core/autopilot.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/main.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/chat.py | 23 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/core/core.py | 2 |
4 files changed, 22 insertions, 7 deletions
diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index 7d149e7e..8da3ad3b 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -31,6 +31,8 @@ def get_error_title(e: Exception) -> str: return e._message elif isinstance(e, ClientPayloadError): return "The request to OpenAI failed. Please try again." + elif isinstance(e, openai_errors.APIConnectionError): + return "The request failed. Please check your internet connection and try again." return e.__repr__() diff --git a/continuedev/src/continuedev/core/main.py b/continuedev/src/continuedev/core/main.py index 1d2b0cad..4c6f4dc2 100644 --- a/continuedev/src/continuedev/core/main.py +++ b/continuedev/src/continuedev/core/main.py @@ -111,7 +111,7 @@ class HistoryNode(ContinueBaseModel): content=json.dumps({ "description": self.step.description or "Function complete", }), - summary=f"Ran function {self.step.name}" + summary=f"Called function {self.step.name}" )] diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py index ccb7f62a..58f61198 100644 --- a/continuedev/src/continuedev/steps/chat.py +++ b/continuedev/src/continuedev/steps/chat.py @@ -1,6 +1,8 @@ import json from typing import Any, Coroutine, List +from pydantic import Field + from .main import EditHighlightedCodeStep from .core.core import MessageStep from ..core.main import FunctionCall, Models @@ -113,8 +115,10 @@ class ViewDirectoryTreeStep(Step): class EditFileStep(Step): name: str = "Edit File" description: str = "Edit a file in the workspace that is not currently open." - filename: str - instructions: str + filename: str = Field( + ..., description="The name of the file to edit.") + instructions: str = Field( + ..., description="The instructions to edit the file.") hide: bool = True async def run(self, sdk: ContinueSDK): @@ -201,7 +205,7 @@ class ChatWithFunctions(Step): # name=func_name, # arguments=func_args # ), - # summary=f"Ran function {func_name}" + # summary=f"Called function {func_name}" # )) # self.chat_context.append(ChatMessage( # role="user", @@ -212,7 +216,11 @@ class ChatWithFunctions(Step): # continue # Call the function, then continue to chat func_args = "{}" if func_args == "" else func_args - fn_call_params = json.loads(func_args) + try: + fn_call_params = json.loads(func_args) + except json.JSONDecodeError: + raise Exception( + "The model returned invalid JSON. Please try again") self.chat_context.append(ChatMessage( role="assistant", content=None, @@ -220,7 +228,7 @@ class ChatWithFunctions(Step): name=func_name, arguments=func_args ), - summary=f"Ran function {func_name}" + summary=f"Called function {func_name}" )) last_function_called_index_in_history = sdk.history.current_index + 1 step_to_run = step_name_step_class_map[func_name]( @@ -234,5 +242,10 @@ class ChatWithFunctions(Step): # self.description += f"\nAdded directory `{func_args['directory_name']}`" # else: # self.description += f"\n`Running function {func_name}`\n\n" + if func_name == "EditHighlightedCodeStep": + step_to_run.user_input = self.user_input + elif func_name == "EditFile": + step_to_run.instructions = self.user_input + await sdk.run_step(step_to_run) await sdk.update_ui() diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py index c8acd7c5..887a6434 100644 --- a/continuedev/src/continuedev/steps/core/core.py +++ b/continuedev/src/continuedev/steps/core/core.py @@ -454,7 +454,7 @@ class DefaultModelEditCodeStep(Step): self._prompt_and_completion += prompt + completion async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]: - self.description = f"{self.user_input}" + self.description = f"`{self.user_input}`" await sdk.update_ui() rif_with_contents = [] |