8 تغريدة 9 قراءة Jun 15, 2023
🚨🤖New Agent Release🤖🚨
We can @OpenAI's new function parameter to create a new type of agent (`openai-functions`) now available in Python and JS
Links to documentation a thread on what went into it below 👇
Under the hood, we are heavily utilizing the new `functions` parameter available in the chat model
First, we convert the LangChain tool spec to the function tool spec the expect
We then call the language model with those parameters
Because of this new API, the prompt is a lot simpler - we don't waste any tokens telling the LLM what tools it has, how to structure output, etc
That's very nice!
We now get back a result from the LLM
If it contains the `function_call` argument, we parse that into a tool invocation
If it doesn't, then we just return to the user
We then go an execute the tool as usual
We then introduce a new type of message - a FunctionMessage - to pass the result of calling the tool back to the LLM
This message has `role=function` and is something new OpenAI introduced
We then continue until `function_call` is not returned from the LLM, meaning it's safe to return to the user!
Along the way, the current agent executor framework handles any errors (either in parsing or when calling the tool itself)
Overall, this fit quite nicely into the existing agent framework
Next up is to make this agent type (`openai-functions`) usable when you're using a SQL agent, a CSV agent, etc
But that might wait for tomorrow :)

جاري تحميل الاقتراحات...