diff options
-rw-r--r-- | continuedev/src/continuedev/core/autopilot.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/server/ide.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/chat.py | 8 |
4 files changed, 11 insertions, 3 deletions
diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index 8da3ad3b..3beebbf0 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -33,7 +33,7 @@ def get_error_title(e: Exception) -> str: 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__() + return e.__str__() or e.__repr__() class Autopilot(ContinueBaseModel): diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index d929a612..d95a233f 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -195,7 +195,7 @@ class ContinueSDK(AbstractContinueSDK): for rif in highlighted_code: code = await self.ide.readRangeInFile(rif) msg = ChatMessage(content=f"{preface} ({rif.filepath}):\n```\n{code}\n```", - role="user", summary=f"{preface}: {rif.filepath}") + role="system", summary=f"{preface}: {rif.filepath}") # Don't insert after latest user message or function call i = -1 diff --git a/continuedev/src/continuedev/server/ide.py b/continuedev/src/continuedev/server/ide.py index ff0b2a24..cc8cb15e 100644 --- a/continuedev/src/continuedev/server/ide.py +++ b/continuedev/src/continuedev/server/ide.py @@ -79,7 +79,7 @@ class GetUserSecretResponse(BaseModel): class RunCommandResponse(BaseModel): - output: str + output: str = "" class UniqueIdResponse(BaseModel): diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py index 58f61198..5b4318c3 100644 --- a/continuedev/src/continuedev/steps/chat.py +++ b/continuedev/src/continuedev/steps/chat.py @@ -152,6 +152,8 @@ class ChatWithFunctions(Step): )) last_function_called_index_in_history = None + # GPT keeps wanting to call the non-existent 'python' function repeatedly, so limiting to once + already_called_python = False while True: was_function_called = False func_args = "" @@ -195,6 +197,9 @@ class ChatWithFunctions(Step): break else: if func_name == "python" and "python" not in step_name_step_class_map: + if already_called_python: + return + already_called_python = True # GPT must be fine-tuned to believe this exists, but it doesn't always func_name = "EditHighlightedCodeStep" func_args = json.dumps({"user_input": self.user_input}) @@ -231,6 +236,9 @@ class ChatWithFunctions(Step): summary=f"Called function {func_name}" )) last_function_called_index_in_history = sdk.history.current_index + 1 + if func_name not in step_name_step_class_map: + raise Exception( + f"The model tried to call a function ({func_name}) that does not exist. Please try again.") step_to_run = step_name_step_class_map[func_name]( **fn_call_params) |