You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the acts_as_chat implementation of the ask method lacks support for rich attachments (e.g., images, audio, PDFs) through the with: parameter. To bring parity with the core Chat class, I propose enhancing the ask method within acts_as_chat to handle attachments seamlessly.
Desired Functionality
Enhance the ask method so users can attach rich content directly:
# Text-only requestchat.ask"What can you tell me about this code?"# Request with a single image attachmentchat.ask"What's in this image?",with: {image: "path/to/image.jpg"}# Request with multiple attachmentschat.ask"Analyse this document and image together",with: {image: ["path/to/image1.jpg","path/to/image2.png"],pdf: "path/to/document.pdf"}
Implementation Steps
Step 1: Update the ask method in ChatMethods
Modify the ask method in the ChatMethods module to accept a with: parameter:
@schappim, thanks for the proposal, I vote for that. Would you like to add a pull request with those updates? i'd use that even from the branch. Or i could make it if you mind :) 🙏
By chance, are you also using ActiveStorage for images/pdfs? The struggle I'm having, beside the with param missing from the acts_as_chatask method, is accessing the file for Base64 encoding. I'd be fine doing the encoding myself but it would be nice if there was a more friendly way to load the content from the rails friendly document storage.
Overview
Currently, the
acts_as_chat
implementation of theask
method lacks support for rich attachments (e.g., images, audio, PDFs) through thewith:
parameter. To bring parity with the coreChat
class, I propose enhancing theask
method withinacts_as_chat
to handle attachments seamlessly.Desired Functionality
Enhance the
ask
method so users can attach rich content directly:Implementation Steps
Step 1: Update the
ask
method inChatMethods
Modify the
ask
method in theChatMethods
module to accept awith:
parameter:Step 2: Enhance
MessageMethods
to handleContent
objectsUpdate the
extract_content
method in theMessageMethods
module:Step 3: Update the
persist_message_completion
methodModify the
persist_message_completion
method to ensure proper storage ofContent
objects:Benefits
Chat
implementation, simplifying developer workflow.The text was updated successfully, but these errors were encountered: