import requests from typing import Dict, Any API_URL = "https://chittrarasu-image-search-engine-fastapi.hf.space/search" def search_by_text(query: str) -> Dict[str, Any]: try: response = requests.get(f"{API_URL}/text", params={"query": query}) response.raise_for_status() return response.json() except requests.RequestException as e: return {"error": str(e)} def search_by_image(image_file) -> Dict[str, Any]: try: files = {"file": (image_file.name, image_file.getvalue(), image_file.type)} response = requests.post(f"{API_URL}/image", files=files) response.raise_for_status() return response.json() except requests.RequestException as e: return {"error": str(e)}