refactor: extract google ai logic to windmill-common and use native gemini api in chat proxy#8115
refactor: extract google ai logic to windmill-common and use native gemini api in chat proxy#8115
Conversation
…emini api in chat proxy Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Deploying windmill with
|
| Latest commit: |
50191c4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://863606f0.windmill.pages.dev |
| Branch Preview URL: | https://ai-logic-share.windmill.pages.dev |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…t auth header Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ream" This reverts commit dfa01d2.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Extract streaming and non-streaming Gemini response conversion into shared functions in ai_google so the API proxy and worker use the same logic instead of duplicating format translation. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Remove duplicate parse_data_url from worker utils, use shared version from windmill_common::ai_google in both google_ai and anthropic providers - Improve error diagnostics in google.rs by including HTTP status code in error messages from Gemini API responses - Change GeminiToolCallEvent::into_extra_content to instance method to_extra_content using &self Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Claude finished @centdix's task in 3m 37s —— View job PR Review: Refactor Google AI Logic
Overall AssessmentWell-structured refactoring that cleanly extracts shared Google AI types and conversion logic into What looks good
Issues found (see inline comments)
Testing instructionsTo test the changes: go to a workspace's Settings > AI page. Configure a Google AI provider by adding a resource with a valid Gemini API key. Then navigate to any Script editor (or the AI Chat in the workspace) and start a conversation using a Google AI / Gemini model. Verify that both streaming responses (real-time token output) and non-streaming responses work correctly. Also test with tool calling if possible (e.g., a script with AI agent capabilities). Finally, verify that other providers (OpenAI, Anthropic, Bedrock) still work normally — their code paths should be unaffected by this change. |
…ht pattern Replace the worker's `convert_messages_to_gemini` and `convert_content_to_parts_with_s3` (~130 lines) with the existing pre-flight pattern: `prepare_messages_for_api` converts S3 objects to data URLs, then the shared `openai_messages_to_gemini` handles the rest. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
Extracts Google AI (Gemini) types and conversion logic from the worker into
windmill-common, mirroring the existing Bedrock pattern. The API chat proxy now uses the native Gemini API directly instead of routing through Google's OpenAI-compatibility shim (/openaisuffix).Changes
windmill-common/src/ai_google.rs(new): shared Gemini types, request/response structs, SSE event types, and conversion functions (openai_messages_to_gemini,openai_tools_to_gemini,parse_gemini_sse_event,parse_data_url,find_gemini_function_name)windmill-api/src/google.rs(new): native Gemini handler for the API chat proxy — converts OpenAI-format requests to Gemini format, callsstreamGenerateContent?alt=sseorgenerateContent, and converts responses back to OpenAI format for the frontendwindmill-api/src/ai.rs: routeGoogleAI+chat/completionsto the new native handler; remove the/openaisuffix hack fromprepare_request; exposeHTTP_CLIENT,KEEPALIVE_INTERVAL_SECS,inject_keepalivesaspub(crate)windmill-worker/src/ai/providers/google_ai.rs: import Gemini types fromwindmill-commoninstead of defining them locally; worker-specific S3 image handling stays in placewindmill-worker/src/ai/sse.rs: remove local Gemini SSE type definitions;GeminiSSEParser.parse_event_datanow delegates toparse_gemini_sse_eventfrom commonwindmill-api/Cargo.toml: addeventsource-streamdependency for HTTP SSE parsing in the new handlerTest plan
Generated with Claude Code