YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(ai-proxy): detect user intent for web vs local search
Louis Beaumontb0e3461e86a2
diff --git a/screenpipe-js/ai-proxy/src/providers/gemini.ts b/screenpipe-js/ai-proxy/src/providers/gemini.tsindex e4f81d68d..c5b856e46 100644--- a/screenpipe-js/ai-proxy/src/providers/gemini.ts+++ b/screenpipe-js/ai-proxy/src/providers/gemini.ts@@ -345,14 +345,30 @@ export class GeminiProvider implements AIProvider {}// Build tools - Vertex AI Gemini doesn't support mixing function tools with Google Search- // If web_search is requested, use ONLY Google Search grounding (most useful for external queries)- // Otherwise, use function declarations- if (hasWebSearch) {- // Use Google Search grounding only+ // Strategy: Detect user intent from the last message to decide which mode to use+ const lastUserMessage = body.messages.filter(m => m.role === 'user').pop();+ const userQuery = typeof lastUserMessage?.content === 'string' ? lastUserMessage.content.toLowerCase() : '';++ // Check if user explicitly wants web/internet search+ const wantsWebSearch = hasWebSearch && (+ userQuery.includes('internet') ||+ userQuery.includes('web search') ||+ userQuery.includes('search the web') ||+ userQuery.includes('search online') ||+ userQuery.includes('latest news') ||+ userQuery.includes('current news') ||+ userQuery.includes('recent news') ||+ userQuery.includes('what is happening') ||+ userQuery.includes('today\'s') ||+ userQuery.includes('this week')+ );++ if (wantsWebSearch) {+ // User explicitly wants web search - use Google Search groundingrequestBody.tools = [{ googleSearch: {} }];- console.log('[Gemini Vertex] Using Google Search grounding (function tools disabled)');+ console.log('[Gemini Vertex] User requested web search, using Google Search grounding');} else if (body.tools && body.tools.length > 0) {- // Convert and use function declarations only+ // Use function declarations for local searchconst functionDeclarations = this.convertToolsToGeminiFormat(body.tools);if (functionDeclarations.length > 0) {requestBody.tools = [{ functionDeclarations }];