tmc / langchaingo

LangChain for Go, the easiest way to write LLM-based programs in Go
https://tmc.github.io/langchaingo/
MIT License
3.76k stars 523 forks source link

[Bug]OpenAI functions agent raise error #824

Open plum330 opened 1 month ago

plum330 commented 1 month ago

`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?

ivanvanderbyl commented 1 month ago

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

Vworri commented 1 month ago

me too

ankit-arora commented 1 month ago

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

ankit-arora commented 1 month ago

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

whichxjy commented 3 weeks ago

@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?🙏🏻