microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
31.59k stars 4.59k forks source link

Json format error when using function call #314

Open sunyq1995 opened 11 months ago

sunyq1995 commented 11 months ago

Hi, I'm running the given example named agentchat_function_call.ipynb in the notebook, and meet the error that " You argument should follow json format.". It looks like the assistant agent return wrong format of code, could anyone help? Thanks!

All returns:

user_proxy (to chatbot):

Draw two agents chatting with each other with an example dialog. Don't add plt.show().

--------------------------------------------------------------------------------
chatbot (to user_proxy):

***** Suggested function Call: python *****
Arguments: 
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.text(0.5, 0.5, "Agent 1", ha="center", va="center", fontsize=14, bbox=dict(facecolor='blue', edgecolor='blue', boxstyle='round,pad=0.5'))

ax.text(0.5, 0.4, "Agent 2", ha="center", va="center", fontsize=14, bbox=dict(facecolor='red', edgecolor='red', boxstyle='round,pad=0.5'))

ax.text(0.5, 0.55, "Agent 1: Hey, how are you?", ha="center", va="center")
ax.text(0.5, 0.45, "Agent 2: I'm good, thanks! How about you?", ha="center", va="center")

ax.set_xlim(0, 1)
ax.set_ylim(0, 1)

ax.axis('off')

plt.savefig('chat.png')
plt.close()
*******************************************

--------------------------------------------------------------------------------
user_proxy (to chatbot):

***** Response from calling function "python" *****
Error: Expecting value: line 1 column 1 (char 0)
 You argument should follow json format.
***************************************************
--------------------------------------------------------------------------------
chatbot (to user_proxy):

***** Suggested function Call: sh *****
Arguments: 
pip install matplotlib
***************************************

--------------------------------------------------------------------------------
user_proxy (to chatbot):

***** Response from calling function "sh" *****
Error: Expecting value: line 1 column 1 (char 0)
 You argument should follow json format.
***********************************************

--------------------------------------------------------------------------------
sonichi commented 11 months ago

This can happen sometimes, especially with weak models. Is gpt-3.5 in use?

sunyq1995 commented 11 months ago

Hi @sonichi, thanks for your reply. I've tried to use gpt4, however, it returned same error as gpt3.5. and I'm also curious where is the return format provided to gpt?

sonichi commented 11 months ago

@kevin666aa could you follow up?

ewagner70 commented 8 months ago

have the same issue. please can you either resolve that issue, i.e. ensuring always json format for function calling or advise on how we can force/wrap/... the assistant return or user-proxy function call to be the required json (or make python function call accept also pure python code. in the meantime had to write separate function python call as the standard python code_execution seems to fail arbitrarily. propose to try to accept also pure function code or detecting missing json and auto-transform it.