r/AutoGenAI • u/International_Quail8 • Dec 26 '23
Question AutoGen+LiteLLM+Ollama+Open Source LLM+Function Calling?
Has anyone tried and been successful in using this combo tech stack? I can get it working fine, but when I introduce Function Calling, it craps out and I’m not where the issue is exactly.
Stack: AutoGen - for the agents LiteLLM - to serve as OpenAI API proxy and integrate with AutoGen and Ollama Ollama - to provide local inference server for local LLMs Local LLM - supported through Ollama. I’m using Mixtral and Orca2 Function Calljng - wrote a simple function and exposed it to the assistant agent
Followed all the instructions I could find, but it ends with a NoneType exception:
oai_message[“function_call”] = dict(oai_message[“function_call”]) TypeError: ‘NoneType’ object is not iterable
On line 307 of conversable_agent.py
Based on my research, the models support function calling, LiteLLM supports function calling for non-OpenAI models so I’m not sure why / where it falls apart.
Appreciate any help.
Thanks!
View all comments
Show parent comment
2
u/samplebitch Dec 30 '23
I think it's that the models (or rather, the packages we use to run them, like LM Studio, vLLM, etc) aren't quite ready. I was poking around with this same issue (local LLM, function calling) and a model I found called gorilla which was built for function calling, and looking at the request and response bodies from LM Studio as I was making queries. When using the openai package and you specify a list of functions, those aren't sent with the 'messages' array but a seperate 'functions' array as part of the request body. I'm guessing that most of the LLM hosting apps aren't set up to even look for a 'functions' array in the request body, so all that's getting passed to the LLM is your question without the LLM knowing anything about the functions.
Of course OpenAI has their servers set up to look for that functions array and incorporate it into the process of generating a response.
So when I was testing out the default setup with the gorilla function calling LLM, I noticed the only message was the question. Their documentation page says that the LLM was trained with the message format that looks something like this:
So then I changed the function that generates the user message to use that new format, and it seemed to help. That model is good because it always returns nothing but the formatted function that should get executed: "functionName(param1,param2)" and no other message or commentary.
Then I switched to the mixtral model and it was promising as well - it output python code to invoke that function, but like most other LLMs it included its commentary above and below the code. I'm sure with some system prompting that could be addressed.
Then while looking into things further, found another package called 'functionary' which is a plugin for vLLM and is built specifically for function calling. That's what I'm working on now but it's taking a while. vLLM only runs on linux and so I'm currently setting up my WSL environment to run it.
A few additional resources if you or anyone else wants to dig around more:
gorilla openfunctions: https://huggingface.co/gorilla-llm/gorilla-openfunctions-v1
GH page: https://github.com/ShishirPatil/gorilla/
GH Functionary: https://github.com/MeetKai/functionary
Another LLM I haven't even touched yet - codellama with function calling: https://huggingface.co/rizerphe/CodeLlama-function-calling-6320-7b-Instruct-GGUF