empower-ai / empower-functions

GPT-4 level function calling models for real-world tool using use cases
https://www.empower.dev
204 stars 16 forks source link

Exception: Content of a message with role tool must be a valid JSON string (Internal Server Error 500) #5

Closed teddybear082 closed 2 weeks ago

teddybear082 commented 2 weeks ago

Hi, thanks very much for creating this model and repo. I'm excited to get it fully working.

I use software called WingmanAI from Shipbit (https://github.com/ShipBit/wingman-ai) which uses openai function calling extensively to perform actions like skills or commands in video games.

I have the empower-functions server running with the 4km gguf.

Chatting with the model works fine. However, when trying to call my first function (a web search tool in wingman) I got the error in the title.

The code for the web search skill including the tool definition it passes is here: https://github.com/ShipBit/wingman-ai/blob/main/skills/web_search/main.py

Any idea what might be causing this error? The traceback says its from line 62 of prompt.py in check and merge messages function.

EDIT: As I test more it seems this occurs if I start with normal chat then try to call a function. The function calling does work, but only if I clear my message history and then call a function. Example, if I say hi how are you? Model will return a normal chat response, If I then say "perform a web search" I get the 500 error. However if I clear messages and then say "perform a web search" as the first message the function calling works and does not error out. However it does not seem to "use" the information from the tool call response to generate a final response, eg the information obtained from the web.

dyang415 commented 2 weeks ago

Hi @teddybear082, thanks for submitting the issue. I think the problem is that the tool response is expected to be a JSON string while you provided a plain string. I just made an update on the pip package (v0.1.7) so now it should work.

Also updated the example to include a full tool calling round (user request, assistant tool calls, and tool response) https://github.com/empower-ai/empower-functions/blob/main/examples/openai_client.py, please take a look as a reference if necessary.

I will close the issue and please reopen if the issue persists.

teddybear082 commented 2 weeks ago

Confirmed this fixed my issue! Thank you!