Made changes to suit Openwebui

This commit is contained in:
Iyeoluwa Akinrinola
2025-05-09 16:47:30 +01:00
parent ac98999507
commit 9535052645
14 changed files with 93 additions and 330 deletions
+2 -2
View File
@@ -18,10 +18,10 @@ class ChatService:
def __init__(self):
"""Initialize the chat service."""
# Ensure data directory exists
os.makedirs(os.path.dirname(config.SQLITE_DB_PATH), exist_ok=True)
os.makedirs('ai_service/data', exist_ok=True)
# For now, we'll store chat data in a simple JSON file
self.chats_file = os.path.join(os.path.dirname(config.SQLITE_DB_PATH), 'chats.json')
self.chats_file = 'ai_service/data/chats.json'
self._load_chats()
def _load_chats(self):
+7 -2
View File
@@ -212,12 +212,17 @@ class ModelService:
# Make the API call to Ollama
try:
# Prepare headers with API key
headers = {"Content-Type": "application/json"}
if self.openwebui_api_key:
headers["Authorization"] = f"Bearer {self.openwebui_api_key}"
# Ollama API endpoint is /api/chat or /api/generate
response = requests.post(
f"{self.ollama_api_url}/api/generate",
headers={"Content-Type": "application/json"},
headers=headers,
json=request_json,
timeout=30
timeout=60
)
response.raise_for_status()