Spaces:
Runtime error
Runtime error
mkw18
commited on
Commit
·
3401873
1
Parent(s):
1a6fe15
reset ans
Browse files
app.py
CHANGED
@@ -69,7 +69,7 @@ def predict(input, chatbot, messages, idx, answer):
|
|
69 |
completion = openai.ChatCompletion.create(
|
70 |
model="gpt-3.5-turbo",
|
71 |
messages=messages,
|
72 |
-
logit_bias={42468:
|
73 |
)
|
74 |
response=completion.choices[0].message.content.strip()
|
75 |
messages.append({"role": "assistant", "content": response})
|
@@ -81,7 +81,7 @@ def predict(input, chatbot, messages, idx, answer):
|
|
81 |
completion1 = openai.ChatCompletion.create(
|
82 |
model="gpt-3.5-turbo",
|
83 |
messages=messages1,
|
84 |
-
logit_bias={42468:
|
85 |
)
|
86 |
response1=completion1.choices[0].message.content.strip()
|
87 |
if '不' in response1 or '否' in response1 or '没' in response1:
|
@@ -108,7 +108,7 @@ def reset_state():
|
|
108 |
messages = data['messages']
|
109 |
answer = data['answer']
|
110 |
idx = data['idx']
|
111 |
-
return chatbot, messages, gr.update(value=""), gr.update(value="Show Answer"), answer, idx, gr.update(value=chatbot[-1][1].replace('汤面:', '').replace('你可以开始猜测汤底的内容,我会回答你的问题。请注意,我只能回答“是”或“否”。', '').replace('<p>', '').replace('</p>', ''))
|
112 |
|
113 |
|
114 |
def show_hide_answer(answer, show_ans):
|
@@ -131,7 +131,7 @@ with gr.Blocks() as demo:
|
|
131 |
idx = gr.State(data['idx'])
|
132 |
show_ans = gr.State(False)
|
133 |
with gr.Row():
|
134 |
-
question = gr.Textbox(label='汤面', value=data['chatbot'][-1][1].replace('汤面:', '').replace('你可以开始猜测汤底的内容,我会回答你的问题。请注意,我只能回答“是”或“否”。', '').replace('<p>', '').replace('</p>', ''),
|
135 |
lines=1, max_lines=3).style(container=False)
|
136 |
|
137 |
with gr.Row():
|
@@ -154,7 +154,7 @@ with gr.Blocks() as demo:
|
|
154 |
show_progress=True)
|
155 |
submitBtn.click(reset_user_input, [], [user_input])
|
156 |
|
157 |
-
emptyBtn.click(reset_state, outputs=[chatbot, messages, answer_output, answerBtn, answer, idx, question], show_progress=True)
|
158 |
|
159 |
answerBtn.click(show_hide_answer, [answer, show_ans], outputs=[answer_output, answerBtn, show_ans])
|
160 |
|
|
|
69 |
completion = openai.ChatCompletion.create(
|
70 |
model="gpt-3.5-turbo",
|
71 |
messages=messages,
|
72 |
+
logit_bias={42468: 5, 28938: 5}
|
73 |
)
|
74 |
response=completion.choices[0].message.content.strip()
|
75 |
messages.append({"role": "assistant", "content": response})
|
|
|
81 |
completion1 = openai.ChatCompletion.create(
|
82 |
model="gpt-3.5-turbo",
|
83 |
messages=messages1,
|
84 |
+
logit_bias={42468: 5, 28938: 5}
|
85 |
)
|
86 |
response1=completion1.choices[0].message.content.strip()
|
87 |
if '不' in response1 or '否' in response1 or '没' in response1:
|
|
|
108 |
messages = data['messages']
|
109 |
answer = data['answer']
|
110 |
idx = data['idx']
|
111 |
+
return chatbot, messages, gr.update(value=""), gr.update(value="Show Answer"), answer, idx, gr.update(value=chatbot[-1][1].replace('汤面:', '').replace('你可以开始猜测汤底的内容,我会回答你的问题。请注意,我只能回答“是”或“否”。', '').replace('<p>', '').replace('</p>', '').strip()), False
|
112 |
|
113 |
|
114 |
def show_hide_answer(answer, show_ans):
|
|
|
131 |
idx = gr.State(data['idx'])
|
132 |
show_ans = gr.State(False)
|
133 |
with gr.Row():
|
134 |
+
question = gr.Textbox(label='汤面', value=data['chatbot'][-1][1].replace('汤面:', '').replace('你可以开始猜测汤底的内容,我会回答你的问题。请注意,我只能回答“是”或“否”。', '').replace('<p>', '').replace('</p>', '').strip(),
|
135 |
lines=1, max_lines=3).style(container=False)
|
136 |
|
137 |
with gr.Row():
|
|
|
154 |
show_progress=True)
|
155 |
submitBtn.click(reset_user_input, [], [user_input])
|
156 |
|
157 |
+
emptyBtn.click(reset_state, outputs=[chatbot, messages, answer_output, answerBtn, answer, idx, question, show_ans], show_progress=True)
|
158 |
|
159 |
answerBtn.click(show_hide_answer, [answer, show_ans], outputs=[answer_output, answerBtn, show_ans])
|
160 |
|