mirror of
https://github.com/deepseek-ai/DeepSeek-R1.git
synced 2026-11-05 00:47:42 +00:00
[GH-ISSUE #9] Function calling #9
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-R1#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sigren on GitHub (Jan 20, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/9
When will R1 support function calling and structured outputs? Thanks
@FORNDODAper commented on GitHub (Jan 21, 2025):
x2
('x2' stands for 'yeah, i would like to know that too')
@reatang commented on GitHub (Jan 21, 2025):
x2 + 1
@flyfish101 commented on GitHub (Jan 21, 2025):
x2 + 2
@ghost commented on GitHub (Jan 21, 2025):
x2 + 3
@lzl-mt commented on GitHub (Jan 21, 2025):
x2 + 4
@juanjopc commented on GitHub (Jan 21, 2025):
x2 + 5
@engalisabry commented on GitHub (Jan 21, 2025):
Response to Issue #9: Function Calling and Structured Outputs
Thank you for your question and for the community’s interest in this feature! Below, I’ve addressed the current status and future plans for function calling and structured outputs in DeepSeek R1.
Current Status
Future Plans
Timeline
Workarounds for Now
If you need structured outputs or function-like behavior in the meantime, here are some workarounds:
Post-Processing Outputs:
Prompt Engineering:
Custom Wrapper:
Community Feedback
We appreciate the enthusiasm from the community (x2 + 5 and counting!). Your feedback is invaluable in shaping the future of DeepSeek R1. If you have specific use cases or feature requests related to function calling and structured outputs, please share them in this thread.
Next Steps
Thank you for your patience and support as we work to make DeepSeek R1 even better! Let us know if you have further questions or need additional assistance.
@ibndias commented on GitHub (Jan 22, 2025):
Use R1 as the master brain for tool decision / plan, and rewrite the output in structure with another model.
@jacobpretorius commented on GitHub (Jan 22, 2025):
I would really like the model to support structured output, such as JSON. For now, no matter how much I tell it to only output JSON it is not consistent. I don't mind the section I think that is useful and very easy to remove with some string handling, but it needs to adhere to JSON output if asked in its final response.
@Chrisbattarbee commented on GitHub (Jan 22, 2025):
Also looking for this
@feliks912 commented on GitHub (Jan 23, 2025):
Bump, definitely bump
@jayeew commented on GitHub (Jan 23, 2025):
When will R1 support agent?
@letscagefdn commented on GitHub (Jan 23, 2025):
response_format: { type: 'json_object' }
@bgarnr commented on GitHub (Jan 24, 2025):
Thank you. I look forward to having a provider that allows my Microsoft Semantic Kernel powered application to use Deepseek as an alternative for auto function calling.
@Dey-Sumit commented on GitHub (Jan 24, 2025):
x2
@justinlietz93 commented on GitHub (Jan 25, 2025):
https://github.com/justinlietz93/agent_tools
I built a suite of tools and a wrapper for deepseek reasoner to use, check it out
@enemchy commented on GitHub (Jan 25, 2025):
My application automates code generation using file operations via functional calls. Currently, integrating R1 requires significant refactoring due to the lack of function calling support, even though this feature is already standardized in most models (OpenAI, Anthropic, Mistral, etc.). To migrate from other models to R1, I must rewrite critical components of the application, which increases transition costs and error risks. Without function calling support, developers are forced to adopt less efficient workarounds or delay adopting R1, despite its exceptional code generation capabilities.
Accelerating the development of function calling for R1 will lower the entry barrier for communities relying on industry-standard approaches.
@justinlietz93 commented on GitHub (Jan 25, 2025):
Can you please email me, feel free to look at my agent_tools repo, I have powerful tools for Deepseek R1 and I’m improving them daily. Jlietz93@gmail.com, I have more contact links on my github
@phpmac commented on GitHub (Jan 26, 2025):
go
@vepicurean commented on GitHub (Jan 26, 2025):
Agree with the original feature request ( function calling and structured outputs standard features on a API now), without structured outputs, it's nearly impossible to achieve targeted data accuracy levels for many applications. When needing data accuracy of 99.999% on large volumes ( hundreds of thousands of records), structured outputs made a huge difference in the accuracy of my responses for unstructured ( document store) database queries using o1-mini.
Function calling, yes, I could do the workaround as suggested), but given the time and effort I already put into the development of the autonomous agent back end programming, I'd prefer not to go backwards and put in workarounds to use R1 when hopefully my existing code using function calling will be adequate when the R series of models and the DeepSeek API can in fact support function calling - hopefully the DeepSeek function calling and structured outputs performance will be just as good as on the OpenAI API using o1 and gpt-4o.
@abylikhsanov commented on GitHub (Jan 26, 2025):
x2
@aaronvg commented on GitHub (Jan 27, 2025):
We got function-calling to work with R1 using our framework BAML: https://www.boundaryml.com/blog/deepseek-r1-function-calling . We haven't had any issues making it spit out structured data.
It doesn't need tool-apis or whatnot, we just serialize types into the prompt in an efficient way, and parse the output using a custom JSON parser to handle missing quotes etc.
Let us know if you do. Here is our open-source repo: https://github.com/BoundaryML/baml
@dickens88 commented on GitHub (Jan 27, 2025):
I'm also looking forward
@justinlietz93 commented on GitHub (Jan 27, 2025):
Awesome I’m going to take a look, because I’ve been building something for the same idea, to allow any LLM to use any tool
@MehdiBukhari commented on GitHub (Jan 29, 2025):
Looking forward deep seek with function calling
@jenyss commented on GitHub (Jan 29, 2025):
+1
@thorwebdev commented on GitHub (Jan 30, 2025):
In case this is helpful for others, looks like the Qwen-32B distillation https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B/discussions/7 has support for function calling.
@danruggi commented on GitHub (Jan 30, 2025):
Asking for
"response_format": {'type': 'json_object' }
too
Thanks for the effort
@krasserm commented on GitHub (Feb 6, 2025):
One possible alternative to builtin function calling via JSON is to leverage DeepSeek-R1's strong coding capabilities and let the model generate code actions in Python. I experimented with this approach and found that it outperforms Claude 3.5 Sonnet on agentic tasks by a large margin (65.5% vs 53.1% on a GAIA validation subset). I used freeact as agent scaffold.
@sammcj commented on GitHub (Feb 9, 2025):
I've spent the past week testing DeepSeek R1 with Cline, Roo Coder and a number of other agentic coding tools using a combination of templates and prompting methods. While R1 is clearly a very capable model in general - in reality it's not practical to use (especially in production) due to it's lack of tool/function calling.
I believe what we need is a battle-tested template or fine tune from DeepSeek to enable reliable tool/function calling.
@thiner commented on GitHub (Feb 11, 2025):
DeepSeek just updated chat template in https://hf-mirror.com/deepseek-ai/DeepSeek-R1/blob/main/tokenizer_config.json two days ago. I think there is problem with the built-in template which blocks function call previously. You may update the chat template and try again.
@feedback9999 commented on GitHub (Feb 11, 2025):
view it on GitHub
---Original---
From: @.>
Date: Tue, Feb 11, 2025 15:52 PM
To: @.>;
Cc: @.***>;
Subject: Re: [deepseek-ai/DeepSeek-R1] Function calling (Issue #9)
DeepSeek just updated chat template in https://hf-mirror.com/deepseek-ai/DeepSeek-R1/blob/main/tokenizer_config.json two days ago. I think there is problem with the built-in template which blocks function call previously. You may update the chat template and try again.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
@icejean commented on GitHub (Feb 14, 2025):
支持函数调用应该成为DeepSeek R1目前优先级最高的事项。
因为DeepSeek R1开源、低成本、能力与OpenAI o1相当,现在国内大部分的云厂商都接入了DeepSeek,包括R1与V3,R1目前不支持工具调用,用于深度思考推理;V3支持函数调用,用于智能体Agent。这在调用云端API的应用场景下没有问题,云厂商在云端部署两个模型,应用分别调用R1与V3两个模型就好了。
但企业内网私有化部署的情况就很不相同了,考虑到数据保密、服务稳定以及集成进企业业务系统的需求,很多稍有规模的组织会优先考虑内网私有化部署DeepSeek R1满血版,企业级的应用各种蒸馏版难以胜任,必须是满血版,这需要一定的硬件投资。因此国内的各大厂商,从三大运营商到各头部云服务商等等,都推出了DeepSeek R1一体机的解决方案,通过1台或2台服务器在内网部署,成本大约在150万到200万RMB之间。
2025将是Agent应用的爆发之年,大模型在各种应用场景中落地应用,与业务系统集成,调用业务系统的API或业务功能去执行特定的任务,将是比问题问答更常见、更有用的LLM落地应用范式,就是AI可以自动化的去完成一些任务了。所以V3这样的函数调用功能是必须的,最好也有结构化输出的功能,方便与业务系统之间的数据交换。
另一方面,R1的深度思考推理能力非常出色,在提供合符真实世界运作逻辑的计划、推理、分析等业务场景中也是必不可少的,比如在GraphRAG的应用场景中,从企业积累的大量各种Wrod、PDF、txt等各种非结构化的文档中建立知识图谱,以知识图谱来支持RAG,即GraphRAG,回答问题就比普通RAG质量要高一个档次。因为普通RAG不管怎样优化文本块切分、检索和排序的算法,它都是线性的,无法像知识图谱一样反映现实世界中实体之间的真实逻辑。R1在从非结构化文档中提取实体关系来建立知识图谱这项任务上,表现要比OpenAI gtp-4o等没有思维链的模型要高一个档次,从它输出的思维链可以看到,它会自动处理文本语义中各种千变万化的情况,你不可能穷尽列举它们硬编码到代码中,R1类的思维链模型就非常适合这样的场景。
所以,在企业内网私有化部署的场景下,R1是必须的,V3的工具调用能力也是必须的,如果R1自己就有函数调用的能力,就可以节省一套服务器硬件150~200万的投资,很多企业上线以DeepSeek为核心的AI赋能项目就会容易很多,DeepSeek的普及会更快更广。
@hello2mao commented on GitHub (Feb 14, 2025):
+1
@KelvinQiu802 commented on GitHub (Feb 16, 2025):
+1
@issamovitch commented on GitHub (Feb 16, 2025):
x2 + 8
@zhangshan123 commented on GitHub (Feb 18, 2025):
x2 + 9
@hyacinthus commented on GitHub (Feb 19, 2025):
x2 + 10
@Superskyyy commented on GitHub (Feb 21, 2025):
No, this is just a best pratice to encourage model to think. In fact adding this template will break things (frontend UI) because they don't see the starting /Think anymore and will fail to render the thinking block.
@GaoDalie commented on GitHub (Feb 23, 2025):
how i fix it
https://www.youtube.com/watch?v=_OTm88z9o54
@elliotvilhelm commented on GitHub (Feb 26, 2025):
x1
@paulluap commented on GitHub (Feb 26, 2025):
+1, any news on function calling ?
@tianyuansun commented on GitHub (Feb 26, 2025):
+1
@hnlisf commented on GitHub (Feb 28, 2025):
+1
@nbarbettini commented on GitHub (Feb 28, 2025):
You don't need to comment with +1 -- just click the 👍 on the top comment. And if you want to be subscribed to updates, click the "Subscribe" button on the right.
Otherwise all of our inboxes are flooded with "+1" messages 😉
@K0IN commented on GitHub (Feb 28, 2025):
+1
@zgpnuaa commented on GitHub (Mar 17, 2025):
+1 期待早日实现函数调用,将会大大增强deepseek在各种需要精确分析领域的利用率。
@FingerLiu commented on GitHub (Mar 18, 2025):
Is this bug on the engineering side or the algorithm side?
@zzzzzzzs commented on GitHub (Mar 18, 2025):
+1
@ParadeTo commented on GitHub (Mar 19, 2025):
+1
@oneWalker commented on GitHub (Mar 20, 2025):
I think the devs are considering the standard of it. after all, the new standard about MCP is more relevant to the feature. They may choose the MCP general standard. Of course, it's just my guess.
@shtse8 commented on GitHub (Mar 23, 2025):
停止無意義的 +1 回應,支持的可以直接點讚就好。
Stop posting meaningless +1 replies. If you support it, just click like.
@reatang commented on GitHub (Mar 27, 2025):
deepseep-v3-0324 已经到来,朋友们还是让r1做好 reasoning吧
@phpmac commented on GitHub (Mar 27, 2025):
让deepseek再次伟大!
@TonyGeez commented on GitHub (Apr 28, 2025):
I think it will be a better approach to first fix the almost unusable function calling on V3 which is actually "support it".
@flamezhang commented on GitHub (Apr 28, 2025):
x2 + 6
@aaronvg commented on GitHub (Apr 29, 2025):
note this still works with v3!
@BradKML commented on GitHub (May 27, 2025):
Can someone help out here? Especially for @aaronvg please make them work with agent coding tools for both debugging and feature development in more complex codebases https://github.com/cline/cline/discussions/3845
Also, cross-reference to some of the weird v3 issues https://github.com/deepseek-ai/DeepSeek-V3/issues/826 https://github.com/deepseek-ai/DeepSeek-V3/issues/302
@chunlea commented on GitHub (May 29, 2025):
https://api-docs.deepseek.com/news/news250528 mentioned the new DeepSeek-R1-0528 release support for functional calling and JSON outputs. Can we assume this issue has been done?
@flamezhang commented on GitHub (May 29, 2025):
No, the stability is not very good. Sometimes the function call will not be executed.
---- Replied Message ----
| From | @.> |
| Date | 05/29/2025 22:05 |
| To | deepseek-ai/DeepSeek-R1 @.> |
| Cc | flame @.>,
Comment @.> |
| Subject | Re: [deepseek-ai/DeepSeek-R1] Function calling (Issue #9) |
chunlea left a comment (deepseek-ai/DeepSeek-R1#9)
https://api-docs.deepseek.com/news/news250528 mentioned the new DeepSeek-R1-0528 release support for functional calling and JSON outputs. Can we assume this issue has been done?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>
@BradKML commented on GitHub (May 30, 2025):
Noted with thanks,are there any root cause for this with Ollama or OpenRouter, with RooCode / Cline or other IDEs, and maybe tools like OpenHands?
@r1di commented on GitHub (May 30, 2025):
nope, still issues(tested in cursor).
@alertzcomp commented on GitHub (May 30, 2025):
I've also got different scores/results in "tool_calls" vs "reasoning_content". Do you know if function call is executed after or before reasoning?
UPD. Day later.
Ok as per https://api-docs.deepseek.com/guides/reasoning_model it does use "reasoning_content" for "content" where function call happens.
Speaking about the function calling itself the
tool_choiceis not supported but out of 300 calls I've got 6 one time retry attempts where there were no function calls done. So just implement retry and this issue could be called done 👍🏻The only issue is that it seems that function calling of the
contentand thereasoning_contentCoT often seem to not align in their decision making at all.@github-actions[bot] commented on GitHub (Jul 2, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@Kayra commented on GitHub (Jul 11, 2025):
@engalisabry Any update on this? I'm hoping to use r1 as an NLP API and having consistent JSON output is critical, thanks!
For others still looking, there's an alternative here that "works" (your mileage may vary) with ollama: https://ollama.com/MFDoom/deepseek-r1-tool-calling
@github-actions[bot] commented on GitHub (Aug 11, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@BradKML commented on GitHub (Aug 11, 2025):
Keep this up, native function calling Should still be important, and @Kayra please check the other config-makers as well https://github.com/RooCodeInc/Roo-Code/discussions/1508#discussioncomment-13291453
@edenreich commented on GitHub (Aug 20, 2025):
When would this be implemented, I need it for the CLI.
https://github.com/inference-gateway/cli/issues/84
Also would be cool to know when the API call is happening with tools being passed to deepseek-reasoner model does it fall back to deepseek-chat? or is it actually running deepseek-reasoner with tool calling and we just don't see the reasoning_content?
@github-actions[bot] commented on GitHub (Oct 17, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@github-actions[bot] commented on GitHub (Oct 31, 2025):
false