Spaces:
Sleeping
Sleeping
guangliang.yin commited on
Commit ·
acdfd32
1
Parent(s): d91fac5
add log 2 bugfix -5:ids 改为uuid
Browse files- app.py +5 -6
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from langchain.document_loaders import WebBaseLoader
|
|
| 7 |
from langchain.text_splitter import CharacterTextSplitter
|
| 8 |
from langchain.chains import RetrievalQAWithSourcesChain
|
| 9 |
from langchain.llms import OpenAI
|
|
|
|
| 10 |
|
| 11 |
chain: Optional[Callable] = None
|
| 12 |
|
|
@@ -23,17 +24,16 @@ def web_loader(url_list, openai_key, zilliz_uri, user, password):
|
|
| 23 |
|
| 24 |
if not embeddings:
|
| 25 |
return "embeddings not"
|
| 26 |
-
print("计算向量结果:", embeddings)
|
| 27 |
-
|
| 28 |
-
print("docs------->:", docs)
|
| 29 |
|
| 30 |
texts = [d.page_content for d in docs]
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
docsearch = Zilliz.from_documents(
|
| 34 |
docs,
|
| 35 |
embedding=embeddings,
|
| 36 |
-
ids=
|
| 37 |
connection_args={
|
| 38 |
"uri": zilliz_uri,
|
| 39 |
"user": user,
|
|
@@ -44,7 +44,6 @@ def web_loader(url_list, openai_key, zilliz_uri, user, password):
|
|
| 44 |
|
| 45 |
if not docsearch:
|
| 46 |
return "docsearch not"
|
| 47 |
-
print("docsearch结果:", docsearch)
|
| 48 |
|
| 49 |
global chain
|
| 50 |
chain = RetrievalQAWithSourcesChain.from_chain_type(
|
|
|
|
| 7 |
from langchain.text_splitter import CharacterTextSplitter
|
| 8 |
from langchain.chains import RetrievalQAWithSourcesChain
|
| 9 |
from langchain.llms import OpenAI
|
| 10 |
+
import uuid
|
| 11 |
|
| 12 |
chain: Optional[Callable] = None
|
| 13 |
|
|
|
|
| 24 |
|
| 25 |
if not embeddings:
|
| 26 |
return "embeddings not"
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
texts = [d.page_content for d in docs]
|
| 29 |
+
|
| 30 |
+
idsByDocs=[str(uuid.uuid4()) for _ in range(len(texts))],
|
| 31 |
+
print("idsByDocs-------->:", idsByDocs)
|
| 32 |
|
| 33 |
docsearch = Zilliz.from_documents(
|
| 34 |
docs,
|
| 35 |
embedding=embeddings,
|
| 36 |
+
ids=idsByDocs,
|
| 37 |
connection_args={
|
| 38 |
"uri": zilliz_uri,
|
| 39 |
"user": user,
|
|
|
|
| 44 |
|
| 45 |
if not docsearch:
|
| 46 |
return "docsearch not"
|
|
|
|
| 47 |
|
| 48 |
global chain
|
| 49 |
chain = RetrievalQAWithSourcesChain.from_chain_type(
|
requirements.txt
CHANGED
|
@@ -3,4 +3,5 @@ langchain
|
|
| 3 |
openai
|
| 4 |
tiktoken
|
| 5 |
gradio
|
| 6 |
-
bs4
|
|
|
|
|
|
| 3 |
openai
|
| 4 |
tiktoken
|
| 5 |
gradio
|
| 6 |
+
bs4
|
| 7 |
+
uuid
|