mirror of
https://github.com/cpacker/MemGPT.git
synced 2025-06-03 04:30:22 +00:00
Better interface output for function calls (#296)
Co-authored-by: Charles Packer <packercharles@gmail.com>
This commit is contained in:
parent
74b2d81f88
commit
194ce3d813
@ -1010,7 +1010,10 @@ class AgentAsync(Agent):
|
||||
|
||||
# If no failures happened along the way: ...
|
||||
# Step 4: send the info on the function call and function response to GPT
|
||||
await self.interface.function_message(f"Success: {function_response_string}")
|
||||
if function_response_string:
|
||||
await self.interface.function_message(f"Success: {function_response_string}")
|
||||
else:
|
||||
await self.interface.function_message(f"Success")
|
||||
messages.append(
|
||||
{
|
||||
"role": "function",
|
||||
|
@ -117,7 +117,7 @@ async def function_message(msg, debug=DEBUG):
|
||||
printd_function_message("", msg)
|
||||
return
|
||||
|
||||
if msg.startswith("Success: "):
|
||||
if msg.startswith("Success"):
|
||||
printd_function_message("🟢", msg)
|
||||
elif msg.startswith("Error: "):
|
||||
printd_function_message("🔴", msg)
|
||||
@ -125,11 +125,11 @@ async def function_message(msg, debug=DEBUG):
|
||||
if debug:
|
||||
printd_function_message("", msg)
|
||||
else:
|
||||
if "memory" in msg:
|
||||
match = re.search(r"Running (\w+)\((.*)\)", msg)
|
||||
if match:
|
||||
function_name = match.group(1)
|
||||
function_args = match.group(2)
|
||||
match = re.search(r"Running (\w+)\((.*)\)", msg)
|
||||
if match:
|
||||
function_name = match.group(1)
|
||||
function_args = match.group(2)
|
||||
if "memory" in function_name:
|
||||
print_function_message("🧠", f"updating memory with {function_name}")
|
||||
try:
|
||||
msg_dict = eval(function_args)
|
||||
@ -138,23 +138,26 @@ async def function_message(msg, debug=DEBUG):
|
||||
if STRIP_UI:
|
||||
print(output)
|
||||
else:
|
||||
print(f"{Fore.RED}{output}")
|
||||
print(f"{Fore.RED}{output}{Style.RESET_ALL}")
|
||||
elif function_name == "archival_memory_insert":
|
||||
output = f'\t→ {msg_dict["content"]}'
|
||||
if STRIP_UI:
|
||||
print(output)
|
||||
else:
|
||||
print(f"{Style.BRIGHT}{Fore.RED}{output}{Style.RESET_ALL}")
|
||||
else:
|
||||
if STRIP_UI:
|
||||
print(f'\t {msg_dict["old_content"]}\n\t→ {msg_dict["new_content"]}')
|
||||
else:
|
||||
print(f'{Style.BRIGHT}\t{Fore.RED} {msg_dict["old_content"]}\n\t{Fore.GREEN}→ {msg_dict["new_content"]}')
|
||||
print(
|
||||
f'{Style.BRIGHT}\t{Fore.RED} {msg_dict["old_content"]}\n\t{Fore.GREEN}→ {msg_dict["new_content"]}{Style.RESET_ALL}'
|
||||
)
|
||||
except Exception as e:
|
||||
printd(e)
|
||||
printd(str(e))
|
||||
printd(msg_dict)
|
||||
pass
|
||||
else:
|
||||
printd(f"Warning: did not recognize function message")
|
||||
printd_function_message("", msg)
|
||||
elif "send_message" in msg:
|
||||
# ignore in debug mode
|
||||
pass
|
||||
else:
|
||||
printd(f"Warning: did not recognize function message")
|
||||
printd_function_message("", msg)
|
||||
else:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user