Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,8 @@ def search_web(query):
|
|
46 |
if results:
|
47 |
for result in results:
|
48 |
web_content += result['body']
|
49 |
-
return web_content
|
|
|
50 |
|
51 |
def chat_gpt(input, use_web, history=None):
|
52 |
if history is None:
|
@@ -88,7 +89,7 @@ def chat_gpt(input, use_web, history=None):
|
|
88 |
|
89 |
result = qa({"query": input, "chat_history": history})
|
90 |
logger.info("chatgpt:", input,result)
|
91 |
-
return result["
|
92 |
|
93 |
def predict(input,
|
94 |
large_language_model,
|
@@ -103,10 +104,12 @@ def predict(input,
|
|
103 |
if history == None:
|
104 |
history = []
|
105 |
|
106 |
-
if large_language_model == "
|
107 |
resp = chat_gpt(input, use_web, history)
|
108 |
elif large_language_model == "ChatGLM-6B-int4":
|
109 |
resp = chat_glm(input, history)
|
|
|
|
|
110 |
|
111 |
history.append((input, resp))
|
112 |
return '', history, history
|
@@ -126,7 +129,7 @@ with block as demo:
|
|
126 |
model_choose = gr.Accordion("模型选择")
|
127 |
with model_choose:
|
128 |
large_language_model = gr.Dropdown(
|
129 |
-
["ChatGLM-6B-int4","
|
130 |
label="large language model",
|
131 |
value="ChatGLM-6B-int4")
|
132 |
use_web = gr.Radio(["True", "False"],
|
|
|
46 |
if results:
|
47 |
for result in results:
|
48 |
web_content += result['body']
|
49 |
+
# return web_content
|
50 |
+
return '' # 4097 tokens limit
|
51 |
|
52 |
def chat_gpt(input, use_web, history=None):
|
53 |
if history is None:
|
|
|
89 |
|
90 |
result = qa({"query": input, "chat_history": history})
|
91 |
logger.info("chatgpt:", input,result)
|
92 |
+
return result["result"]
|
93 |
|
94 |
def predict(input,
|
95 |
large_language_model,
|
|
|
104 |
if history == None:
|
105 |
history = []
|
106 |
|
107 |
+
if large_language_model == "GPT-3.5-turbo":
|
108 |
resp = chat_gpt(input, use_web, history)
|
109 |
elif large_language_model == "ChatGLM-6B-int4":
|
110 |
resp = chat_glm(input, history)
|
111 |
+
elif large_language_model == "Search Web":
|
112 |
+
resp = search_web(input)
|
113 |
|
114 |
history.append((input, resp))
|
115 |
return '', history, history
|
|
|
129 |
model_choose = gr.Accordion("模型选择")
|
130 |
with model_choose:
|
131 |
large_language_model = gr.Dropdown(
|
132 |
+
["ChatGLM-6B-int4","GPT-3.5-turbo","Search Web"],
|
133 |
label="large language model",
|
134 |
value="ChatGLM-6B-int4")
|
135 |
use_web = gr.Radio(["True", "False"],
|