Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,8 @@ collection = chroma_client.get_or_create_collection("knowledge")
|
|
| 20 |
MODELS = [
|
| 21 |
"llama-3.3-70b-versatile",
|
| 22 |
"llama-3.1-8b-instant",
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
]
|
| 26 |
|
| 27 |
def call_groq(messages):
|
|
@@ -36,7 +36,10 @@ def call_groq(messages):
|
|
| 36 |
except Exception as e:
|
| 37 |
error = str(e)
|
| 38 |
if "rate_limit_exceeded" in error or "429" in error:
|
| 39 |
-
print(f"⚠️
|
|
|
|
|
|
|
|
|
|
| 40 |
continue
|
| 41 |
else:
|
| 42 |
raise e
|
|
@@ -119,7 +122,7 @@ SYSTEM_PROMPT = """أنت مساعد متخصص في الأمن السيبران
|
|
| 119 |
- عند شرح الثغرات، ركز على الحماية وليس الاستغلال"""
|
| 120 |
|
| 121 |
# ======================
|
| 122 |
-
# دالة المحادثة
|
| 123 |
# ======================
|
| 124 |
def chat(message, history):
|
| 125 |
if not message.strip():
|
|
@@ -138,7 +141,7 @@ def chat(message, history):
|
|
| 138 |
|
| 139 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 140 |
|
| 141 |
-
#
|
| 142 |
history_to_send = history[-10:]
|
| 143 |
|
| 144 |
for item in history_to_send:
|
|
|
|
| 20 |
MODELS = [
|
| 21 |
"llama-3.3-70b-versatile",
|
| 22 |
"llama-3.1-8b-instant",
|
| 23 |
+
"llama3-70b-8192",
|
| 24 |
+
"llama3-8b-8192",
|
| 25 |
]
|
| 26 |
|
| 27 |
def call_groq(messages):
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
error = str(e)
|
| 38 |
if "rate_limit_exceeded" in error or "429" in error:
|
| 39 |
+
print(f"⚠️ {model} وصل للحد، جارٍ التبديل...")
|
| 40 |
+
continue
|
| 41 |
+
elif "decommissioned" in error or "model_not_found" in error:
|
| 42 |
+
print(f"⚠️ {model} متوقف، جارٍ التبديل...")
|
| 43 |
continue
|
| 44 |
else:
|
| 45 |
raise e
|
|
|
|
| 122 |
- عند شرح الثغرات، ركز على الحماية وليس الاستغلال"""
|
| 123 |
|
| 124 |
# ======================
|
| 125 |
+
# دالة المحادثة
|
| 126 |
# ======================
|
| 127 |
def chat(message, history):
|
| 128 |
if not message.strip():
|
|
|
|
| 141 |
|
| 142 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 143 |
|
| 144 |
+
# آخر 10 عناصر فقط = 5 أسئلة + 5 أجوبة
|
| 145 |
history_to_send = history[-10:]
|
| 146 |
|
| 147 |
for item in history_to_send:
|