Spaces:
Configuration error
Configuration error
Download clients/python/exa.py from AnthropicallyHuggingFaces/ai-platform-toolbox: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/clients/python/exa.py
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/clients/python/exa.py
-
curl -L -o exa.py https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/clients/python/exa.py
710 Bytes
| """Exa client - semantic + keyword web search.""" | |
| import os | |
| import requests | |
| BASE = os.getenv("EXA_API_BASE", "https://api.exa.ai") | |
| KEY = os.getenv("EXA_API_KEY") | |
| def _h(): | |
| if not KEY: | |
| raise RuntimeError("EXA_API_KEY not set") | |
| return {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"} | |
| def search(query, num_results=10, type="auto", **kwargs): | |
| body = {"query": query, "numResults": num_results, "type": type, **kwargs} | |
| return requests.post(f"{BASE}/search", headers=_h(), json=body, timeout=60).json() | |
| def get_contents(urls, **kwargs): | |
| body = {"urls": urls, **kwargs} | |
| return requests.post(f"{BASE}/contents", headers=_h(), json=body, timeout=60).json() | |