Spaces:
Build error
Build error
Julian Vanecek commited on
Commit ·
05ab747
1
Parent(s): 287e8c6
reverting frontend
Browse files
app.py
CHANGED
|
@@ -38,21 +38,20 @@ def process_faq(question, user_id="anonymous", model="claude-sonnet"):
|
|
| 38 |
if response.status_code != 200:
|
| 39 |
return f"Error: Lambda function returned status code {response.status_code}"
|
| 40 |
|
| 41 |
-
# Process the
|
| 42 |
full_response = ""
|
| 43 |
for chunk in response.iter_content(chunk_size=1024, decode_unicode=True):
|
| 44 |
if chunk:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
yield full_response
|
| 56 |
|
| 57 |
return full_response
|
| 58 |
|
|
|
|
| 38 |
if response.status_code != 200:
|
| 39 |
return f"Error: Lambda function returned status code {response.status_code}"
|
| 40 |
|
| 41 |
+
# Process the response (Lambda returns complete response as plain text)
|
| 42 |
full_response = ""
|
| 43 |
for chunk in response.iter_content(chunk_size=1024, decode_unicode=True):
|
| 44 |
if chunk:
|
| 45 |
+
full_response += chunk
|
| 46 |
+
|
| 47 |
+
# Simulate streaming by yielding progressively
|
| 48 |
+
if full_response:
|
| 49 |
+
words = full_response.split()
|
| 50 |
+
current_text = ""
|
| 51 |
+
for i, word in enumerate(words):
|
| 52 |
+
current_text += word + " "
|
| 53 |
+
if i % 2 == 0 or i == len(words) - 1: # Yield every 2 words or at the end
|
| 54 |
+
yield current_text.strip()
|
|
|
|
| 55 |
|
| 56 |
return full_response
|
| 57 |
|