Copilot
|
0d04b99b46
|
Add Google AI file summarization package (#2455)
- [x] Create new directory pkg/aiusechat/google
- [x] Implement SummarizeFile function with:
- Context parameter for timeout
- File validation (images, PDFs, text files only)
- Use gemini-2.5-flash-lite model
- Configurable API URL and prompt as constants
- Return (string, usage, error)
- [x] Define Google-specific usage struct
- [x] Test the implementation (all tests pass)
- [x] Verify with existing linting and build
- [x] Run CodeQL security check (no issues found)
- [x] Revert unintended tsunami demo dependency changes
## Summary
Successfully implemented a new Google AI package at
`pkg/aiusechat/google` with:
1. **SummarizeFile function** - A simple request-response API (not
streaming, not SSE)
- Takes context for timeout
- Validates file types (images, PDFs, text only)
- Enforces file size limits matching wshcmd-ai.go
- Uses gemini-2.5-flash-lite model
- Returns (summary string, usage stats, error)
2. **GoogleUsage struct** - Tracks token consumption:
- PromptTokenCount
- CachedContentTokenCount
- CandidatesTokenCount
- TotalTokenCount
3. **Configurable constants**:
- GoogleAPIURL (for reference)
- SummarizePrompt (customizable prompt)
- SummarizeModel (gemini-2.5-flash-lite)
4. **Comprehensive tests** - 41.7% coverage with all tests passing
5. **Security verified** - No CodeQL alerts
6. **Package documentation** - doc.go with usage examples
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
|
2025-10-17 17:24:06 -07:00 |
|