-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_processor.py
More file actions
29 lines (24 loc) · 802 Bytes
/
Copy pathdata_processor.py
File metadata and controls
29 lines (24 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
from langchain_community.document_loaders import PyPDFLoader
async def load_pages(file_dir):
pages = []
for file_path in os.listdir(file_dir):
file_path = os.path.join(file_dir, file_path)
if not file_path.endswith(".pdf"):
continue
loader = PyPDFLoader(file_path)
async for page in loader.alazy_load():
pages.append(page)
return pages
async def process_claim(agent, claim):
response = await agent.ainvoke({"claim": claim, "mistake_message": ""})
return {
"claim": claim,
"match_source": [
{
"document_name": detail.document_name,
"matching_text": detail.matching_text
}
for detail in response["answer"].details
]
}