Repository navigation
feat(go-models): add Groq provider driver - #15097
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
📝 WalkthroughWalkthroughThis PR adds Groq provider support to the Go model-driver framework. It introduces a JSON configuration file defining the Groq OpenAI-compatible API defaults, registers the provider in the factory, implements a full-featured GroqModel driver with non-streaming and SSE streaming chat completions, model listing and connection checks, and comprehensive test coverage validating all code paths and error cases. ChangesGroq Model Provider Integration
Sequence Diagram(s)sequenceDiagram
participant Client
participant GroqModel
participant GroqAPI
participant Sender as SSE_Sender
rect rgba(100, 150, 200, 0.5)
Note over Client,GroqAPI: Non-streaming Chat Flow
Client->>GroqModel: ChatWithMessages(model, messages, apiConfig)
GroqModel->>GroqModel: Validate inputs
GroqModel->>GroqAPI: POST /chat/completions (stream=false)
GroqAPI-->>GroqModel: JSON response with choices[0]
GroqModel->>Client: ChatResponse{content, reasoning}
end
rect rgba(150, 150, 100, 0.5)
Note over Client,Sender: Streaming Chat Flow
Client->>GroqModel: ChatStreamlyWithSender(model, messages, apiConfig, sender)
GroqModel->>GroqAPI: POST /chat/completions (stream=true, Accept: text/event-stream)
GroqAPI-->>GroqModel: SSE stream (data: JSON events)
loop Process SSE Events
GroqModel->>GroqModel: Unmarshal event delta
GroqModel->>Sender: Send reasoning/content deltas
end
GroqAPI-->>GroqModel: [DONE]
GroqModel->>Sender: Send terminal "[DONE]"
GroqModel-->>Client: return nil
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes The PR introduces a new model driver with heterogeneous logic: HTTP client configuration, region-aware endpoint resolution, dual chat modes (blocking and streaming SSE), request/response marshaling with multiple field variations, error handling across network and API layers, and 15 test functions covering edge cases. The streaming implementation is the densest portion, requiring careful attention to SSE parsing, delta accumulation, terminal detection, and sender callback contracts. Test coverage is thorough but adds to review scope. Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
|
@JSONbored Since previous PR includes a binary file which is very big. So, I reset the head of main branch one hour ago. Would you please re-submit the commit from current HEAD of main branch? Thank you very much. |
Sure, i will get this handled now 👍🏻 |
Awesome, please let me know once you've finished. Thanks! |
Add a Groq Go model driver, provider catalog, factory registration, and focused tests for chat, streaming, model listing, connection checks, and custom base URL handling.
Fix vet-safe error formatting in existing model providers and align unsupported-method tests with currently implemented TogetherAI and Xinference capabilities so the Go model package validates cleanly.
Done! |
|
Hi @JSONbored, before I review your code, I want to know where I can find API Reference and Create API KEYS? |
Hi @Haruko386, Groq’s developer docs and API keys are under GroqCloud:
The endpoints used by this PR are documented there:
So the default base URL in this driver is |
|
@JSONbored emmm, I try to access these links, but it returned : {"error": {"message":"Forbidden"}}You can try it too. |
Hi @Haruko386, thanks for checking. I tested the same GroqCloud links from my environment and they return HTTP 200, so the The driver is using Groq’s OpenAI-compatible endpoints:
I cannot provide a Groq API key, since reviewers need to create/manage their own key in GroqCloud. If GroqCloud is blocked for your environment, live API verification may not be possible there. The PR includes |
|
@JSONbored I use VPN, and I can see the docs now, thank you for your time, I will review your code soon ;) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15097 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Closes #15088.
Adds Groq support to the Go model-provider layer so Groq instances can be routed through the Go API server with the same OpenAI-compatible chat, streaming, model listing, and connection-check flow used by other SaaS providers.
Type of change
Summary
What changed
Why
The existing Python/provider catalog path includes Groq, but the Go model-provider layer did not have a Groq driver, so the Go API server could not instantiate or use Groq as requested in #15088.
Validation
go test ./internal/entity/models -count=1go test ./internal/entity/... -count=1jq empty conf/models/groq.jsongit diff --checkNotes
The model package now validates without disabling vet.