Spaces:
Running on Zero
Running on Zero
Update report_generator.py
Browse files- report_generator.py +15 -15
report_generator.py
CHANGED
|
@@ -49,21 +49,16 @@ def generate_ai_report(diagnostic_data: dict) -> str:
|
|
| 49 |
if not failed_sessions_only:
|
| 50 |
return "# Executive Health & Deployment Readiness\n\nAll multi-turn trajectories operated at optimal parameters. The agent achieved a **100.0% Success Rate (Health Rating: [A])**. Recommended for production deployment."
|
| 51 |
|
| 52 |
-
# Citim cheia direct la apel
|
| 53 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
| 54 |
|
| 55 |
-
if not HAS_GROQ:
|
| 56 |
-
print("[Groq Debug]:
|
| 57 |
-
return generate_fallback_markdown(diagnostic_data)
|
| 58 |
-
|
| 59 |
-
if not groq_api_key:
|
| 60 |
-
print("[Groq Debug]: GROQ_API_KEY nu a fost gasita in os.getenv(). Asigura-te ca e setata in Space Secrets!")
|
| 61 |
return generate_fallback_markdown(diagnostic_data)
|
| 62 |
|
| 63 |
try:
|
| 64 |
groq_client = Groq(api_key=groq_api_key)
|
| 65 |
except Exception as e:
|
| 66 |
-
print(f"[Groq Debug]: Eroare la
|
| 67 |
return generate_fallback_markdown(diagnostic_data)
|
| 68 |
|
| 69 |
filtered_report = {
|
|
@@ -92,14 +87,19 @@ def generate_ai_report(diagnostic_data: dict) -> str:
|
|
| 92 |
f"Failure Diagnostic JSON:\n{json.dumps(filtered_report)}"
|
| 93 |
)
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
|
|
|
| 101 |
try:
|
| 102 |
-
print(f"[Groq Debug]: Incercam apelul catre modelul {model_name}...")
|
| 103 |
completion = groq_client.chat.completions.create(
|
| 104 |
model=model_name,
|
| 105 |
messages=[
|
|
@@ -109,7 +109,7 @@ def generate_ai_report(diagnostic_data: dict) -> str:
|
|
| 109 |
temperature=0.1,
|
| 110 |
max_tokens=400
|
| 111 |
)
|
| 112 |
-
print(f"[Groq Debug]: SUCCESS cu modelul {model_name}!")
|
| 113 |
return completion.choices[0].message.content
|
| 114 |
except Exception as e:
|
| 115 |
print(f"[Groq Debug]: Eroare la modelul {model_name}: {e}")
|
|
|
|
| 49 |
if not failed_sessions_only:
|
| 50 |
return "# Executive Health & Deployment Readiness\n\nAll multi-turn trajectories operated at optimal parameters. The agent achieved a **100.0% Success Rate (Health Rating: [A])**. Recommended for production deployment."
|
| 51 |
|
|
|
|
| 52 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
| 53 |
|
| 54 |
+
if not HAS_GROQ or not groq_api_key:
|
| 55 |
+
print("[Groq Debug]: Groq sau GROQ_API_KEY indisponibil.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
return generate_fallback_markdown(diagnostic_data)
|
| 57 |
|
| 58 |
try:
|
| 59 |
groq_client = Groq(api_key=groq_api_key)
|
| 60 |
except Exception as e:
|
| 61 |
+
print(f"[Groq Debug]: Eroare la client Groq: {e}")
|
| 62 |
return generate_fallback_markdown(diagnostic_data)
|
| 63 |
|
| 64 |
filtered_report = {
|
|
|
|
| 87 |
f"Failure Diagnostic JSON:\n{json.dumps(filtered_report)}"
|
| 88 |
)
|
| 89 |
|
| 90 |
+
# 1. Intrebam Groq ce modele sunt disponibile in contul tau
|
| 91 |
+
try:
|
| 92 |
+
models_list = groq_client.models.list()
|
| 93 |
+
available_models = [m.id for m in models_list.data if "whisper" not in m.id.lower() and "embed" not in m.id.lower()]
|
| 94 |
+
print(f"[Groq Debug]: Modele active detectate in contul tau: {available_models}")
|
| 95 |
+
except Exception as e:
|
| 96 |
+
print(f"[Groq Debug]: Nu am putut lista modelele: {e}")
|
| 97 |
+
available_models = ["llama-3.3-70b-versatile", "llama-3.1-8b-instant", "gemma2-9b-it"]
|
| 98 |
|
| 99 |
+
# 2. Rulam primul model disponibil
|
| 100 |
+
for model_name in available_models:
|
| 101 |
try:
|
| 102 |
+
print(f"[Groq Debug]: Incercam apelul catre modelul detectat: [{model_name}]...")
|
| 103 |
completion = groq_client.chat.completions.create(
|
| 104 |
model=model_name,
|
| 105 |
messages=[
|
|
|
|
| 109 |
temperature=0.1,
|
| 110 |
max_tokens=400
|
| 111 |
)
|
| 112 |
+
print(f"[Groq Debug]: 🎉 SUCCESS cu modelul [{model_name}]!")
|
| 113 |
return completion.choices[0].message.content
|
| 114 |
except Exception as e:
|
| 115 |
print(f"[Groq Debug]: Eroare la modelul {model_name}: {e}")
|