Hey again team! one question... if i want to give ...
# koog-agentic-framework
e
Hey again team! one question... if i want to give the agent .pdf document to learn and answer question about the information inside it the .pdf. The best way to do it is in the prompt using attachments?
v
Hi! It depends on the model you are willing to use. Not all models support documents, and some that do might be more expensive. So it’s basically a trade-off between using some external tools for pdf->text extraction and then providing the text to a cheaper model VS using a smaeter model without any extra tools/libraries. For the start I would suggest doing what you described — just add pdf as attachment
e
okay! and for example if i want to use OpenAIModels.Chat.GPT4o... can i read documents? and this is the way to do it:
Copy code
attachments {
    attachment(
        Attachment.File(
            content = AttachmentContent.Binary.Bytes(readPdfAsBytes("/Users/eduardoruesta/Workplace/SafePal/uso_pantalla.pdf")),
            format = "pdf",
            mimeType = "application/pdf",
        )
    )
    attachment(
        Attachment.File(
            content = AttachmentContent.Binary.Bytes(readPdfAsBytes("/Users/eduardoruesta/Workplace/SafePal/bebes_ninos_pantalla.pdf")),
            format = "pdf", 
            mimeType = "application/pdf",
        )
    )
}
👌 1
i have an error: Model gpt-4o does not support files
😵 1
v
What if you try something like
Copy code
val MyGPT4o = with(OpenAIModels.Chat.GPT4o) {
   copy(capabilities = capabilities + LLMCapability.Document)
}
as was described above in the thread?
e
yea!! worked. now facing another issue haha
Error: Error from OpenAl API: -1 Unknown Status Code: "error": م "message": "Missing required parameter: messages[1].content[1].file.fle_id".", type": "invalid_request_error" param": "messages[1].content[1].file.file_id", "code": "missing_required_parameter )
I looked up the problem, and it says I need to upload the files to OpenAI first. Is that correct? Or is there a way to get the model to read my PDFs?
p
it says I need to upload the files to OpenAI first
It’s expected to work like that, but OpenAI allowed sending files directly, and
file_id
is optional field I’ll look into what the issue is
Unfortunately, OpenAI now really requires using the file api, need to upload file and then specify file id Even though the documentation says that file_id is optional there’s no workaround for this using attachments. The only option is to read the text and include it as part of the prompt
e
Yes, i saw the same. Thats why i moved to Gemini and worked! Thanks 🙏🏽
p
Possibly, this is related to issues on openai side and the current release of gpt-5. A month ago, pdf files were working with openai. Nevertheless, I’ve created an issue to use the File API - KG-215
e
niceee!! thanks for that kodee happy