fix: CLI patches - patch runtime error on main loop + duplicate internal monologue (#1852)

This commit is contained in:
Charles Packer
2024-10-08 17:47:29 -07:00
committed by GitHub
parent 020bbd658e
commit fa0b0a5b9f
2 changed files with 5 additions and 2 deletions

View File

@@ -556,9 +556,12 @@ class Agent(BaseAgent):
) # extend conversation with assistant's reply
printd(f"Function call message: {messages[-1]}")
nonnull_content = False
if response_message.content:
# The content if then internal monologue, not chat
self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
# Flag to avoid printing a duplicate if inner thoughts get popped from the function call
nonnull_content = True
# Step 3: call the function
# Note: the JSON response may not always be valid; be sure to handle errors
@@ -619,7 +622,7 @@ class Agent(BaseAgent):
if "inner_thoughts" in function_args:
response_message.content = function_args.pop("inner_thoughts")
# The content if then internal monologue, not chat
if response_message.content:
if response_message.content and not nonnull_content:
self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
# (Still parsing function args)

View File

@@ -366,7 +366,7 @@ def run_agent_loop(
first_message=False,
skip_verify=no_verify,
stream=stream,
inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs,
ms=ms,
)
new_messages = step_response.messages