AI_Chat_With_Tools / back /ollama_client.py
muhammad1707's picture
Move master code to main
8421ec4
Raw
History Blame Contribute Delete
460 Bytes
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"]