Spaces:
Sleeping
Sleeping
naourpally
commited on
Commit
·
a2ff132
1
Parent(s):
c78d430
Remove streaming equals true argument
Browse files
app.py
CHANGED
@@ -11,8 +11,8 @@ def get_text_response(prompt):
|
|
11 |
with requests.post(api_url, json=data_payload, stream=True) as response:
|
12 |
for line in response.iter_lines():
|
13 |
if line:
|
14 |
-
decoded_line = line.decode('utf-8')
|
15 |
-
json_line = decoded_line.strip(',')
|
16 |
try:
|
17 |
response_json = json.loads(json_line)
|
18 |
text_response = response_json.get("response", "")
|
@@ -21,7 +21,7 @@ def get_text_response(prompt):
|
|
21 |
if done:
|
22 |
break
|
23 |
except json.JSONDecodeError as e:
|
24 |
-
continue
|
25 |
|
26 |
def clear_chat():
|
27 |
return "", ""
|
@@ -81,7 +81,7 @@ with gr.Blocks(css=css) as demo:
|
|
81 |
clear_button = gr.Button("Clear")
|
82 |
output = gr.Textbox(label="Response", lines=10, placeholder="Response will appear here...")
|
83 |
|
84 |
-
submit_button.click(fn=get_text_response, inputs=prompt, outputs=output
|
85 |
clear_button.click(fn=clear_chat, inputs=[], outputs=[prompt, output])
|
86 |
|
87 |
gr.HTML(
|
|
|
11 |
with requests.post(api_url, json=data_payload, stream=True) as response:
|
12 |
for line in response.iter_lines():
|
13 |
if line:
|
14 |
+
decoded_line = line.decode('utf-8')
|
15 |
+
json_line = decoded_line.strip(',')
|
16 |
try:
|
17 |
response_json = json.loads(json_line)
|
18 |
text_response = response_json.get("response", "")
|
|
|
21 |
if done:
|
22 |
break
|
23 |
except json.JSONDecodeError as e:
|
24 |
+
continue
|
25 |
|
26 |
def clear_chat():
|
27 |
return "", ""
|
|
|
81 |
clear_button = gr.Button("Clear")
|
82 |
output = gr.Textbox(label="Response", lines=10, placeholder="Response will appear here...")
|
83 |
|
84 |
+
submit_button.click(fn=get_text_response, inputs=prompt, outputs=output)
|
85 |
clear_button.click(fn=clear_chat, inputs=[], outputs=[prompt, output])
|
86 |
|
87 |
gr.HTML(
|