Repository navigation
Add Replicate chat provider - #14958
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 as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Replicate as a new model provider: config and factory wiring, a ReplicateModel driver with HTTP prediction creation, polling and SSE streaming support, model discovery and stubbed unsupported methods, plus unit tests for request, polling, and streaming flows. ChangesReplicate Model Provider Integration
Sequence DiagramsequenceDiagram
participant Client
participant ReplicateAPI
participant SSEStream
Client->>ReplicateAPI: POST /v1/predictions (Authorization, stream=true?)
ReplicateAPI->>SSEStream: open SSE (Accept: text/event-stream)
SSEStream->>Client: events (output / error / done)
ReplicateAPI->>Client: GET /v1/predictions/<id> (polling, non-stream)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/entity/models/replicate_test.go`:
- Around line 62-66: The handler goroutine in replicate_test.go is using
t.Fatalf inside the http.HandlerFunc after json.Unmarshal (the block reading
raw, body and checking err); replace that t.Fatalf call with t.Errorf so
failures inside the handler are reported to the test runner rather than
terminating only the handler goroutine—update the error call where
json.Unmarshal is checked (the anonymous handler closure using t) to use
t.Errorf with the same message and error details.
- Around line 176-180: In the HTTP handler goroutine (the http.HandlerFunc that
reads r.Body into raw, unmarshals into body via json.Unmarshal), replace
t.Fatalf("body: %v", err) with t.Errorf("body: %v", err) so the test failure is
reported correctly from the goroutine; keep the rest of the error handling flow
(e.g., return from the handler after reporting the error) so the handler stops
processing when json.Unmarshal fails.
- Around line 83-85: Add an inline comment in the replicateInputFromMessages
implementation explaining why the ChatConfig.Stop field is intentionally not
forwarded to the Replicate API: mention that Stop (and similar fields) are
selectively forwarded and Stop is omitted because Replicate's upstream behavior
is undefined/unsupported; update the comment near the logic that drops Stop in
replicate.go (the block referenced in lines 151-160) and add a matching
explanatory comment above the test assertion in replicate_test.go (the assertion
checking input["stop"] is nil) so future readers understand this is intentional.
🪄 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: a85131ac-ccaa-41c3-8061-e9ab8ae91749
📒 Files selected for processing (4)
conf/models/replicate.jsoninternal/entity/models/factory.gointernal/entity/models/replicate.gointernal/entity/models/replicate_test.go
Haruko386
left a comment
There was a problem hiding this comment.
Hi @tmimmanuel.
Please make sure you know what you're doing.
Haruko386
left a comment
There was a problem hiding this comment.
Hi @tmimmanuel, I suggest these two changes.
It will be ok to merge after these
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14958 +/- ##
==========================================
- Coverage 95.59% 94.16% -1.43%
==========================================
Files 10 10
Lines 703 703
Branches 112 112
==========================================
- Hits 672 662 -10
- Misses 21 25 +4
- Partials 10 16 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
### What problem does this PR solve? `ReplicateModel.Rerank` in `internal/entity/models/replicate.go` was a `"replicate, no such method"` stub. The chat path landed in #14958 and the embed path in #15073; rerank is the last major retrieval surface still missing on this provider. Until this PR, a tenant who selected a Replicate reranker model got the sentinel error on every rerank call. Co-authored-by: sxxtony <[email protected]> Co-authored-by: Jin Hai <[email protected]>
What
urls.stream, model listing, and connection checksNotes
POST /v1/predictionswith Replicate model identifiers inversion, which supports official and community model identifiersprompt, optionalsystem_prompt) and forwards common documented LLM inputs:max_new_tokens,temperature,top_p[DONE]at stream completionTests
go test -vet=off -run TestReplicate -count=1 ./internal/entity/modelsgo test -vet=off -count=1 ./internal/entity/modelsRefs #14736