How do I process the attachments correctly? #296
Unanswered
the-s-anton
asked this question in
Q&A
Replies: 1 comment
-
I worked around this by using ActiveStorage direct uploads in the browser and storing the signed_ids for the uploaded files in a hidden field that is submitted with the users message. I then pass the user message and the signed_ids to the job. If signed_ids exist then I fetch the attachments blobs and call ask with attachments. chat.ask(user_content, with: attachments) do |chunk|
...
end Seems to work well. Next up is to do more validation and error handling for when files are too big for the context window. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Love this gem
I am currently working on a project that utilizes this gem as its core. Here is what I want to get:
The user creates a new message record and attaches multiple files. I did review the documentation, and it does describe the setup of the attachments. However, what I am confused about is the controller itself.
As per the documentation on scalability, it suggests setting up the ActiveJob in a certain way:
Ok, now let's move to the controllers. I would like to initiate the chat using a form and attach one or more files. However, we encounter a problem here because we cannot pass the files from the form into the job due to a garbage collection issue.
Ok, the workaround (which is perfect to me) is to create another model, let's call it
Asset
. Asset has one Attachment (ActiveStorage). Now I can do something like thisThe issue here is that the messages will not get the reference to the assets. However, I can't display the file within a chat, but the solution still works.
Here is another way of doing it
In this case, we are bypassing the Asset model, but we attach everything to the message, allowing us to display the attachment in the chat.
What will be the proper setup here? How can I let accounts control the assets in the settings while also displaying them nicely in the chat? What am I missing? It seems like I'm over-engineering at this stage.
Beta Was this translation helpful? Give feedback.
All reactions