mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-09 19:52:44 +00:00
wip: refactoring tui
This commit is contained in:
parent
37c0c1f358
commit
005d6e0bde
30 changed files with 168 additions and 4674 deletions
|
|
@ -4,8 +4,6 @@ import (
|
|||
"encoding/base64"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/sst/opencode/internal/llm/models"
|
||||
)
|
||||
|
||||
type MessageRole string
|
||||
|
|
@ -74,11 +72,11 @@ type BinaryContent struct {
|
|||
Data []byte
|
||||
}
|
||||
|
||||
func (bc BinaryContent) String(provider models.ModelProvider) string {
|
||||
func (bc BinaryContent) String(provider string) string {
|
||||
base64Encoded := base64.StdEncoding.EncodeToString(bc.Data)
|
||||
if provider == models.ProviderOpenAI {
|
||||
return "data:" + bc.MIMEType + ";base64," + base64Encoded
|
||||
}
|
||||
// if provider == models.ProviderOpenAI {
|
||||
// return "data:" + bc.MIMEType + ";base64," + base64Encoded
|
||||
// }
|
||||
return base64Encoded
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
"github.com/sst/opencode/internal/db"
|
||||
"github.com/sst/opencode/internal/llm/models"
|
||||
"github.com/sst/opencode/internal/pubsub"
|
||||
)
|
||||
|
||||
|
|
@ -21,7 +20,6 @@ type Message struct {
|
|||
Role MessageRole
|
||||
SessionID string
|
||||
Parts []ContentPart
|
||||
Model models.ModelID
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
|
@ -35,7 +33,6 @@ const (
|
|||
type CreateMessageParams struct {
|
||||
Role MessageRole
|
||||
Parts []ContentPart
|
||||
Model models.ModelID
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
|
|
@ -104,7 +101,6 @@ func (s *service) Create(ctx context.Context, sessionID string, params CreateMes
|
|||
SessionID: sessionID,
|
||||
Role: string(params.Role),
|
||||
Parts: string(partsJSON),
|
||||
Model: sql.NullString{String: string(params.Model), Valid: params.Model != ""},
|
||||
}
|
||||
|
||||
dbMessage, err := s.db.CreateMessage(ctx, dbMsgParams)
|
||||
|
|
@ -312,7 +308,6 @@ func (s *service) fromDBItem(item db.Message) (Message, error) {
|
|||
SessionID: item.SessionID,
|
||||
Role: MessageRole(item.Role),
|
||||
Parts: parts,
|
||||
Model: models.ModelID(item.Model.String),
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue