import requests from io import BytesIO from langchain_core.tools import tool from huggingface_hub import InferenceClient from hf_token import resolve_hf_token @tool def image_identifier_tool(image_url: str) -> str: """Identify and describe what is in an image given its URL. Use this tool when a question includes an image URL or asks about the contents of an image. Pass the full URL to this tool. """ client = InferenceClient(token=resolve_hf_token()) response = requests.get(image_url, timeout=30) response.raise_for_status() image_bytes = BytesIO(response.content) result = client.image_to_text(image_bytes) if isinstance(result, str): return result return result.generated_text