adk-python
adk-python copied to clipboard
PDF artifact not being OCR’d by ADK
Problem
Sending a PDF as a Part with mime_type='application/pdf' but the agent:
- Always asks for “raw text”.
- Returns made-up data that doesn’t match the PDF.
Steps
- Create session
- Save PDF via
artifact_service.save_artifact - Send:
content = Content(parts=[ Part(text=f"Patient folder: {patient_id}"), Part.from_bytes(pdf_bytes, mime_type="application/pdf") ]) async for event in runner.run_async(...): ... - Agent never invokes OCR or
analyze_attachment.
Questions
- Is sending PDF Parts directly supported?
- How to trigger OCR (built‑in or custom tool) on a PDF artifact?
- Should I pre-convert PDFs to text/images instead?
I'm using 2.5 pro model, that should support PDF. Any examples in ADK repos appreciated.
pdf_part = Part.from_bytes(
data=pdf_bytes,
mime_type="application/pdf"
)
session_id = f"{patient_id}_{filename}"
await session_service.create_session(
app_name=APP_NAME,
user_id=USER_ID,
session_id=session_id
)
version = await artifact_service.save_artifact(
app_name=APP_NAME,
user_id=USER_ID,
session_id=session_id,
filename=filename,
artifact=pdf_part
)
content = Content(parts=[
Part(text=f"Patient folder: {patient_id}"),
pdf_part
])
async for event in runner.run_async(
user_id=USER_ID,
session_id=session_id,
new_message=content
)
Might be the same issue as https://github.com/google/adk-python/issues/2017.
Hi, Is there any update to this issue? I am facing the same issue. I am uploading the PDF from artifact service, but 50% of the time it hallucinates and speaks made up data about PDF and other 50% of the time it is accurate? I am on ADK 1.8.0