Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def chatbot(input, choice):
|
|
75 |
search_prompt = [f"Source:\nTitle: {result['name']}\nURL: {result['url']}\nContent: {result['snippet']}" for result in internet_search_result]
|
76 |
print('content:\n', search_prompt[0])
|
77 |
# prompt = "Use these sources to answer the question:\n\n" + "\n\n".join(search_prompt) + "\n\nQuestion: " + input + "\n\nAnswer:"
|
78 |
-
prompt = "Use these sources to answer the question:\n\n" + "\n\n".join(search_prompt[0:3]) + "\n\nQuestion: " + input + "\n\nAnswer
|
79 |
messages.append({"role": "user", "content": prompt})
|
80 |
|
81 |
## no streaming version.
|
@@ -124,7 +124,7 @@ auth_list = [(x, y) for (x, y) in user_csv[['username', 'password']].values]
|
|
124 |
## 如果要优化显示效果,参见: https://gradio.app/theming-guide/
|
125 |
try:
|
126 |
inputs = [gr.inputs.Textbox(lines=5, label="请输入你的问题/任务"), gr.Radio(['默认ChatGPT模式', '联网增强模式'], label="ChatGPT运行模式")] #! working. 如果有多个input,那么需要把这些input放在一个list里面,然后传给inputs。注意这里如果更改了选项的文字,需要到chatbot中更改对应的文字。
|
127 |
-
outputs = gr.outputs.Textbox(label="ChatGPT的回答").style(show_copy_button=True)
|
128 |
interface = gr.Interface(
|
129 |
# fn=chatbot,
|
130 |
fn=chatbot,
|
|
|
75 |
search_prompt = [f"Source:\nTitle: {result['name']}\nURL: {result['url']}\nContent: {result['snippet']}" for result in internet_search_result]
|
76 |
print('content:\n', search_prompt[0])
|
77 |
# prompt = "Use these sources to answer the question:\n\n" + "\n\n".join(search_prompt) + "\n\nQuestion: " + input + "\n\nAnswer:"
|
78 |
+
prompt = "Use these sources to answer the question:\n\n" + "\n\n".join(search_prompt[0:3]) + "\n\nQuestion: " + input + "\n\nAnswer:(注意:回答问题时请提示'以下答案基于互联网公开信息。')" ## 限制了只有3个搜索结果。
|
79 |
messages.append({"role": "user", "content": prompt})
|
80 |
|
81 |
## no streaming version.
|
|
|
124 |
## 如果要优化显示效果,参见: https://gradio.app/theming-guide/
|
125 |
try:
|
126 |
inputs = [gr.inputs.Textbox(lines=5, label="请输入你的问题/任务"), gr.Radio(['默认ChatGPT模式', '联网增强模式'], label="ChatGPT运行模式")] #! working. 如果有多个input,那么需要把这些input放在一个list里面,然后传给inputs。注意这里如果更改了选项的文字,需要到chatbot中更改对应的文字。
|
127 |
+
outputs = gr.outputs.Textbox(lines=11, label="ChatGPT的回答").style(show_copy_button=True)
|
128 |
interface = gr.Interface(
|
129 |
# fn=chatbot,
|
130 |
fn=chatbot,
|