Skip to content

Go: update chat URL - #14453

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix407
Apr 29, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix407

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

What problem does this PR solve?

Update the URL to: /api/v1/chat/completions

Type of change

  • Refactoring

Signed-off-by: Jin Hai <[email protected]>
@JinHai-CN JinHai-CN added the ci Continue Integration label Apr 29, 2026
@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR refactors the chat-to-model endpoint from a provider-instance-specific path to a unified /chat/completions endpoint. Request parameters—provider_name, instance_name, and model_name—move from URL path segments to optional JSON body fields, with server-side validation ensuring all three are present and non-empty.

Changes

Cohort / File(s) Summary
Request Structure Update
internal/handler/providers.go
Modified ChatToModelRequest struct to accept provider_name, instance_name, and model_name as optional pointer fields in JSON body instead of URL parameters. Added validation logic to ensure all three fields are present and non-empty, returning HTTP 400 if validation fails.
Endpoint Routing
internal/router/router.go
Changed route from /:provider_name/instances/:instance_name/models to unified POST /api/v1/chat/completions endpoint for the same handler.
Client-Side Alignment
internal/cli/user_command.go
Updated ChatToModel function to target /chat/completions endpoint and include provider_name and instance_name in request payload instead of URL path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

size:M

Poem

🐰 From paths of providers, we break free,
One endpoint unified, for all to see,
Parameters bundled in body instead,
The chat completions road lies straight ahead! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete; it only briefly mentions updating a URL and marks the type of change, but lacks detailed context about what problem this solves or why the refactoring is necessary. Expand the description to explain the rationale for migrating from provider-specific endpoints to the unified endpoint, implementation details, and expected impact or benefits of this refactoring.
Title check ❓ Inconclusive The title 'Go: update chat URL' is vague and generic, using non-descriptive language that doesn't clearly convey the specific change made to the codebase. Provide a more specific title that explains what was updated and why, such as 'Migrate chat endpoint to unified /api/v1/chat/completions path' or 'Refactor ChatToModel to use centralized chat completions endpoint'.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@JinHai-CN
JinHai-CN marked this pull request as ready for review April 29, 2026 03:24
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/router/router.go`:
- Line 221: Add a deprecated compatibility alias that keeps the old POST
/api/v1/providers/:provider_name/instances/:instance_name/models route pointing
to the same handler as the new route; i.e., register a v1.POST for
"/providers/:provider_name/instances/:instance_name/models" that calls
r.providerHandler.ChatToModel so existing CLI/clients continue to work while you
roll out the new POST "/chat/completions" endpoint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e68da0dc-117c-4660-b4ce-30f9cdc4fd71

📥 Commits

Reviewing files that changed from the base of the PR and between 74fa54f and b40acee.

📒 Files selected for processing (3)
  • internal/cli/user_command.go
  • internal/handler/providers.go
  • internal/router/router.go

Comment thread internal/router/router.go
provider.GET("/:provider_name/instances/:instance_name/models", r.providerHandler.ListInstanceModels)
provider.PATCH("/:provider_name/instances/:instance_name/models/*model_name", r.providerHandler.EnableOrDisableModel)
provider.POST("/:provider_name/instances/:instance_name/models", r.providerHandler.ChatToModel)
v1.POST("/chat/completions", r.providerHandler.ChatToModel)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Keep a compatibility alias for the old chat route.

This replaces the existing POST /api/v1/providers/:provider_name/instances/:instance_name/models contract with POST /api/v1/chat/completions. The CLI and frontend in this PR are updated, but any other /api/v1 clients will break immediately. Please keep the legacy route as a deprecated alias, or version the API change explicitly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/router/router.go` at line 221, Add a deprecated compatibility alias
that keeps the old POST
/api/v1/providers/:provider_name/instances/:instance_name/models route pointing
to the same handler as the new route; i.e., register a v1.POST for
"/providers/:provider_name/instances/:instance_name/models" that calls
r.providerHandler.ChatToModel so existing CLI/clients continue to work while you
roll out the new POST "/chat/completions" endpoint.

@codecov

codecov Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.30%. Comparing base (345bec8) to head (b40acee).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14453      +/-   ##
==========================================
- Coverage   96.72%   95.30%   -1.43%     
==========================================
  Files          10       10              
  Lines         703      703              
  Branches      112      112              
==========================================
- Hits          680      670      -10     
- Misses         12       16       +4     
- Partials       11       17       +6     

☔ 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.

@JinHai-CN
JinHai-CN merged commit b493a33 into infiniflow:main Apr 29, 2026
1 check passed
TIMBLOCKER pushed a commit to TIMBLOCKER/kira that referenced this pull request Apr 29, 2026
### What problem does this PR solve?

Update the URL to: /api/v1/chat/completions

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <[email protected]>
TIMBLOCKER pushed a commit to TIMBLOCKER/kira that referenced this pull request May 7, 2026
### What problem does this PR solve?

Update the URL to: /api/v1/chat/completions

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant