fix(openai): enable function calling for DeepSeek models#266
Open
yusiwen wants to merge 1 commit intoappleboy:mainfrom
Open
fix(openai): enable function calling for DeepSeek models#266yusiwen wants to merge 1 commit intoappleboy:mainfrom
yusiwen wants to merge 1 commit intoappleboy:mainfrom
Conversation
DeepSeek models now officially support OpenAI-compatible function calling, so remove the special-case that forced plain text completion for them. 🤖 Generated with [Qoder][https://qoder.com]
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
==========================================
- Coverage 21.96% 17.31% -4.66%
==========================================
Files 8 36 +28
Lines 346 2374 +2028
==========================================
+ Hits 76 411 +335
- Misses 264 1929 +1665
- Partials 6 34 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetSummaryPrefix, enabling OpenAI-compatible function calling instead.Problem
When using a DeepSeek model,
GetSummaryPrefixinprovider/openai/openai.goskips function calling and falls back toCreateChatCompletiondue to this check:The
conventional_commit.tmplprompt asks the model two questions:Since function calling is bypassed, the model responds with plain text like:
This raw text is returned directly as
summarize_prefix(seeopenai.go:167-171— theToolCalls == 0branch returnsmsg.Contentwithout any post-processing), resulting in"feat\nauth"instead of the expected"feat(auth)"format.This causes the final commit message to break across lines:
Instead of the correct:
Solution
DeepSeek models now officially support OpenAI-compatible function calling. Removing the
strings.Contains(strings.ToLower(c.model), "deepseek")condition allows DeepSeek models to use the function calling path, which returns structuredprefixandscopearguments that are properly formatted asprefix(scope).Test Plan
codegpt commitwith a DeepSeek model produces a commit message withprefix(scope)format (e.g.,feat(auth): ...)codegpt commitwith OpenAI o-series models still falls back to plain text completion as expected