don't call python function, other

This commit is contained in:
Nate Sesti 2023-06-25 13:44:31 -07:00
parent 54048d3e7b
commit 8db3dcb7b9
6 changed files with 20 additions and 6 deletions

View file

@ -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,

View file

@ -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
))
@ -182,6 +182,15 @@ class ChatWithFunctions(Step):
else:
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.",

View file

@ -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)

View file

@ -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"

View file

@ -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={() => {

View file

@ -200,6 +200,7 @@ function StepContainer(props: StepContainerProps) {
<>
<HeaderButtonWithText
disabled={props.historyNode.active as boolean}
onClick={(e) => {
e.stopPropagation();
props.onDelete();