-
Notifications
You must be signed in to change notification settings - Fork 135
Feature/images #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature/images #72
Conversation
Tested openai and anthropic. Need to fix test cases and refactor |
internal/llm/agent/agent.go
Outdated
@@ -38,7 +39,7 @@ func (e *AgentEvent) Response() message.Message { | |||
} | |||
|
|||
type Service interface { | |||
Run(ctx context.Context, sessionID string, content string) (<-chan AgentEvent, error) | |||
Run(ctx context.Context, sessionID string, content string, attachments [][]byte) (<-chan AgentEvent, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run(ctx context.Context, sessionID string, content string, attachments [][]byte) (<-chan AgentEvent, error) | |
Run(ctx context.Context, sessionID string, content string, attachments ...[]byte) (<-chan AgentEvent, error) |
Just a small thing maybe this looks better so that you don't have to use nil
when you don't have attachments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you're right. will change
@PhantomReactor this is great 🙌 |
keep up the great work! |
hey @kujtimiihoxha, somethng's wrong with gemini models or am i just dumb? can't get them working |
nevermind, saw your comments in other discussions |
@PhantomReactor yeah that provides is messed up I did not test it enough, something is definitely wrong with it |
okay. will test it from my end after this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not ready but saw a couple of things that maybe can be improved
internal/tui/tui.go
Outdated
@@ -95,6 +100,11 @@ type appModel struct { | |||
|
|||
showInitDialog bool | |||
initDialog dialog.InitDialogCmp | |||
|
|||
editingMode bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this came from pulling from main this is removed now.
internal/llm/agent/agent.go
Outdated
@@ -157,7 +156,7 @@ func (a *agent) err(err error) AgentEvent { | |||
} | |||
} | |||
|
|||
func (a *agent) Run(ctx context.Context, sessionID string, content string) (<-chan AgentEvent, error) { | |||
func (a *agent) Run(ctx context.Context, sessionID string, content string, attachmentPaths string, attachments ...[]byte) (<-chan AgentEvent, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we instead create a type here for attachment something like
type Attachment struct {
Path string
Data []byte
}
And than also update the message.BinaryContent
to add the Path
attribute, this way we do not need to add a new attribute to the message itself and it keeps the code a bit cleaner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Didn't push my latest changes, that should address the attachment comment. Will push it when I get back
- Any reason we need path in binary content?
Also, I was trying to add image previews to the messages but they just keep aligning diagonally breaking the ui. I will try to fix it but if it takes time let's merge it to master without previews. Will keep you updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What is
attachmentPaths
used for, is it a list of paths for attachments that the message has? I might have misunderstood it, my thought was to store the paths in the binary content so that you don't have to add a new field to the message itself and you know which path represents which data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am saving attachment paths in a new db column in messages table. We can use it to fetch all the attachments(assuming the path isn't broken) when retrieving message history and display them on messages on chat page. As I moved path to attachment type I don't see any reason to attach them to binary content. Let me know if I am missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought was to remove the attachmentPaths
from the message and instead add the Path
in the BinaryContent instead, this way you have the path and the data (even if the path is broken you have the data the user initially uploaded) and you than you can use myMsg.BinaryContent()
to get all binary content including all their paths and you can still display them in the chat page. The main reason to do it this way is to have 1 place we store related image data. Does this explain my thinking better? let me know if I can share more context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I had the same thought initially but we will have to create a new table to store binary content. I decided not to considering the length of base64 strings and the size of the encoded attachments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm what if instead we just update https://github.com/PhantomReactor/opencode/blob/feature/images/internal/message/content.go#L70 to be a string and store the base64 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will be storing all the attachments base64 in db which is not a good idea. Also deserialising them from db would be slow.
Also I understand the downside to storing paths in db is they could be broken if user deletes files but I feel the second one is a better for performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I get your concern🤔, I was thinking since this is all local and the DB is per project it would not be a big issue but maybe you are right... in that case maybe we just update the BinaryContent model so that it just stores the Path and nothing else and than you use that to load the images in the history... We might need to just ignore paths that are now broken...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right. i am saving it in attachment_paths column in messages table
Closes #40 |
@PhantomReactor I merged fixes for the gemini provider it should work as expected now. I am really exited for this PR thanks so much for working on this you are awesome 🙌 |
thanks man, i too am excited to work on this. thanks for making this tool |
@PhantomReactor another thing you could consider is pushing the preview stuff to a follow up pr and just include the paths for now. Another reason that might be a good thing is that rendering the images might make it slow to render if you have many... |
It looks like bubbletea doesn't support images. There's an open issue for image support in bubbletea. Images sort of render but the ui just breaks after that. I will just add ASCII previews for file picker and messages will just have paths. Will push the latest changes today. |
@PhantomReactor this is sooo amazing man, I think a couple of small things.
|
|
InShot_20250429_212847545.mp4