Spaces:
Paused
Paused
code refactoring
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ from pathlib import Path
|
|
13 |
from typing import List
|
14 |
|
15 |
|
16 |
-
def build_rag_chain(pdf_paths: List[str], chunk_size: int
|
17 |
loaders = [PyPDFLoader(path) for path in pdf_paths]
|
18 |
|
19 |
docs = []
|
@@ -50,7 +50,7 @@ def build_rag_chain(pdf_paths: List[str], chunk_size: int =1000, chunk_overlap:
|
|
50 |
return rag_chain
|
51 |
|
52 |
|
53 |
-
def predict(query: str, pdf_id: str =None, user_id: str = None):
|
54 |
print(type(pdf_id))
|
55 |
# print(user_id)
|
56 |
if pdf_id:
|
@@ -72,7 +72,7 @@ def predict(query: str, pdf_id: str =None, user_id: str = None):
|
|
72 |
# os.system("ls data/pdf")
|
73 |
|
74 |
# pdf_paths = load_pdf_paths(data_root)
|
75 |
-
rag_chain = build_rag_chain([pdf_id])
|
76 |
return rag_chain.invoke(query)
|
77 |
return "Please upload PDF file"
|
78 |
|
|
|
13 |
from typing import List
|
14 |
|
15 |
|
16 |
+
def build_rag_chain(pdf_paths: List[str], chunk_size: int, chunk_overlap: int, model_name: str):
|
17 |
loaders = [PyPDFLoader(path) for path in pdf_paths]
|
18 |
|
19 |
docs = []
|
|
|
50 |
return rag_chain
|
51 |
|
52 |
|
53 |
+
def predict(query: str, pdf_id: str =None, user_id: str = None, chunk_size: int =1000, chunk_overlap: int =200, model_name: str ='gpt-4-0125-preview'):
|
54 |
print(type(pdf_id))
|
55 |
# print(user_id)
|
56 |
if pdf_id:
|
|
|
72 |
# os.system("ls data/pdf")
|
73 |
|
74 |
# pdf_paths = load_pdf_paths(data_root)
|
75 |
+
rag_chain = build_rag_chain([pdf_id], chunk_size=chunk_size, chunk_overlap=chunk_overlap, model_name=model_name)
|
76 |
return rag_chain.invoke(query)
|
77 |
return "Please upload PDF file"
|
78 |
|