Skip to content

Commit 75b195e

Browse files
committed
fix: update PDF processing in web interfaces - Update gradio_app to handle docuent_id correctly - Update FastAPI endpoint to use returned document_id - Fix document_id handling in vector store integration
1 parent 554e0d6 commit 75b195e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

agentic_rag/gradio_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def load_config():
4040
def process_pdf(file: tempfile._TemporaryFileWrapper) -> str:
4141
"""Process uploaded PDF file"""
4242
try:
43-
chunks = pdf_processor.process_pdf(file.name)
44-
vector_store.add_pdf_chunks(chunks)
45-
return f"✓ Successfully processed PDF and added {len(chunks)} chunks to knowledge base"
43+
chunks, document_id = pdf_processor.process_pdf(file.name)
44+
vector_store.add_pdf_chunks(chunks, document_id=document_id)
45+
return f"✓ Successfully processed PDF and added {len(chunks)} chunks to knowledge base (ID: {document_id})"
4646
except Exception as e:
4747
return f"✗ Error processing PDF: {str(e)}"
4848

agentic_rag/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ async def upload_pdf(file: UploadFile = File(...)):
6666
buffer.write(content)
6767

6868
# Process the PDF
69-
chunks = pdf_processor.process_pdf(temp_path)
69+
chunks, document_id = pdf_processor.process_pdf(temp_path)
7070

7171
# Add chunks to vector store
72-
document_id = str(uuid.uuid4())
73-
vector_store.add_pdf_chunks(chunks, document_id)
72+
vector_store.add_pdf_chunks(chunks, document_id=document_id)
7473

7574
# Clean up
7675
os.remove(temp_path)

0 commit comments

Comments
 (0)