main.py aktualisiert

This commit is contained in:
2026-03-05 20:31:26 +00:00
parent 8e443da4f1
commit 3440b8fc5d

16
main.py
View File

@@ -75,12 +75,20 @@ async def get_ai_response(user_input, system_prompt):
try:
if AI_PROVIDER == "openai" or AI_PROVIDER == "ollama":
# Für OpenAI / Ollama
messages = [{"role": "system", "content": system_prompt}] + chat_history
url = OLLAMA_BASE_URL if AI_PROVIDER == "ollama" else None
key = "ollama" if AI_PROVIDER == "ollama" else OPENAI_API_KEY
model_to_use = OLLAMA_MODEL if AI_PROVIDER == "ollama" else OPENAI_MODEL
# Sicherstellen, dass die URL für Ollama korrekt endet
if AI_PROVIDER == "ollama":
url = OLLAMA_BASE_URL
if not url.endswith('/v1') and not url.endswith('/v1/'):
url = url.rstrip('/') + '/v1'
key = "ollama"
model_to_use = OLLAMA_MODEL
else:
url = None # Benutzt Standard OpenAI URL
key = OPENAI_API_KEY
model_to_use = OPENAI_MODEL
client = openai.OpenAI(base_url=url, api_key=key)
response = client.chat.completions.create(
model=model_to_use,