Conversation
…ntation - Replace deprecated google/generative-ai-go/genai package with google.golang.org/genai and update imports accordingly - Refactor Gemini provider: update API usage to reflect new genai client structure and methods - Update completion and function call logic to use explicit content/message structs rather than genai.Text - Add internal error handling for invalid function call responses - Improve usage metrics extraction with additional nil checks - Remove unused imports and update client initialization logic to match new genai API - Add new indirect dependencies in go.mod (google.golang.org/genai, github.com/google/go-cmp, github.com/gorilla/websocket) - Remove obsolete and unused dependencies in go.mod Signed-off-by: appleboy <[email protected]>
|
Caution Review failedThe pull request is closed. WalkthroughThe changes update the Gemini provider's integration with Google's generative AI APIs. The dependency management in Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GeminiClient as Gemini Provider
participant GenAI as Google GenAI API
User->>GeminiClient: Completion(ctx, content)
GeminiClient->>GenAI: GenerateContent(model, content, config)
GenAI-->>GeminiClient: Response (text, usage metadata)
GeminiClient-->>User: core.Response (text, usage)
User->>GeminiClient: GetSummaryPrefix(ctx, content)
GeminiClient->>GenAI: GenerateContent(model, content, config with function call)
GenAI-->>GeminiClient: Response (function call result)
GeminiClient-->>User: core.Response (prefix or error)
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
go.mod (1)
3-3:⚠️ Potential issue
go 1.24will break builds on current Go tool-chainsThe latest publicly released version is 1.22. Declaring an unreleased major version prevents
gocommands (including CI, IDE tooling and third-party modules) from working unless contributors run a development build of Go.Unless you really need a bleeding-edge feature gated to 1.24, roll this back to the latest stable tag (
go 1.22) so the module can be consumed everywhere.provider/gemini/gemini.go (1)
17-26: 🛠️ Refactor suggestion
debugstruct field is dead code and fails linting
golangci-lintalready flags it (unused). Either (a) wire it into meaningful behaviour or (b) drop the field to keep the struct minimal.-type Client struct { - client *genai.Client - model string - maxTokens int32 - temperature float32 - topP float32 - debug bool -} +type Client struct { + client *genai.Client + model string + maxTokens int32 + temperature float32 + topP float32 +}🧰 Tools
🪛 GitHub Check: lint
[failure] 25-25:
field debug is unused (unused)🪛 GitHub Actions: Lint and Testing
[error] 25-25: golangci-lint: field debug is unused (unused)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (3)
go.mod(2 hunks)provider/gemini/func.go(1 hunks)provider/gemini/gemini.go(3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Lint and Testing
provider/gemini/gemini.go
[error] 25-25: golangci-lint: field debug is unused (unused)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (3)
go.mod (1)
36-41:Details
❓ Verification inconclusive
Double-check that the new indirect deps are actually needed
github.com/google/go-cmpandgithub.com/gorilla/websocketsuddenly appear as indirect requirements. Their presence is fine if they are truly pulled in via the newgenaiclient, but they often creep in through test-only or transitive paths and can later be pruned by runningRun the tidy command and commit the resulting
go.mod/go.sumto avoid dragging unused code into downstream consumers.
🏁 Script executed:
go mod tidyLength of output: 4485
Commit
go mod tidyresults and verify indirect depsThe
go mod tidyrun didn’t removegithub.com/google/go-cmporgithub.com/gorilla/websocket, so they remain as indirect requirements. Please:
- Confirm these modules are genuinely pulled in (e.g. by the new
genaiclient) rather than through a test-only or spurious transitive path.- Run
git diff go.mod go.sumand commit any changes fromgo mod tidyto prevent unused dependencies from leaking downstream.provider/gemini/func.go (1)
3-3: Import path update looks good – just remember to do a full build test
google.golang.org/genaireplaces the deprecated path, which is correct.
A quickgo vet ./...after this change will flush out any lingering references to the old package.provider/gemini/gemini.go (1)
30-47:Details
✅ Verification successful
Possible API mismatch:
client.Models.GenerateContentsignatureThe v1.x examples for
google.golang.org/genaishow usage like:model := client.GenerativeModel("gemini-pro") resp, err := model.GenerateContent(ctx, parts...)Here the call is:
resp, err := c.client.Models.GenerateContent(ctx, c.model, data, cfg)If
Models.GenerateContentdoes not exist (or its parameter list differs), this will not compile. Please run:and adjust to the idiomatic pattern if needed (e.g. obtain a
model := c.client.GenerativeModel(c.model)first).
🏁 Script executed:
go vet ./...Length of output: 14
🏁 Script executed:
#!/bin/bash # Find definition of Models field/type and GenerateContent method signature set -e echo "Searching for client type definition and Models field..." rg "type .*Client" -A5 -B5 echo -e "\nSearching for 'Models' usage in the client struct..." rg "Models" -A5 -B5 echo -e "\nSearching for GenerateContent method definition..." rg "GenerateContent(" -R -A3 -nLength of output: 6186
🏁 Script executed:
#!/bin/bash # Inspect go.mod for google.golang.org/genai requirement if [ -f go.mod ]; then echo "go.mod entries for genai:" rg "google.golang.org/genai" -n go.mod || true echo -e "\nListing installed modules including genai:" go list -m all | grep "google.golang.org/genai" || true else echo "No go.mod file found in repository root." fiLength of output: 334
No API mismatch found;
Models.GenerateContentis valid in v1.3.0
go vet ./...ran without errors ongoogle.golang.org/genai v1.3.0, confirming thatc.client.Models.GenerateContent(ctx, c.model, data, cfg)matches the published API. No changes required.
- Add github.com/yassinebenaid/godump v0.11.1 as a new dependency - Import godump in the gemini provider code - Dump Gemini API response candidates to console when debug mode is enabled Signed-off-by: appleboy <[email protected]>
- Remove the ErrInvalidFunctionCall error declaration - Refactor error handling in GetSummaryPrefix to provide more granular error messages for missing candidates, content, function calls, or prefix values - Store the extracted prefix in a variable to simplify assignment to the response object Signed-off-by: appleboy <[email protected]>
Summary by CodeRabbit