main.py aktualisiert
This commit is contained in:
16
main.py
16
main.py
@@ -75,11 +75,19 @@ async def get_ai_response(user_input, system_prompt):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if AI_PROVIDER == "openai" or AI_PROVIDER == "ollama":
|
if AI_PROVIDER == "openai" or AI_PROVIDER == "ollama":
|
||||||
# Für OpenAI / Ollama
|
|
||||||
messages = [{"role": "system", "content": system_prompt}] + chat_history
|
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
|
# Sicherstellen, dass die URL für Ollama korrekt endet
|
||||||
model_to_use = OLLAMA_MODEL if AI_PROVIDER == "ollama" else OPENAI_MODEL
|
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)
|
client = openai.OpenAI(base_url=url, api_key=key)
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
|
|||||||
Reference in New Issue
Block a user