lindsay-qu
commited on
Commit
•
553fa58
1
Parent(s):
34f4c7b
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ api_base = os.environ["OPENAI_API_BASE"]
|
|
15 |
|
16 |
def chatbot_initialize():
|
17 |
retriever = core.retriever.ChromaRetriever(pdf_dir="",
|
18 |
-
collection_name="
|
19 |
split_args={"size": 2048, "overlap": 10}, #embedding_model="text-embedding-ada-002"
|
20 |
embed_model=models.BiomedModel()
|
21 |
)
|
@@ -25,7 +25,11 @@ def chatbot_initialize():
|
|
25 |
async def respond(query, chat_history, img_path_list, chat_history_string):
|
26 |
time1 = time.time()
|
27 |
global Chatbot
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
chat_history.append((query, response))
|
30 |
if img_path_list is None:
|
31 |
chat_history_string += "Query: " + query + "\nImage: None" + "\nResponse: " + response + "\n\n\n"
|
@@ -33,7 +37,7 @@ async def respond(query, chat_history, img_path_list, chat_history_string):
|
|
33 |
chat_history_string += "Query: " + query + "\nImages: " + "\n".join([path.name for path in img_path_list]) + "\nResponse: " + response + "\n\n\n"
|
34 |
time2 = time.time()
|
35 |
print(f"Total: {time2-time1}")
|
36 |
-
return "", chat_history, logs, chat_history_string
|
37 |
|
38 |
if __name__ == "__main__":
|
39 |
global Chatbot
|
|
|
15 |
|
16 |
def chatbot_initialize():
|
17 |
retriever = core.retriever.ChromaRetriever(pdf_dir="",
|
18 |
+
collection_name="pdfs_1000",
|
19 |
split_args={"size": 2048, "overlap": 10}, #embedding_model="text-embedding-ada-002"
|
20 |
embed_model=models.BiomedModel()
|
21 |
)
|
|
|
25 |
async def respond(query, chat_history, img_path_list, chat_history_string):
|
26 |
time1 = time.time()
|
27 |
global Chatbot
|
28 |
+
result = await Chatbot.response(query, image_paths=img_path_list)
|
29 |
+
response = result["answer"]
|
30 |
+
logs = result["logs"]
|
31 |
+
titles_set = result["titles"]
|
32 |
+
titles = "\n".join(list(titles_set))
|
33 |
chat_history.append((query, response))
|
34 |
if img_path_list is None:
|
35 |
chat_history_string += "Query: " + query + "\nImage: None" + "\nResponse: " + response + "\n\n\n"
|
|
|
37 |
chat_history_string += "Query: " + query + "\nImages: " + "\n".join([path.name for path in img_path_list]) + "\nResponse: " + response + "\n\n\n"
|
38 |
time2 = time.time()
|
39 |
print(f"Total: {time2-time1}")
|
40 |
+
return "", chat_history, logs + "\n\n" + titles, chat_history_string
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
global Chatbot
|