Spaces:
Sleeping
Sleeping
| import requests | |
| OLLAMA_URL = "http://localhost:11434/api/generate" | |
| def ask_ollama(prompt: str, model="llama3.2:1b") -> str: | |
| response = requests.post( | |
| OLLAMA_URL, | |
| json={ | |
| "model": model, | |
| "prompt": prompt, | |
| "stream": False, | |
| "options": { | |
| "temperature": 0.2 | |
| } | |
| }, | |
| timeout=120 | |
| ) | |
| response.raise_for_status() | |
| return response.json()["response"] | |