Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,8 +19,18 @@ headers = {
|
|
19 |
def query_mistral(question):
|
20 |
payload = {"inputs": question, "parameters": {"max_length": 256}}
|
21 |
response = requests.post(API_URL, headers=headers, json=payload)
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
POLYGON_API_KEY = os.getenv("POLYGON_API_KEY")
|
26 |
|
|
|
19 |
def query_mistral(question):
|
20 |
payload = {"inputs": question, "parameters": {"max_length": 256}}
|
21 |
response = requests.post(API_URL, headers=headers, json=payload)
|
22 |
+
|
23 |
+
try:
|
24 |
+
output = response.json()
|
25 |
+
# Check for standard output format
|
26 |
+
if isinstance(output, list) and "generated_text" in output[0]:
|
27 |
+
return output[0]["generated_text"]
|
28 |
+
else:
|
29 |
+
# Return error message or full object for debugging
|
30 |
+
return f"[Error from Mistral API]: {output}"
|
31 |
+
except Exception as e:
|
32 |
+
return f"[Exception in query_mistral]: {str(e)}"
|
33 |
+
|
34 |
|
35 |
POLYGON_API_KEY = os.getenv("POLYGON_API_KEY")
|
36 |
|