Spaces:
Build error
Build error
Jack Sambath commited on
Commit ·
bc99b82
1
Parent(s): e4a31f9
new cache
Browse files
app.py
CHANGED
|
@@ -18,21 +18,8 @@ def qa(query):
|
|
| 18 |
texts = text_splitter.split_documents(docs)
|
| 19 |
embeddings = HuggingFaceEmbeddings()
|
| 20 |
vectordb = Chroma.from_documents(documents=texts,embedding=embeddings)
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# docs = loader.load()
|
| 27 |
-
# text_splitter = RecursiveCharacterTextSplitter (chunk_size=1000, chunk_overlap=200)
|
| 28 |
-
# texts = text_splitter.split_documents(docs)
|
| 29 |
-
# embeddings = HuggingFaceEmbeddings()
|
| 30 |
-
# vectordb = Chroma.from_documents(documents=texts,embedding=embeddings)
|
| 31 |
-
# llm = HuggingFaceHub(repo_id="google/flan-t5-small", model_kwargs={"temperature":0,"max_length":200}, huggingfacehub_api_token="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") # type: ignore
|
| 32 |
-
# qa = RetrievalQA.from_chain_type(llm=llm(), chain_type="stuff",retriever=vectordb.as_retriever(search_type="mmr", search_kwargs={'fetch_k': 30}), return_source_documents=True)
|
| 33 |
-
query = st.text_input("Ask a question: ")
|
| 34 |
-
# qa(inputs=query,return_only_outputs=True)
|
| 35 |
-
result = qa({"query": query})
|
| 36 |
-
st.write(result["result"])
|
| 37 |
-
st.write(result["source_documents"][0])
|
| 38 |
-
main()
|
|
|
|
| 18 |
texts = text_splitter.split_documents(docs)
|
| 19 |
embeddings = HuggingFaceEmbeddings()
|
| 20 |
vectordb = Chroma.from_documents(documents=texts,embedding=embeddings)
|
| 21 |
+
return RetrievalQA.from_chain_type(llm=llm(), chain_type="stuff",retriever=vectordb.as_retriever(search_type="mmr", search_kwargs={'fetch_k': 30}), return_source_documents=True)
|
| 22 |
+
query = st.text_input("Ask a question: ")
|
| 23 |
+
result = qa({"query": query})
|
| 24 |
+
st.write(result["result"])
|
| 25 |
+
st.write(result["source_documents"][0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|