Spaces:
Runtime error
Runtime error
yizhangliu
commited on
Commit
•
e20880a
1
Parent(s):
eec819d
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from pyChatGPT import ChatGPT
|
2 |
import gradio as gr
|
3 |
-
import os
|
4 |
from loguru import logger
|
5 |
import random
|
6 |
|
@@ -25,7 +25,7 @@ def get_response_from_chatbot(text):
|
|
25 |
# history.append((message, response))
|
26 |
# return history, history
|
27 |
|
28 |
-
def
|
29 |
split_mark_1 = ',,,,,,,,,,;'
|
30 |
split_mark_2 = ';;;;;;;;;;;'
|
31 |
out_chat = []
|
@@ -42,6 +42,20 @@ def chat(message, chat_history):
|
|
42 |
chat_history += f'{message}{split_mark_2}{response}'
|
43 |
print(f'liuyz_2_{chat_history}')
|
44 |
return out_chat, chat_history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
start_work = """async() => {
|
47 |
function isMobile() {
|
@@ -146,10 +160,9 @@ with gr.Blocks(title='Text to Image') as demo:
|
|
146 |
# with gr.Group(elem_id="page_2", visible=False) as page_2:
|
147 |
with gr.Row(elem_id="prompt_row"):
|
148 |
chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|
149 |
-
chatbot.change(None, show_progress=False)
|
150 |
with gr.Row():
|
151 |
prompt_input0 = gr.Textbox(lines=1, label="prompt",show_label=False)
|
152 |
-
chat_history = gr.Textbox(lines=4, label="prompt", visible=
|
153 |
submit_btn = gr.Button(value = "submit",elem_id="submit-btn").style(
|
154 |
margin=True,
|
155 |
rounded=(True, True, True, True),
|
|
|
1 |
from pyChatGPT import ChatGPT
|
2 |
import gradio as gr
|
3 |
+
import os, json
|
4 |
from loguru import logger
|
5 |
import random
|
6 |
|
|
|
25 |
# history.append((message, response))
|
26 |
# return history, history
|
27 |
|
28 |
+
def chat1(message, chat_history):
|
29 |
split_mark_1 = ',,,,,,,,,,;'
|
30 |
split_mark_2 = ';;;;;;;;;;;'
|
31 |
out_chat = []
|
|
|
42 |
chat_history += f'{message}{split_mark_2}{response}'
|
43 |
print(f'liuyz_2_{chat_history}')
|
44 |
return out_chat, chat_history
|
45 |
+
|
46 |
+
def chat(message, chat_history):
|
47 |
+
out_chat = []
|
48 |
+
if chat_history != '':
|
49 |
+
out_chat = json.load(chat_history)
|
50 |
+
print(f'liuyz_1_{chat_history}')
|
51 |
+
response = get_response_from_chatbot(message)
|
52 |
+
out_chat.append((message, response))
|
53 |
+
# if chat_history != '':
|
54 |
+
# chat_history += split_mark_1
|
55 |
+
# chat_history += f'{message}{split_mark_2}{response}'
|
56 |
+
chat_history = json.dump(out_chat)
|
57 |
+
print(f'liuyz_2_{chat_history}')
|
58 |
+
return out_chat, chat_history
|
59 |
|
60 |
start_work = """async() => {
|
61 |
function isMobile() {
|
|
|
160 |
# with gr.Group(elem_id="page_2", visible=False) as page_2:
|
161 |
with gr.Row(elem_id="prompt_row"):
|
162 |
chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|
|
|
163 |
with gr.Row():
|
164 |
prompt_input0 = gr.Textbox(lines=1, label="prompt",show_label=False)
|
165 |
+
chat_history = gr.Textbox(lines=4, label="prompt", visible=True)
|
166 |
submit_btn = gr.Button(value = "submit",elem_id="submit-btn").style(
|
167 |
margin=True,
|
168 |
rounded=(True, True, True, True),
|