-
Hello everyone! I'm unable to attach files to prompt using with: path or with: ActionDispatch::Http::UploadedFile :( For
I'm currently trying to use the with: parameter to attach a PDF file to the prompt, but it seems the file is not being passed correctly to the model. No matter whether I use the @source object (which is an ActionDispatch::Http::UploadedFile) or the file path (@source.path), the response from the assistant is always the same: it asks me to attach the document, as if it wasn't received. Here are the details:
or
Both attempts result in the assistant replying: "Please attach the document. I can't determine the topic without the text." Debug output shows that @attachments=[], meaning no attachment is passed to the underlying model:
Expected behavior: Let me know if I should structure the file differently or if only specific object types are supported in the with: parameter. Thanks in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
✅ Update: Solved by wrapping the file in a hash with file: key After trying multiple ways to pass the file using the with: parameter in chat.ask, I discovered that you need to wrap the file in a hash with a file: key, like this:
This works for both ActionDispatch::Http::UploadedFile objects and file paths (strings), as long as the file is wrapped properly:
🚫 What didn't work for me:
results in no attachment being passed to the assistant, and @attachments stays empty. The assistant then replies with a message like: "Please attach the document. I can't determine the topic without the text." ✅ Final takeaway: 🧐 Additional note: If you're still running into issues, it's worth double-checking the behavior of the Marcel gem, which is used internally to detect file MIME types. In some environments, MIME type resolution might fail silently, causing attachments to be ignored. Hope this helps! |
Beta Was this translation helpful? Give feedback.
✅ Update: Solved by wrapping the file in a hash with file: key
Hi everyone! I just wanted to post an update for anyone facing the same issue.
After trying multiple ways to pass the file using the with: parameter in chat.ask, I discovered that you need to wrap the file in a hash with a file: key, like this:
This works for both ActionDispatch::Http::UploadedFile objects and file paths (strings), as long as the file is wrapped properly:
🚫 What didn't work for me:
Passing the file directly, like this: