langchaingo icon indicating copy to clipboard operation
langchaingo copied to clipboard

[Bug]OpenAI functions agent raise error

Open plum330 opened this issue 9 months ago • 6 comments

`agent := agents.NewExecutor(agents.NewOpenAIFunctionsAgent(qar.data.llm[index], toolKits), toolKits)

result, err = chains.Run(ctx, agent, input, options...)`

toolKits are self-defined tool,which implement the tool interface, the following is http request body partial parameter about function: [     {         "type": "function",         "function": {             "name": "query_conversation",             "description": "Query history conversation, if history conversation contain relevant info",             "parameters": {                 "properties": {                     "__arg1": {                         "title": "__arg1",                         "type": "string"                     }                 },                 "required": [                     "__arg1"                 ],                 "type": "object"             }         }     },     {         "type": "function",         "function": {            "name": "search_info",             "description": "Search for general information about enrollment, should be used tools cannot provide more specific information",             "parameters": {                 "properties": {                     "__arg1": {                         "title": "__arg1",                         "type": "string"                     }                 },                 "required": [                     "__arg1"                 ],                 "type": "object"             }         }     } ] Execute the above code and return an error(API returned unexpected status code: 400: Missing parameter 'name': messages with role 'function' must have a 'name') So, where is wrong?

plum330 avatar May 08 '24 08:05 plum330

I'm getting the same error following the test case for openai agents.

ivanvanderbyl avatar May 13 '24 01:05 ivanvanderbyl

me too

Vworri avatar May 24 '24 02:05 Vworri

I got the same error. I'll try fixing it

ankit-arora avatar May 26 '24 07:05 ankit-arora

I've added a fix for this and upgraded to the latest OpenAI API. PR: https://github.com/tmc/langchaingo/pull/858

ankit-arora avatar May 26 '24 19:05 ankit-arora

@tmc It seems the OpenAI Functions Agent is currently not working. Could you please take a look at this issue when you have a chance?🙏🏻

whichxjy avatar Jun 12 '24 03:06 whichxjy

I've rebased @ankit-arora's code and submit a PR https://github.com/tmc/langchaingo/pull/1054

nuffin avatar Oct 24 '24 09:10 nuffin