Update app.py
Browse files
app.py
CHANGED
|
@@ -11,8 +11,19 @@ def query_mistral(prompt):
|
|
| 11 |
"inputs": prompt,
|
| 12 |
"parameters": {"max_new_tokens": 300}
|
| 13 |
}
|
|
|
|
| 14 |
r = requests.post(API_URL, headers=HEADERS, json=payload)
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def chat_fn(message, history):
|
| 18 |
if history is None:
|
|
|
|
| 11 |
"inputs": prompt,
|
| 12 |
"parameters": {"max_new_tokens": 300}
|
| 13 |
}
|
| 14 |
+
|
| 15 |
r = requests.post(API_URL, headers=HEADERS, json=payload)
|
| 16 |
+
data = r.json()
|
| 17 |
+
|
| 18 |
+
# Eğer model yükleniyorsa
|
| 19 |
+
if isinstance(data, dict) and "error" in data:
|
| 20 |
+
return f"Model yükleniyor veya hata oluştu:\n{data['error']}"
|
| 21 |
+
|
| 22 |
+
# Normal cevap
|
| 23 |
+
if isinstance(data, list):
|
| 24 |
+
return data[0].get("generated_text", "Cevap alınamadı.")
|
| 25 |
+
|
| 26 |
+
return "Beklenmeyen API cevabı."
|
| 27 |
|
| 28 |
def chat_fn(message, history):
|
| 29 |
if history is None:
|