Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,6 +47,7 @@ def process_response(response, history):
|
|
47 |
if chunk:
|
48 |
try:
|
49 |
chunk_json = json.loads(chunk.decode('utf-8'))
|
|
|
50 |
if 'choices' in chunk_json and len(chunk_json['choices']) > 0:
|
51 |
chunk_data = chunk_json['choices'][0].get('delta', {})
|
52 |
if 'content' in chunk_data:
|
@@ -56,12 +57,14 @@ def process_response(response, history):
|
|
56 |
else:
|
57 |
history[-1] = partial_words
|
58 |
token_counter += 1
|
59 |
-
except json.JSONDecodeError:
|
60 |
-
print("Error decoding JSON response")
|
61 |
-
|
|
|
62 |
chat = [(history[i], history[i + 1]) for i in range(0, len(history) - 1, 2)]
|
63 |
return chat, history, token_counter
|
64 |
|
|
|
65 |
def setup_ui():
|
66 |
with gr.Blocks() as demo:
|
67 |
with gr.Column():
|
|
|
47 |
if chunk:
|
48 |
try:
|
49 |
chunk_json = json.loads(chunk.decode('utf-8'))
|
50 |
+
print("Chunk JSON:", chunk_json) # Log para diagn贸stico
|
51 |
if 'choices' in chunk_json and len(chunk_json['choices']) > 0:
|
52 |
chunk_data = chunk_json['choices'][0].get('delta', {})
|
53 |
if 'content' in chunk_data:
|
|
|
57 |
else:
|
58 |
history[-1] = partial_words
|
59 |
token_counter += 1
|
60 |
+
except json.JSONDecodeError as e:
|
61 |
+
print("Error decoding JSON response:", e)
|
62 |
+
print("Raw chunk:", chunk) # Log do chunk bruto para diagn贸stico
|
63 |
+
break # ou trate o erro como achar melhor
|
64 |
chat = [(history[i], history[i + 1]) for i in range(0, len(history) - 1, 2)]
|
65 |
return chat, history, token_counter
|
66 |
|
67 |
+
|
68 |
def setup_ui():
|
69 |
with gr.Blocks() as demo:
|
70 |
with gr.Column():
|