add support for images (#144)

This commit is contained in:
phantomreactor 2025-05-03 01:53:58 +05:30 committed by GitHub
commit 9fec8df7d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1326 additions and 484 deletions

View file

@ -66,13 +66,17 @@ func (iuc ImageURLContent) String() string {
func (ImageURLContent) isPart() {}
type BinaryContent struct {
Path string
MIMEType string
Data []byte
}
func (bc BinaryContent) String() string {
func (bc BinaryContent) String(provider models.ModelProvider) string {
base64Encoded := base64.StdEncoding.EncodeToString(bc.Data)
return "data:" + bc.MIMEType + ";base64," + base64Encoded
if provider == models.ProviderOpenAI {
return "data:" + bc.MIMEType + ";base64," + base64Encoded
}
return base64Encoded
}
func (BinaryContent) isPart() {}
@ -110,7 +114,6 @@ type Message struct {
SessionID string
Parts []ContentPart
Model models.ModelID
CreatedAt int64
UpdatedAt int64
}