✨ feat: upgrade to the new `tool calls` mode
💻 变更类型 | Change Type
- [x] ✨ feat
- [ ] 🐛 fix
- [ ] ♻️ refactor
- [ ] 💄 style
- [ ] 🔨 chore
- [ ] ⚡️ perf
- [ ] 📝 docs
🔀 变更说明 | Description of Change
Tool Calling 调用模式升级
- close #999
- close #1790
- close #1876
支持更多有 Function Calling 能力的 Provider 使用插件
- [ ] 支持 Claude 插件调用(Anthropic), close #1472, close #1929
- [x] 支持 GLM 插件调用(Zhipu), close #1535
- [x] 支持 Moonshot 插件调用,close #2208
- [x] 支持 Minimax 插件调用, close #2394
- [x] 支持 Groq 插件调用
- [x] 支持 Google 插件调用, close #1561
Model Provider 体验优化
- [ ] 气泡点样式优化
- [ ] 允许重置 model-list
📝 补充信息 | Additional Information
refs:
- https://github.com/lobehub/lobe-chat/discussions/1310
- Tool Calling 流式也解决了 GLM Tool Calling 不规范的问题: https://github.com/lobehub/lobe-chat/discussions/737#discussioncomment-8315815
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| lobe-chat-community | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 11, 2024 3:17pm |
👍 @arvinxx
Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。
考虑支持一下Ollama么
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Consider supporting Ollama?
@BrandonStudio Ollama 本身不支持 Function Calling,等他们支持了我们就很容易支持
Ollama 应该是支持的吧?Langchain 可以用 https://python.langchain.com/v0.1/docs/integrations/chat/ollama_functions/
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Ollama should support it, right? Langchain can be used https://python.langchain.com/v0.1/docs/integrations/chat/ollama_functions/
@BrandonStudio ollama 原生不支持,https://github.com/lobehub/lobe-chat/issues/2220#issuecomment-2081298640 。langchain 支持大概率是它做了 ReAct 之类的工程优化才实现的,但是否生产可用我挺怀疑的。我还是倾向等待 Ollama 官方的原生实现方案。
Example from Ollama Functions
from langchain_core.prompts import PromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_experimental.llms.ollama_functions import OllamaFunctions
# Schema for structured response
class Person(BaseModel):
name: str = Field(description="The person's name", required=True)
height: float = Field(description="The person's height", required=True)
hair_color: str = Field(description="The person's hair color")
# Prompt template
prompt = PromptTemplate.from_template(
"""Alex is 5 feet tall.
Claudia is 1 feet taller than Alex and jumps higher than him.
Claudia is a brunette and Alex is blonde.
Human: {question}
AI: """
)
# Chain
llm = OllamaFunctions(model="phi3", format="json", temperature=0)
structured_llm = llm.with_structured_output(Person)
chain = prompt | structured_llm
chain.invoke({"question": "Who are the persons?"})
will be converted to
api/chat
{
"messages": [
{
"role": "system",
"content": "You have access to the following tools:\n\n[\n {\n \"name\": \"Person\",\n \"properties\": {\n \"name\": {\n \"title\": \"Name\",\n \"description\": \"The person's name\",\n \"required\": true,\n \"type\": \"string\"\n },\n \"height\": {\n \"title\": \"Height\",\n \"description\": \"The person's height\",\n \"required\": true,\n \"type\": \"number\"\n },\n \"hair_color\": {\n \"title\": \"Hair Color\",\n \"description\": \"The person's hair color\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"name\",\n \"height\",\n \"hair_color\"\n ]\n }\n]\n\nYou must always select one of the above tools and respond with only a JSON object matching the following schema:\n\n{\n \"tool\": <name of the selected tool>,\n \"tool_input\": <parameters for the selected tool, matching the tool's JSON schema>\n}\n",
"images": []
},
{
"role": "user",
"content": "Alex is 5 feet tall. \nClaudia is 1 feet taller than Alex and jumps higher than him. \nClaudia is a brunette and Alex is blonde.\n\nHuman: Who are the persons?\nAI: ",
"images": []
}
],
"model": "phi3",
"format": "json",
"options": {
"mirostat": null,
"mirostat_eta": null,
"mirostat_tau": null,
"num_ctx": null,
"num_gpu": null,
"num_thread": null,
"num_predict": null,
"repeat_last_n": null,
"repeat_penalty": null,
"temperature": 0.0,
"stop": null,
"tfs_z": null,
"top_k": null,
"top_p": null
},
"system": null,
"template": null,
"keep_alive": null
}
And this is streamable.
Codecov Report
Attention: Patch coverage is 88.50000% with 184 lines in your changes are missing coverage. Please review.
Project coverage is 93.37%. Comparing base (
ebcd083) to head (fed7083). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2414 +/- ##
==========================================
+ Coverage 92.80% 93.37% +0.56%
==========================================
Files 302 317 +15
Lines 17646 18827 +1181
Branches 2041 1406 -635
==========================================
+ Hits 16377 17579 +1202
+ Misses 1269 1248 -21
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
❤️ Great PR @arvinxx ❤️
The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx 或 @canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。
That is a huge improvement of tool calls. Eager to try it out 😁.
:tada: This PR is included in version 0.157.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: