Skip to content

fix(go-models): fix MiniMax driver requests - #15527

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
oktofeesh1:codex/minimax-driver-requests
Jun 8, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
oktofeesh1:codex/minimax-driver-requests

Conversation

@oktofeesh1

Copy link
Copy Markdown
Contributor

Summary

  • keep MiniMax chat calls in non-streaming mode and streaming calls in SSE mode
  • make MiniMax model listing and connection checks use a bodyless GET /v1/models
  • add focused MiniMax request/response regression tests

What changed

  • return a real MiniMax driver from NewInstance
  • validate API keys, model names, and stream senders before issuing requests
  • remove raw SSE line logging from the chat stream path
  • parse ListModels responses with typed structs instead of unchecked assertions

Why

MiniMax documents its OpenAI-compatible model list endpoint as GET /v1/models with bearer auth: https://platform.minimax.io/docs/api-reference/models/openai/list-models. The previous driver sent a JSON body on that GET, let callers flip the expected stream mode, and could panic on malformed model-list responses.

Validation

  • go test ./internal/entity/models -run TestMinimax -count=1
  • git diff --check

Notes

  • Also ran go test ./internal/entity/models -count=1; it currently fails in an unrelated upstream Astraflow embedding test before this MiniMax-specific coverage is involved.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e84a37c-257a-47bc-8bc3-6baf3291235d

📥 Commits

Reviewing files that changed from the base of the PR and between 789f901 and ad2f7cf.

📒 Files selected for processing (2)
  • internal/entity/models/minimax.go
  • internal/entity/models/minimax_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/entity/models/minimax_test.go
  • internal/entity/models/minimax.go

📝 Walkthrough

Walkthrough

Refactors the Minimax client to add centralized input validation, enforce non-streaming chat requests and strict response parsing, expand streaming request parameters and SSE headers, perform bodyless GET for model listing, delegate CheckConnection to ListModels, and add a comprehensive httptest-based test suite.

Changes

Minimax API Integration Refactoring and Testing

Layer / File(s) Summary
Import removal and test scaffolding
internal/entity/models/minimax.go, internal/entity/models/minimax_test.go
Removes an obsolete import, adds test file scaffolding, and provides test server + NewInstance wiring for tests.
ChatWithMessages: non-streaming request and strict parsing
internal/entity/models/minimax.go, internal/entity/models/minimax_test.go
Adds model-name validation, forces stream=false, sets Content-Type and Authorization from trimmed key, and requires a non-empty choices array; tests cover normal parsing and empty-choice rejection.
ChatStreamlyWithSender: input validation, model-config mapping, SSE headers
internal/entity/models/minimax.go, internal/entity/models/minimax_test.go
Validates sender and model, maps modelConfig fields (max_tokens, temperature, top_p, do_sample, stop, thinking/reasoning_split) into streaming request body, sets Accept: text/event-stream, removes per-line SSE logging; tests cover SSE parsing and nil-config acceptance.
ListModels: bodyless GET and typed parsing; CheckConnection
internal/entity/models/minimax.go, internal/entity/models/minimax_test.go
Trims API key, issues a bodyless GET with Accept: application/json, parses into a typed response ensuring non-empty data[].id, and delegates CheckConnection to ListModels; tests verify bodyless GET, id trimming, and malformed-response rejection.
httptest-based test coverage for behaviors and validation
internal/entity/models/minimax_test.go
Adds test server helpers and a suite exercising NewInstance, chat (streaming and non-streaming), model listing, connection checks, and input validation error cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14478: Introduced the initial Minimax provider implementation; this PR refactors and tightens the same functions with improved validation and response parsing.

Suggested reviewers

  • Haruko386

Suggested labels

🐞 bug

Poem

🐰 I trim the keys and watch the stream,
Headers neat and choices seen,
Tests hum softly, events are done,
Models listed, ids all one,
A carrot for each passing run.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description provides comprehensive context but does not follow the required template structure with explicit 'What problem does this PR solve?' and 'Type of change' sections. Reorganize the description to match the template: add a 'What problem does this PR solve?' section and explicitly select the 'Type of change' with checkboxes (this is a Bug Fix).
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(go-models): fix MiniMax driver requests' clearly and specifically describes the main change—fixing MiniMax driver request handling to align with API specifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oktofeesh1

Copy link
Copy Markdown
Contributor Author

Hi @Haruko386 @JinHai-CN - please review when you have a little time. 🤝

@Haruko386 Haruko386 added the ci Continue Integration label Jun 3, 2026

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oktofeesh1 Do a small change would be ok

Comment thread internal/entity/models/minimax.go Resolved
@oktofeesh1
oktofeesh1 force-pushed the codex/minimax-driver-requests branch from a4a2a44 to c8707b6 Compare June 7, 2026 16:15
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

@oktofeesh1 Do a small change would be ok

Fixed, thanks for the review

@oktofeesh1
oktofeesh1 requested a review from Haruko386 June 7, 2026 16:19
@codecov

codecov Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (220ee9d) to head (ad2f7cf).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15527   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 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.

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread internal/entity/models/minimax.go Resolved
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

@oktofeesh1

Fixed as well!

@oktofeesh1
oktofeesh1 requested a review from Haruko386 June 8, 2026 06:07

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oktofeesh1
please refer this and fetch the latest code

Comment thread internal/entity/models/minimax.go Resolved
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

Thanks, I fetched/rebased onto the latest upstream code and verified the MiniMax paths now follow the current pattern: ChatWithMessages, ChatStreamlyWithSender, and ListModels call m.baseModel.APIConfigCheck(apiConfig), then use strings.TrimSpace(*apiConfig.ApiKey) for the Authorization header. Validation passed with go test ./internal/entity/models -run 'TestMinimax' -count=1, go test ./internal/entity/models -run '^$' -count=1, go vet ./internal/entity/models, and git diff --check.

@oktofeesh1
oktofeesh1 force-pushed the codex/minimax-driver-requests branch from 789f901 to ad2f7cf Compare June 8, 2026 06:30
@oktofeesh1
oktofeesh1 requested a review from Haruko386 June 8, 2026 06:33

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 8, 2026
@JinHai-CN
JinHai-CN merged commit e0dc7af into infiniflow:main Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants