mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-02 22:40:22 +00:00
feat: add support for images
This commit is contained in:
parent
0095832be3
commit
ff0ef3bb43
30 changed files with 1323 additions and 468 deletions
8
internal/message/attachment.go
Normal file
8
internal/message/attachment.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package message
|
||||
|
||||
type Attachment struct {
|
||||
FilePath string
|
||||
FileName string
|
||||
MimeType string
|
||||
Content []byte
|
||||
}
|
||||
|
|
@ -69,13 +69,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() {}
|
||||
|
|
@ -113,7 +117,6 @@ type Message struct {
|
|||
SessionID string
|
||||
Parts []ContentPart
|
||||
Model models.ModelID
|
||||
|
||||
CreatedAt int64
|
||||
UpdatedAt int64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ func (s *service) Create(ctx context.Context, sessionID string, params CreateMes
|
|||
if err != nil {
|
||||
return Message{}, err
|
||||
}
|
||||
|
||||
dbMessage, err := s.q.CreateMessage(ctx, db.CreateMessageParams{
|
||||
ID: uuid.New().String(),
|
||||
SessionID: sessionID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue