-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: LocalAI functions #726
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Signed-off-by: mudler <mudler@localai.io>
It also needs a llama.cpp with grammar branch + rebased on current master
Signed-off-by: mudler <mudler@localai.io>
tested also on x86_64 GPU and works. Seems all good to go. |
Add notice to documentation Signed-off-by: mudler <mudler@localai.io>
Great work! But I have a problem with using this PR with Langchain OpenAI Functions Agent. My code: llm_tools = tools.tux_load_tools(llm, memory=None) mrkl = initialize_agent(llm_tools, llm, agent=AgentType.OPENAI_MULTI_FUNCTIONS, verbose=True) mrkl.run( Output: Are there any compatibility problems with json output with langchains function agents? |
good catch, thanks @Rybens92 , should be fixed now |
Signed-off-by: mudler <mudler@localai.io>
Signed-off-by: mudler <mudler@localai.io>
Description
This PR closes #588 and #354
It implements LocalAI functions - which are compatible with OpenAI functions but works differently (there is no expectations from the model to return valid JSON)
It is based on the fantastic work done in llama.cpp by @ejones ( ❤️ ) in ggml-org/llama.cpp#1773 and ggml-org/llama.cpp#1887
This PR wires up functions to a grammar generator. The functions passed via API are parsed, and a grammar is generated to constrain the LLM to output specific JSON fields.
Small bad, but needed things:
Extra:
grammar
and agrammar_json_functions
parameter is added to/chat/completions
to pass by JSON or grammars to constrain the outputfunction
template to customize the template function promptLimitations:
Next, nice to have items:
with this is now possible to emulate OpenAI functions and run directly their examples:
See also my tweet: https://twitter.com/mudler_it/status/1675524071457533953
Notes for Reviewers
Signed commits