""" NeuraPrompt Agent — Vision Tools (v7.5) """ import requests import logging import os log = logging.getLogger("agent.tools.vision") OPENROUTER_KEY = os.getenv("OPENROUTE_KEY", "") VISION_MODEL = "nvidia/llama-nemotron-rerank-vl-1b-v2:free" def analyze_image(image_b64: str, prompt: str = "Describe this image in detail.") -> str: """Analyze an image using vision model""" if not OPENROUTER_KEY: return "Error: Vision service not configured" enhanced_prompt = f"""You are an expert visual analyst. {prompt} Provide a detailed, structured response including: 1. Overall description 2. Key objects, text, or people visible 3. Any notable details or context 4. Your confidence level""" try: response = requests.post( "https://openrouter.ai/api/v1/chat/completions", headers={ "Authorization": f"Bearer {OPENROUTER_KEY}", "Content-Type": "application/json" }, json={ "model": VISION_MODEL, "messages": [{ "role": "user", "content": [ { "type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_b64}"} }, { "type": "text", "text": enhanced_prompt } ] }] }, timeout=40 ) response.raise_for_status() return response.json()["choices"][0]["message"]["content"].strip() except Exception as e: log.error(f"Vision analysis failed: {e}") return f"Vision error: {str(e)}"