Update app.py
Browse files
app.py
CHANGED
@@ -105,7 +105,7 @@ def infer(message:str, history: list):
|
|
105 |
documents, option = extract_web(message["text"])
|
106 |
db_path = create_col(documents)
|
107 |
elif not message["text"].startswith("http://") and not message["text"].startswith("https://") and len(history) == 0:
|
108 |
-
|
109 |
|
110 |
|
111 |
# Load from disk
|
@@ -123,7 +123,7 @@ def infer(message:str, history: list):
|
|
123 |
)
|
124 |
|
125 |
if option == "web" and len(history) == 0:
|
126 |
-
response = "
|
127 |
else:
|
128 |
question = message['text']
|
129 |
|
@@ -131,10 +131,11 @@ def infer(message:str, history: list):
|
|
131 |
index.as_retriever(),
|
132 |
memory=memory,
|
133 |
context_prompt=(
|
134 |
-
"You are
|
135 |
-
"
|
136 |
-
"Here are the relevant documents for the context:\n"
|
137 |
"{context_str}"
|
|
|
|
|
138 |
"\nInstruction: Use the previous chat history, or the context above, to interact and help the user."
|
139 |
),
|
140 |
verbose=True,
|
@@ -155,9 +156,9 @@ def infer(message:str, history: list):
|
|
155 |
|
156 |
|
157 |
|
158 |
-
chatbot = gr.Chatbot()
|
159 |
|
160 |
-
with gr.Blocks(theme="soft") as demo:
|
161 |
gr.ChatInterface(
|
162 |
fn = infer,
|
163 |
title = "RAG demo",
|
|
|
105 |
documents, option = extract_web(message["text"])
|
106 |
db_path = create_col(documents)
|
107 |
elif not message["text"].startswith("http://") and not message["text"].startswith("https://") and len(history) == 0:
|
108 |
+
raise gr.Error("请先输入网址或上传文档。")
|
109 |
|
110 |
|
111 |
# Load from disk
|
|
|
123 |
)
|
124 |
|
125 |
if option == "web" and len(history) == 0:
|
126 |
+
response = "获取成功,开始对话吧!"
|
127 |
else:
|
128 |
question = message['text']
|
129 |
|
|
|
131 |
index.as_retriever(),
|
132 |
memory=memory,
|
133 |
context_prompt=(
|
134 |
+
"You are an assistant for question-answering tasks."
|
135 |
+
"Use the following context to answer the question:\n"
|
|
|
136 |
"{context_str}"
|
137 |
+
"\nIf you don't know the answer, just say that you don't know."
|
138 |
+
"Use five sentences maximum and keep the answer concise, all response in Chinese."
|
139 |
"\nInstruction: Use the previous chat history, or the context above, to interact and help the user."
|
140 |
),
|
141 |
verbose=True,
|
|
|
156 |
|
157 |
|
158 |
|
159 |
+
chatbot = gr.Chatbot(placeholder="请先输入网址或上传文档<br>然后进行对话")
|
160 |
|
161 |
+
with gr.Blocks(theme="soft", fill_height="true") as demo:
|
162 |
gr.ChatInterface(
|
163 |
fn = infer,
|
164 |
title = "RAG demo",
|