diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-25 13:44:31 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-25 13:44:31 -0700 |
commit | 4b394e96a57e0a018cb815e929bf28b445e17ae0 (patch) | |
tree | 445b9839396e8000b0fabd14fb7f4294730fb0c9 | |
parent | b72cbb40276b811bebbe3a82c43c71d3cfe1a147 (diff) | |
download | sncontinue-4b394e96a57e0a018cb815e929bf28b445e17ae0.tar.gz sncontinue-4b394e96a57e0a018cb815e929bf28b445e17ae0.tar.bz2 sncontinue-4b394e96a57e0a018cb815e929bf28b445e17ae0.zip |
don't call python function, other
-rw-r--r-- | continuedev/src/continuedev/libs/llm/openai.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/chat.py | 13 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/core/core.py | 3 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/main.py | 5 | ||||
-rw-r--r-- | extension/react-app/src/components/HeaderButtonWithText.tsx | 2 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 1 |
6 files changed, 20 insertions, 6 deletions
diff --git a/continuedev/src/continuedev/libs/llm/openai.py b/continuedev/src/continuedev/libs/llm/openai.py index aa12d70a..7621111f 100644 --- a/continuedev/src/continuedev/libs/llm/openai.py +++ b/continuedev/src/continuedev/libs/llm/openai.py @@ -70,7 +70,7 @@ class OpenAI(LLM): messages=compile_chat_messages( args["model"], with_history, prompt, with_functions=False), **args, - )).choices[0].message + )).choices[0].message.content else: resp = (await openai.Completion.acreate( prompt=prompt, diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py index 76fead9d..a940c3ba 100644 --- a/continuedev/src/continuedev/steps/chat.py +++ b/continuedev/src/continuedev/steps/chat.py @@ -105,7 +105,7 @@ class ViewDirectoryTreeStep(Step): class EditFileStep(Step): name: str = "Edit File" - description: str = "Edit a file in the workspace." + description: str = "Edit a file in the workspace that is not currently open." filename: str instructions: str hide: bool = True @@ -136,7 +136,7 @@ class ChatWithFunctions(Step): self.chat_context.append(ChatMessage( role="user", - content=self.user_input, + content=self.user_input + "\n**DO NOT EVER call the 'python' function.**", summary=self.user_input )) @@ -183,6 +183,15 @@ class ChatWithFunctions(Step): if func_name == "python" and "python" not in step_name_step_class_map: # GPT must be fine-tuned to believe this exists, but it doesn't always self.chat_context.append(ChatMessage( + role="assistant", + content=None, + function_call=FunctionCall( + name=func_name, + arguments=func_args + ), + summary=f"Ran function {func_name}" + )) + self.chat_context.append(ChatMessage( role="user", content="The 'python' function does not exist. Don't call it.", summary="'python' function does not exist." diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py index 7ccf82cb..f146c94a 100644 --- a/continuedev/src/continuedev/steps/core/core.py +++ b/continuedev/src/continuedev/steps/core/core.py @@ -213,7 +213,8 @@ class DefaultModelEditCodeStep(Step): if model_to_use.name == "gpt-4": - total_tokens = model_to_use.count_tokens(full_file_contents + self._prompt) + total_tokens = model_to_use.count_tokens( + full_file_contents + self._prompt) cur_start_line, cur_end_line = cut_context( model_to_use, total_tokens, cur_start_line, cur_end_line) diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py index bb48dce9..5caac180 100644 --- a/continuedev/src/continuedev/steps/main.py +++ b/continuedev/src/continuedev/steps/main.py @@ -1,7 +1,7 @@ import os from typing import Coroutine, List, Union -from pydantic import BaseModel +from pydantic import BaseModel, Field from ..libs.llm import LLM from ..models.main import Traceback, Range @@ -246,7 +246,8 @@ class StarCoderEditHighlightedCodeStep(Step): class EditHighlightedCodeStep(Step): - user_input: str + user_input: str = Field( + ..., title="User Input", description="The natural language request describing how to edit the code") hide = True description: str = "Change the contents of the currently highlighted code or open file" diff --git a/extension/react-app/src/components/HeaderButtonWithText.tsx b/extension/react-app/src/components/HeaderButtonWithText.tsx index acaca9ce..5901c5d8 100644 --- a/extension/react-app/src/components/HeaderButtonWithText.tsx +++ b/extension/react-app/src/components/HeaderButtonWithText.tsx @@ -6,12 +6,14 @@ interface HeaderButtonWithTextProps { text: string; onClick?: (e: any) => void; children: React.ReactNode; + disabled?: boolean; } const HeaderButtonWithText = (props: HeaderButtonWithTextProps) => { const [hover, setHover] = useState(false); return ( <HeaderButton + disabled={props.disabled} style={{ padding: "1px", paddingLeft: hover ? "4px" : "1px" }} onMouseEnter={() => setHover(true)} onMouseLeave={() => { diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index 74a1c4e8..827d2d5f 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -200,6 +200,7 @@ function StepContainer(props: StepContainerProps) { <> <HeaderButtonWithText + disabled={props.historyNode.active as boolean} onClick={(e) => { e.stopPropagation(); props.onDelete(); |