Made changes to suit Openwebui
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user