rss2podcast/ollama_client.py

14 lines
431 B
Python
Raw Normal View History

2024-11-05 14:45:19 +01:00
import ollama
class OllamaClient:
def __init__(self, model, url='http://localhost:11434'):
self.model = model
self.client = ollama.Client(host=url)
def generate(self, prompt):
try:
response = self.client.generate(model=self.model, prompt=prompt)
return response['response']
except Exception as e:
raise Exception(f"Ollama API request failed: {str(e)}")