Spaces:
Sleeping
Sleeping
Commit
·
3284c4f
1
Parent(s):
6dcf428
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,19 +25,9 @@ def paper_changes(paper_id):
|
|
| 25 |
qa = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True)
|
| 26 |
return 'Ready!!'
|
| 27 |
|
| 28 |
-
def
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
documents = loader.load_and_split()
|
| 32 |
-
text_splitter = CharacterTextSplitter(chunk_size=1024, chunk_overlap=0)
|
| 33 |
-
texts = text_splitter.split_documents(documents)
|
| 34 |
-
embeddings = HuggingFaceHubEmbeddings()
|
| 35 |
-
db = Chroma.from_documents(texts, embeddings)
|
| 36 |
-
retriever = db.as_retriever()
|
| 37 |
-
llm = HuggingFaceHub(repo_id='mistralai/Mistral-7B-v0.1', model_kwargs={'temperature': 0.5, 'max_new_tokens': 2096})
|
| 38 |
-
global qa
|
| 39 |
-
qa = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True)
|
| 40 |
-
return 'Ready!!'
|
| 41 |
|
| 42 |
def bot(history):
|
| 43 |
response = infer(history[-1][0])
|
|
|
|
| 25 |
qa = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True)
|
| 26 |
return 'Ready!!'
|
| 27 |
|
| 28 |
+
def add_text(history, text):
|
| 29 |
+
history = history + [(text, None)]
|
| 30 |
+
return history, ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def bot(history):
|
| 33 |
response = infer(history[-1][0])
|