waveterm/pkg/aiusechat
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
..
anthropic New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
chatstore New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
google Add Google AI file summarization package (#2455) 2025-10-17 17:24:06 -07:00
openai handle reasoning deltas and display them in the UI (#2443) 2025-10-16 11:17:24 -07:00
uctypes Updates to prepare for v0.12 launch (#2434) 2025-10-15 16:10:37 -07:00
toolapproval.go New data-tooluse AI SDK packet and Tool Approvals Implemented (#2407) 2025-10-09 10:21:01 -07:00
tools.go working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
tools_readdir.go working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
tools_readdir_test.go Add read_dir AI tool for reading directory contents (#2414) 2025-10-09 21:41:50 -07:00
tools_readfile.go working on more terminal context (#2444) 2025-10-17 12:19:40 -07:00
tools_screenshot.go Updates to prepare for v0.12 launch (#2434) 2025-10-15 16:10:37 -07:00
tools_term.go Updates to prepare for v0.12 launch (#2434) 2025-10-15 16:10:37 -07:00
tools_tsunami.go New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
tools_web.go Updates to prepare for v0.12 launch (#2434) 2025-10-15 16:10:37 -07:00
usechat-utils.go New AIPanel (#2370) 2025-10-07 13:32:10 -07:00
usechat.go reduce some logging for prod release (#2440) 2025-10-15 22:10:00 -07:00