Attachment Support

What are best practices for handling file attachment support and attachment processing? Right now we have a separate component from Mastra to handle file upload to S3. In the input processor we are creating custom code to handle PDF, Word Doc that converts that into markdown and then into Mastra for processing. Is that the best approach if our goal is to be able to incorporate a file into a query with the LLM?
3 Replies
Mastra Triager
GitHub
[DISCORD:1427324623480950905] Attachment Support · Issue #8808 · ...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1427324623480950905 What are best practices for handling file attachment support and attachment processing...
_roamin_
_roamin_7d ago
Hi @magellan ! You could pass the document url directly to the LLM, for example
const response = await orcaAgent.generate(
[
{
role: "user",
content: [
{
type: "text",
text: "Hello!",
},
{
type: "file",
data: "https://sample.edu/example.pdf",
mediaType: "application/pdf",
filename: "example.pdf",
},
],
},
],
// ...
})
const response = await orcaAgent.generate(
[
{
role: "user",
content: [
{
type: "text",
text: "Hello!",
},
{
type: "file",
data: "https://sample.edu/example.pdf",
mediaType: "application/pdf",
filename: "example.pdf",
},
],
},
],
// ...
})
magellan
magellanOP6d ago
This assumes the LLM handles it already, which most do not. We transformation flow that OCR the PDF to feed into the LLM. Mastra integration with AI-SDK would be great, or an example.

Did you find this page helpful?