Go: add Jina chat completions support#14935
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughImplements JinaModel.ChatWithMessages (synchronous chat completions) with region-aware base URL lookup, request validation, JSON request construction including optional chat params, timed HTTP POST with Bearer auth, response parsing to return the first choice's content, adds ChangesJina Chat Support
Sequence DiagramsequenceDiagram
participant Client
participant ChatWithMessages
participant baseURLForRegion
participant HTTP
participant ResponseParser
Client->>ChatWithMessages: Call ChatWithMessages(model, messages, apiConfig, chatModelConfig)
ChatWithMessages->>ChatWithMessages: Validate inputs (apiKey, model, messages)
ChatWithMessages->>baseURLForRegion: Resolve base URL for region
baseURLForRegion-->>ChatWithMessages: Return base URL or error
ChatWithMessages->>HTTP: POST /v1/chat/completions with JSON body + Authorization
HTTP-->>ChatWithMessages: Return JSON response (status 200)
ChatWithMessages->>ResponseParser: Parse JSON -> choices[0].message.content
ResponseParser-->>ChatWithMessages: Extracted content
ChatWithMessages-->>Client: Return ChatResponse{Answer: content, ReasonContent: ""}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
@Haruko386 @JinHai-CN |
Haruko386
left a comment
There was a problem hiding this comment.
@jakearmstrong59, If you’ve found the Jina Chat API documentation, please let me know.
|
@Haruko386 Thanks for your check. I tested the Jina chat endpoint with a real API key. Docs/source:
Live API result:
I updated the PR config and tests to use |
What problem does this PR solve?
This PR adds non-streaming chat support for the Jina Go model provider.
The Jina provider was added with embedding, rerank, model listing, and connection checking, but
ChatWithMessagesstill returned a not-implemented error even though Jina exposes an OpenAI-compatible/v1/chat/completionsendpoint.Closes #14933
The following functionalities are now supported:
Jina:
Implementation details:
JinaModel.ChatWithMessagesAuthorization: Bearer <api-key>and JSON chat completion requestsmax_tokens,temperature,top_p, andstopChatResponse.Answerjina-ai/jina-vlmas a chat-capable model inconf/models/jina.jsonVerification:
Note:
go test ./internal/entity/models -run TestJina -count=1currently hits unrelated existing vet findings in other provider files, so the focused Jina tests were run with-vet=off.Type of change