Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,7 @@ async def init():
|
|
| 50 |
await msg.send()
|
| 51 |
|
| 52 |
# --build FAISS index from csv
|
| 53 |
-
loader = CSVLoader(file_path="./data/
|
| 54 |
data = loader.load()
|
| 55 |
documents = text_splitter.transform_documents(data)
|
| 56 |
store = LocalFileStore("./cache/")
|
|
@@ -62,9 +62,9 @@ async def init():
|
|
| 62 |
docsearch = await cl.make_async(FAISS.from_documents)(documents, embedder)
|
| 63 |
|
| 64 |
chain = RetrievalQA.from_chain_type(
|
| 65 |
-
ChatOpenAI(model="gpt-3.5-turbo", temperature=0.
|
| 66 |
chain_type="stuff",
|
| 67 |
-
return_source_documents=
|
| 68 |
retriever=docsearch.as_retriever(),
|
| 69 |
chain_type_kwargs = {"prompt": prompt}
|
| 70 |
)
|
|
@@ -87,8 +87,9 @@ async def main(message):
|
|
| 87 |
answer = res["result"]
|
| 88 |
source_elements = []
|
| 89 |
visited_sources = set()
|
|
|
|
| 90 |
|
| 91 |
-
#
|
| 92 |
docs = res["source_documents"]
|
| 93 |
metadatas = [doc.metadata for doc in docs]
|
| 94 |
all_sources = [m["source"] for m in metadatas]
|
|
@@ -97,9 +98,10 @@ async def main(message):
|
|
| 97 |
if source in visited_sources:
|
| 98 |
continue
|
| 99 |
visited_sources.add(source)
|
| 100 |
-
# --
|
| 101 |
source_elements.append(
|
| 102 |
-
cl.Text(content="https://www.
|
|
|
|
| 103 |
)
|
| 104 |
|
| 105 |
if source_elements:
|
|
|
|
| 50 |
await msg.send()
|
| 51 |
|
| 52 |
# --build FAISS index from csv
|
| 53 |
+
loader = CSVLoader(file_path="./data/total_faq.csv", source_column="Answer") # columns in csv: answer, question, info_url
|
| 54 |
data = loader.load()
|
| 55 |
documents = text_splitter.transform_documents(data)
|
| 56 |
store = LocalFileStore("./cache/")
|
|
|
|
| 62 |
docsearch = await cl.make_async(FAISS.from_documents)(documents, embedder)
|
| 63 |
|
| 64 |
chain = RetrievalQA.from_chain_type(
|
| 65 |
+
ChatOpenAI(model="gpt-3.5-turbo", temperature=0.7, streaming=True),
|
| 66 |
chain_type="stuff",
|
| 67 |
+
return_source_documents=False,
|
| 68 |
retriever=docsearch.as_retriever(),
|
| 69 |
chain_type_kwargs = {"prompt": prompt}
|
| 70 |
)
|
|
|
|
| 87 |
answer = res["result"]
|
| 88 |
source_elements = []
|
| 89 |
visited_sources = set()
|
| 90 |
+
return
|
| 91 |
|
| 92 |
+
# --get documents from user session
|
| 93 |
docs = res["source_documents"]
|
| 94 |
metadatas = [doc.metadata for doc in docs]
|
| 95 |
all_sources = [m["source"] for m in metadatas]
|
|
|
|
| 98 |
if source in visited_sources:
|
| 99 |
continue
|
| 100 |
visited_sources.add(source)
|
| 101 |
+
# --create text element referenced in message
|
| 102 |
source_elements.append(
|
| 103 |
+
cl.Text(content="https://www.daysoff.no" + source, name="Info_Url")
|
| 104 |
+
#cl.Text(content="https://www.imdb.com" + source, name="Review URL")
|
| 105 |
)
|
| 106 |
|
| 107 |
if source_elements:
|