nicolaakmal
commited on
Commit
•
fb370a1
1
Parent(s):
7ed607e
Update app.py
Browse files
app.py
CHANGED
@@ -160,9 +160,14 @@ def generate_response(inputs):
|
|
160 |
]
|
161 |
# Generate the response using the pipeline
|
162 |
response = pipe(messages)
|
163 |
-
# Extract the generated
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
# Antarmuka Gradio
|
168 |
iface = gr.Interface(
|
|
|
160 |
]
|
161 |
# Generate the response using the pipeline
|
162 |
response = pipe(messages)
|
163 |
+
# Extract the generated assistant's response
|
164 |
+
try:
|
165 |
+
# Navigate the nested structure to find the assistant's response content
|
166 |
+
assistant_response = response[0]["generated_text"][1]["content"]
|
167 |
+
return assistant_response.strip() # Clean up any extra whitespace
|
168 |
+
except (IndexError, KeyError, TypeError) as e:
|
169 |
+
# Handle any errors due to unexpected structure in the response
|
170 |
+
return "Error processing response. Please try again."
|
171 |
|
172 |
# Antarmuka Gradio
|
173 |
iface = gr.Interface(
|