Update app.py
Browse files
app.py
CHANGED
@@ -67,10 +67,15 @@ class AutonomousEmailAgent:
|
|
67 |
|
68 |
print(f"Status Code: {response.status_code}")
|
69 |
if response.status_code == 200:
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
else:
|
75 |
print(f"Error: Unable to connect to Groq Cloud LLM. Status Code: {response.status_code}, Response: {response.text}")
|
76 |
return "Error: Unable to generate response."
|
|
|
67 |
|
68 |
print(f"Status Code: {response.status_code}")
|
69 |
if response.status_code == 200:
|
70 |
+
try:
|
71 |
+
result = response.json() # Parse the response as JSON
|
72 |
+
# Check if 'choices' and the content are correctly structured in the response
|
73 |
+
content = "".join([chunk.get("choices", [{}])[0].get("message", {}).get("content", "") for chunk in result.get("choices", [])])
|
74 |
+
print(content)
|
75 |
+
return self.act_on_llm_instructions(content)
|
76 |
+
except json.JSONDecodeError:
|
77 |
+
print("Error: Response from Groq Cloud LLM is not valid JSON.")
|
78 |
+
return "Error: Response is not in JSON format."
|
79 |
else:
|
80 |
print(f"Error: Unable to connect to Groq Cloud LLM. Status Code: {response.status_code}, Response: {response.text}")
|
81 |
return "Error: Unable to generate response."
|