Skip to content

fix(openai): enable function calling for DeepSeek models#266

Open
yusiwen wants to merge 1 commit intoappleboy:mainfrom
yusiwen:fix/enable-function-calling-in-deepseek
Open

fix(openai): enable function calling for DeepSeek models#266
yusiwen wants to merge 1 commit intoappleboy:mainfrom
yusiwen:fix/enable-function-calling-in-deepseek

Conversation

@yusiwen
Copy link
Copy Markdown

@yusiwen yusiwen commented Apr 23, 2026

Summary

  • Remove the special-case that forces plain text completion for DeepSeek models in GetSummaryPrefix, enabling OpenAI-compatible function calling instead.

Problem

When using a DeepSeek model, GetSummaryPrefix in provider/openai/openai.go skips function calling and falls back to CreateChatCompletion due to this check:

if checkOSeriesModels.MatchString(c.model) ||
    strings.Contains(strings.ToLower(c.model), "deepseek") {
    resp, err = c.CreateChatCompletion(ctx, content)

The conventional_commit.tmpl prompt asks the model two questions:

  1. What's the best label for the commit?
  2. What's the best scope for the commit?

Since function calling is bypassed, the model responds with plain text like:

feat
auth

This raw text is returned directly as summarize_prefix (see openai.go:167-171 — the ToolCalls == 0 branch returns msg.Content without any post-processing), resulting in "feat\nauth" instead of the expected "feat(auth)" format.

This causes the final commit message to break across lines:

feat
auth: add new authentication module

Instead of the correct:

feat(auth): add new authentication module

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 structured prefix and scope arguments that are properly formatted as prefix(scope).

Test Plan

  • Verify codegpt commit with a DeepSeek model produces a commit message with prefix(scope) format (e.g., feat(auth): ...)
  • Verify codegpt commit with OpenAI o-series models still falls back to plain text completion as expected
  • Verify other providers (Anthropic, Gemini) are unaffected

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
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 17.31%. Comparing base (0125d86) to head (1510983).
⚠️ Report is 281 commits behind head on main.

Files with missing lines Patch % Lines
provider/openai/openai.go 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
go-1.25 17.31% <0.00%> (?)
go-1.26 17.31% <0.00%> (?)
macos-latest 17.31% <0.00%> (?)
ubuntu-latest 17.31% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant