Update app.py
Browse files
app.py
CHANGED
@@ -37,8 +37,13 @@ def local_query(query, context):
|
|
37 |
Context: {}
|
38 |
Question: {}
|
39 |
""".format(context, query)
|
|
|
|
|
|
|
40 |
|
41 |
inputs = tokenizer(t5query, return_tensors="pt")
|
|
|
|
|
42 |
outputs = model.generate(**inputs, max_new_tokens=20)
|
43 |
|
44 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
@@ -85,34 +90,6 @@ def run_query(file, history, query):
|
|
85 |
return history, result
|
86 |
|
87 |
|
88 |
-
# def load_document(pdf_filename):
|
89 |
-
|
90 |
-
|
91 |
-
# loader = PDFMinerLoader(pdf_filename)
|
92 |
-
# doc = loader.load()
|
93 |
-
|
94 |
-
# text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
95 |
-
# texts = text_splitter.split_documents(doc)
|
96 |
-
|
97 |
-
# texts = [i.page_content for i in texts]
|
98 |
-
|
99 |
-
# doc_emb = st_model.encode(texts)
|
100 |
-
# doc_emb = doc_emb.tolist()
|
101 |
-
|
102 |
-
# ids = [str(uuid.uuid1()) for _ in doc_emb]
|
103 |
-
|
104 |
-
# client = chromadb.Client()
|
105 |
-
# collection = client.create_collection("test_db")
|
106 |
-
|
107 |
-
# collection.add(
|
108 |
-
# embeddings=doc_emb,
|
109 |
-
# documents=texts,
|
110 |
-
# ids=ids
|
111 |
-
# )
|
112 |
-
|
113 |
-
# return 'Success'
|
114 |
-
|
115 |
-
|
116 |
|
117 |
|
118 |
def upload_pdf(file):
|
|
|
37 |
Context: {}
|
38 |
Question: {}
|
39 |
""".format(context, query)
|
40 |
+
|
41 |
+
print('t5 query is')
|
42 |
+
primt(t5query)
|
43 |
|
44 |
inputs = tokenizer(t5query, return_tensors="pt")
|
45 |
+
|
46 |
+
print('done with tokenizer')
|
47 |
outputs = model.generate(**inputs, max_new_tokens=20)
|
48 |
|
49 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
|
90 |
return history, result
|
91 |
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
|
95 |
def upload_pdf(file):
|