Spaces:
Runtime error
Runtime error
Commit
·
f99882d
1
Parent(s):
48802c2
文件上传功能
Browse files
app.py
CHANGED
@@ -54,11 +54,14 @@ def doc_vectorize(texts):
|
|
54 |
return docsearch
|
55 |
|
56 |
#文本被拆解储存在数组texts中
|
|
|
57 |
texts = doc_split("./资治通鉴_1_残缺.txt")
|
58 |
-
title = "资治通鉴"
|
59 |
docsearch = doc_vectorize((texts))
|
60 |
|
61 |
-
def openai_reply(word1, word2, word3, temp):
|
|
|
|
|
|
|
62 |
words = word1 + "*****" + word2 + "*****" + word3
|
63 |
# 文本相似查找,最终结果是一个列表
|
64 |
docs = docsearch.similarity_search(words)
|
@@ -121,7 +124,7 @@ with gr.Blocks() as demo:
|
|
121 |
|
122 |
btn.click(
|
123 |
openai_reply,
|
124 |
-
inputs= [raw_text_1, raw_text_2, raw_text_3, temp],
|
125 |
outputs= [answer, reference, shijian],
|
126 |
)
|
127 |
|
|
|
54 |
return docsearch
|
55 |
|
56 |
#文本被拆解储存在数组texts中
|
57 |
+
# raw_file =
|
58 |
texts = doc_split("./资治通鉴_1_残缺.txt")
|
|
|
59 |
docsearch = doc_vectorize((texts))
|
60 |
|
61 |
+
def openai_reply(word1, word2, word3, temp, file):
|
62 |
+
if file:
|
63 |
+
texts = doc_split(file)
|
64 |
+
docsearch = doc_vectorize((texts))
|
65 |
words = word1 + "*****" + word2 + "*****" + word3
|
66 |
# 文本相似查找,最终结果是一个列表
|
67 |
docs = docsearch.similarity_search(words)
|
|
|
124 |
|
125 |
btn.click(
|
126 |
openai_reply,
|
127 |
+
inputs= [raw_text_1, raw_text_2, raw_text_3, temp, file],
|
128 |
outputs= [answer, reference, shijian],
|
129 |
)
|
130 |
|