{"modulePath":"github.com/wavetermdev/waveterm","version":"v0.14.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package google\n\nPackage google provides Google Generative AI integration for WaveTerm.\n\nThis package implements file summarization using Google's Gemini models. Unlike other AI provider implementations in the aiusechat package, this package does NOT implement full SSE streaming. It uses a simple request-response API for file summarization.\n\n### Supported File Types {#hdr-Supported_File_Types}\n\nThe package supports the same file types as defined in wshcmd-ai.go:\n\n  - Images (PNG, JPEG, etc.): up to 7MB\n  - PDFs: up to 5MB\n  - Text files: up to 200KB\n\nBinary files are rejected unless they are recognized as images or PDFs.\n\n### Usage {#hdr-Usage}\n\nTo summarize a file:\n\n\tctx := context.Background()\n\tsummary, usage, err := google.SummarizeFile(ctx, \"/path/to/file.txt\", google.SummarizeOpts{\n\t\tAPIKey: \"YOUR_API_KEY\",\n\t\tMode:   google.ModeQuickSummary,\n\t})\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"Summary:\", summary)\n\tfmt.Printf(\"Tokens used: %d\\n\", usage.TotalTokenCount)\n\n### Configuration {#hdr-Configuration}\n\nThe summarization behavior can be customized by modifying the constants:\n\n  - SummarizeModel: The Gemini model to use (default: \"gemini-2.5-flash-lite\")\n  - SummarizePrompt: The prompt sent to the model\n  - GoogleAPIURL: The base URL for the API (for reference, not currently used by the SDK)\n\n## Constants\n\n```go\nconst (\n\t// GoogleAPIURL is the base URL for the Google Generative AI API\n\tGoogleAPIURL = \"https://generativelanguage.googleapis.com\"\n\n\t// SummarizeModel is the model used for file summarization\n\tSummarizeModel = \"gemini-2.5-flash-lite\"\n\n\t// Mode constants\n\tModeQuickSummary = \"quick\"\n\tModeUseful       = \"useful\"\n\tModePublicCode   = \"publiccode\"\n\tModeHTMLContent  = \"htmlcontent\"\n\tModeHTMLFull     = \"htmlfull\"\n\n\t// SummarizePrompt is the default prompt used for file summarization\n\tSummarizePrompt = \"Please provide a concise summary of this file. Include the main topics, key points, and any notable information.\"\n\n\t// QuickSummaryPrompt is the prompt for quick file summaries\n\tQuickSummaryPrompt = `Summarize the following file for another AI agent that is deciding which files to read.\n\nIf the content is HTML or web page markup, ignore layout elements such as headers, footers, sidebars, navigation menus, cookie banners, pop-ups, ads, and search boxes. \nFocus only on the visible main content that describes the page’s subject or purpose.\n\nKeep the summary extremely concise — one or two sentences at most.\nExplain what the file appears to be and its main purpose or contents.\nIf it's code, mention the language and what it implements (e.g., a CLI, library, test, or config).\nAvoid speculation or verbose explanations.\nDo not include markdown, bullets, or formatting — just a plain text summary.`\n\n\t// UsefulSummaryPrompt is the prompt for useful file summaries with more detail\n\tUsefulSummaryPrompt = `You are summarizing a single file so that another AI agent can understand its purpose and structure.\n\nIf the content is HTML or web page markup, ignore layout elements such as headers, footers, sidebars, navigation menus, cookie banners, pop-ups, ads, and search boxes. \nFocus only on the visible main content that describes the page’s subject or purpose.\n\nStart with a short overview (2–4 sentences) describing the overall purpose of the file.\nIf the file is large (more than about 150 lines) or has multiple major sections or functions,\nthen briefly summarize each major section (1–2 sentences per section) and include an approximate line range in parentheses like \"(lines 80–220)\".\n\nKeep section summaries extremely concise — only include the most important parts or entry points.\nIf it's code, mention key functions or classes and what they do.\nIf it's documentation, describe key topics or sections.\nIf it's a data or config file, summarize the structure and purpose of the values.\n\nNever produce more text than would fit comfortably on one screen (roughly under 200 words total).\nPlain text only — no lists, no markdown, no JSON.`\n\n\t// PublicCodeSummaryPrompt is the prompt for public API summaries\n\tPublicCodeSummaryPrompt = `You are summarizing a SINGLE source file to expose its PUBLIC API to another AI client.\n\nGOAL\nProduce a compact, header-like listing of all PUBLIC symbols callers would use.\n\nOUTPUT FORMAT (plain text only; no bullets/markdown/JSON):\n1) Public data structures required by public functions (types/structs/interfaces/enums/const groups):\n\t  \u003cnative one-line comment\u003e (lines A–B)\n\t  \u003cexact single-line declaration\u003e\n\n2) Public functions/methods in order of appearance:\n\t  \u003cnative one-line comment\u003e (lines A–B)\n\t  \u003cexact single-line signature\u003e\n\nRULES\n- PUBLIC means exported/externally visible for the language (Go: capitalized; Java/C#/TS: public; Rust: pub; Python: not underscore-prefixed, etc.).\n- Include ALL public functions/methods.\n- Include public data structures ONLY if referenced by any public function OR commonly constructed/consumed by callers.\n- For multi-line declarations, emit a single-line canonical form by collapsing internal whitespace while preserving tokens and order.\n- The one-line comment is either a compressed docstring or, if absent, a concise inferred purpose (≤ 20 words).\n- Include approximate line ranges as \"(lines A–B)\".\n- Skip private helpers, tests, examples, and internal-only constants.\n- Preserve generics/annotations/modifiers as they appear (e.g., type params, async, const, noexcept).\n- No preface or epilogue text—just the listing.\n\nEXAMPLE STYLE (illustrative; use the target language's comment syntax):\n// Configuration for the proxy (lines 10–42)\ntype ProxyConfig struct { ... }\n\n// Creates and configures a new proxy instance (lines 60–92)\nfunc NewProxy(cfg ProxyConfig) (*Proxy, error)\n\n// Handles a single HTTP request (lines 95–168)\nfunc (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)`\n\n\t// HTMLContentPrompt is the prompt for converting HTML to content-focused Markdown\n\tHTMLContentPrompt = `Convert the following stripped HTML into clean Markdown for READING CONTENT ONLY.\n\n- Output Markdown ONLY (no explanations, no JSON, no code fences).\n- Keep document title as a single H1 if present (from \u003ctitle\u003e or first \u003ch1\u003e).\n- Preserve headings (h1–h6), paragraphs, strong/emphasis, inline code.\n- Convert \u003ca\u003e to [text](absolute_url). If href is relative, resolve against BASE_URL: {{BASE_URL}}. Do not output javascript:void links.\n- Preserve lists (ul/ol, nested), blockquotes, and code blocks (\u003cpre\u003e\u003ccode\u003e) as fenced code (include language if obvious).\n- Convert tables to Markdown tables; keep header row; include up to 50 data rows, then append \"… (more rows)\".\n- Keep images ONLY if alt text is descriptive; render as ![alt](absolute_url). Skip tracking pixels and decorative images.\n- Discard navigation, site header/footer, sidebars, cookie banners, search bars, newsletter/signup, social share, repetitive link clouds, and legal boilerplate unless they are the ONLY content.\n- Preserve in-page structure order; do not invent content; do not summarize prose—extract faithfully.\n- Normalize whitespace, collapse repeated blank lines to one.\n`\n\n\t// HTMLFullPrompt is the prompt for converting HTML to navigation-focused Markdown\n\tHTMLFullPrompt = `Convert the following stripped HTML into Markdown optimized for SITE NAVIGATION.\n\n- Output Markdown ONLY (no explanations, no JSON, no code fences).\n- Start with a top-level title (from \u003ctitle\u003e or first \u003ch1\u003e) as H1.\n- Include primary navigation as a section \"## Navigation\" with bullet lists of top-level links (use visible link text; dedupe exact duplicates).\n- Include secondary nav/footer links under \"## Footer Links\".\n- Then extract the main page content as Markdown (headings, paragraphs, lists, blockquotes, code blocks).\n- Convert \u003ca\u003e to [text](absolute_url). If href is relative, resolve against BASE_URL: {{BASE_URL}}.\n- Convert tables to Markdown tables; keep header + up to 50 rows, then \"… (more rows)\".\n- Keep images with meaningful alt as ![alt](absolute_url); otherwise skip.\n- Preserve order as it appears in the page; do not summarize prose—extract faithfully.\n- Normalize whitespace; collapse repeated blank lines.`\n)\n```\n\n## Types\n\n```go\ntype GoogleUsage struct {\n\tPromptTokenCount        int32 `json:\"prompt_token_count\"`\n\tCachedContentTokenCount int32 `json:\"cached_content_token_count\"`\n\tCandidatesTokenCount    int32 `json:\"candidates_token_count\"`\n\tTotalTokenCount         int32 `json:\"total_token_count\"`\n}\n```\nGoogleUsage represents token usage information from Google's Generative AI API\n\n```go\nfunc SummarizeFile(ctx context.Context, filename string, opts SummarizeOpts) (string, *GoogleUsage, error)\n```\nSummarizeFile reads a file and generates a summary using Google's Generative AI. It supports images, PDFs, and text files based on the limits defined in wshcmd-ai.go. Returns the summary text, usage information, and any error encountered.\n\n```go\ntype SummarizeOpts struct {\n\tAPIKey string\n\tMode   string\n}\n```\nSummarizeOpts contains options for file summarization\n\n","path":"github.com/wavetermdev/waveterm/pkg/aiusechat/google","name":"google","synopsis":"Package google provides Google Generative AI integration for WaveTerm.","isRedistributable":true}
