-
Notifications
You must be signed in to change notification settings - Fork 581
Add Google Gemini backend for AI chat #2602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
|
|
- Added APIType_GoogleGemini constant to uctypes - Created gemini package with backend, types, and message conversion - Implemented streaming support with SSE - Added tool calling (function calling) support - Added support for images, PDFs, and text files - Integrated gemini backend into usechat-backend.go Co-authored-by: sawka <[email protected]>
Co-authored-by: sawka <[email protected]>
Final implementation includes: - Full streaming chat support - Tool/function calling - Image, PDF, and text file uploads - Proper error handling and token tracking - Comprehensive documentation - No security issues found - All builds passing Co-authored-by: sawka <[email protected]>
|
@copilot please do not modify the go.mod / go.sum files in the tsunami demos |
These files were unintentionally modified during the build process. Only the main go.mod and go.sum should have been affected by the Gemini backend implementation. Co-authored-by: sawka <[email protected]>
Reverted all tsunami demo go.mod and go.sum files to their original state in commit 7963afb. These were unintentionally modified during the build process. |
|
@copilot i'd like to be able to test this using main-testai.go ... this lets me see the generated SSE packets etc to verify it is working. can you add a new flag... --google or --gemini to let me test.... |
- Added testGemini() function to test Google Gemini API - Added --gemini flag to command-line options - Added DefaultGeminiModel constant (gemini-2.0-flash-exp) - Updated usage/help text with Gemini examples - Added GOOGLE_APIKEY environment variable documentation - Supports tool calling and all Gemini capabilities Co-authored-by: sawka <[email protected]>
Co-authored-by: sawka <[email protected]>
Added export GOOGLE_APIKEY="your-api-key"
cd cmd/testai
go run main-testai.go --gemini 'What is 2+2?'The implementation includes tool support via |
|
@copilot : ❯ go run cmd/testai/main-testai.go --gemini --tools "what is 55+188, use the tool"
|
Gemini's API uses a strict subset of JSON Schema and rejects: - $schema field - units (custom property field) - title field - definitions field - $ref field - other non-standard fields Added cleanSchemaForGemini() function that filters the schema to only include fields that Gemini accepts (type, properties, required, description, items, enum, format, minimum, maximum, pattern, default). This fixes the "Invalid JSON payload received. Unknown name" errors when using tools with the --gemini flag in main-testai.go. Co-authored-by: sawka <[email protected]>
Fixed cleanSchemaForGemini to preserve property values that are not maps, ensuring the schema structure is maintained correctly. Co-authored-by: sawka <[email protected]>
Fixed in commits 2401379 and 2ade244. The issue was that Gemini's API uses a strict subset of JSON Schema and rejects fields like Added The tool calling should now work correctly with the |
Co-authored-by: sawka <[email protected]>
--geminiflag to main-testai.go for testingSummary
Successfully implemented a complete Google Gemini backend for WaveTerm's AI chat system. The implementation:
--geminiflag to main-testai.go for easy testing with SSE outputTesting
To test the Gemini backend using main-testai.go:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.