Skip to content

Commit

Permalink
fix: Fix profile generator in-prompt example for functions compatibil…
Browse files Browse the repository at this point in the history
…ity mode

- Updated the in-prompt example in the profile generator to be compatible with functions compatibility mode.
- Modified the example call section to correctly reflect the structure of function calls.
  • Loading branch information
Pwuts committed Nov 7, 2023
1 parent 1b4e921 commit cd55da5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions autogpts/autogpt/autogpt/agent_factory/profile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class AgentProfileGeneratorConfiguration(SystemConfiguration):
"\n"
"Example Input:\n"
'"""Help me with marketing my business"""\n\n'
"Example Function Call:\n"
"Example Call:\n"
"```\n"
"{"
"[" # tool_calls
'{"type": "function", "function": {'
'"name": "create_agent",'
' "arguments": {'
'"name": "CMOGPT",'
Expand All @@ -65,7 +66,9 @@ class AgentProfileGeneratorConfiguration(SystemConfiguration):
"]" # constraints
"}" # directives
"}" # arguments
"}\n"
"}" # function
"}" # tool call
"]\n" # tool_calls
"```"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ def extract_command(
raise InvalidAgentResponseError("No 'tool_calls' in assistant reply")
assistant_reply_json["command"] = {
"name": assistant_reply["tool_calls"][0]["function"]["name"],
"args": json.loads(assistant_reply["tool_calls"][0]["function"]["arguments"]),
"args": json.loads(
assistant_reply["tool_calls"][0]["function"]["arguments"]
),
}
try:
if not isinstance(assistant_reply_json, dict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ def _get_completion_kwargs(
if functions:
if OPEN_AI_CHAT_MODELS[model_name].has_function_call_api:
completion_kwargs["tools"] = [
{"type": "function", "function": f.schema}
for f in functions
{"type": "function", "function": f.schema} for f in functions
]
if len(functions) == 1:
# force the model to call the only specified function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class AssistantFunctionCallDict(TypedDict):


class AssistantToolCall(BaseModel):
id: str
# id: str
type: Literal["function"]
function: AssistantFunctionCall


class AssistantToolCallDict(TypedDict):
id: str
# id: str
type: Literal["function"]
function: AssistantFunctionCallDict

Expand Down

0 comments on commit cd55da5

Please sign in to comment.