Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -92,7 +92,11 @@ def get_bot_response(adapter_id, prompt, state, bot_index):
|
|
92 |
"Authorization": f"Bearer {os.environ.get('PREDIBASE_TOKEN')}"
|
93 |
}
|
94 |
response = requests.post("https://serving.app.predibase.com/79957f/deployments/v2/llms/mistral-7b/generate", json=payload, headers=headers)
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
def chat_with_bots(user_input, state):
|
97 |
# Use existing bot order from state if available, otherwise shuffle and initialize
|
98 |
if 'last_bots' not in state or not state['last_bots']:
|
|
|
92 |
"Authorization": f"Bearer {os.environ.get('PREDIBASE_TOKEN')}"
|
93 |
}
|
94 |
response = requests.post("https://serving.app.predibase.com/79957f/deployments/v2/llms/mistral-7b/generate", json=payload, headers=headers)
|
95 |
+
try:
|
96 |
+
response_text = response.json()['generated_text']
|
97 |
+
except (KeyError, requests.exceptions.JSONDecodeError):
|
98 |
+
response_text = "Sorry, I couldn't generate a response."
|
99 |
+
return response_text.split('### Instruction')[0]
|
100 |
def chat_with_bots(user_input, state):
|
101 |
# Use existing bot order from state if available, otherwise shuffle and initialize
|
102 |
if 'last_bots' not in state or not state['last_bots']:
|