diff options
| author | Kujtim Hoxha <[email protected]> | 2025-03-27 22:35:48 +0100 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-01 13:38:54 +0200 |
| commit | afd9ad0560d76c2a6d161dad52553b10ff428905 (patch) | |
| tree | 69f78b05ff0d7952cd3e3c9332f001e66abb2faf /internal/session | |
| parent | 904061c243f70696bfe781e97bf4e392e6954d07 (diff) | |
| download | opencode-afd9ad0560d76c2a6d161dad52553b10ff428905.tar.gz opencode-afd9ad0560d76c2a6d161dad52553b10ff428905.zip | |
rework llm
Diffstat (limited to 'internal/session')
| -rw-r--r-- | internal/session/session.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/session/session.go b/internal/session/session.go index 23abe5b5c..13f420b7c 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -2,6 +2,7 @@ package session import ( "context" + "database/sql" "github.com/google/uuid" "github.com/kujtimiihoxha/termai/internal/db" @@ -10,6 +11,7 @@ import ( type Session struct { ID string + ParentSessionID string Title string MessageCount int64 PromptTokens int64 @@ -22,6 +24,7 @@ type Session struct { type Service interface { pubsub.Suscriber[Session] Create(title string) (Session, error) + CreateTaskSession(toolCallID, parentSessionID, title string) (Session, error) Get(id string) (Session, error) List() ([]Session, error) Save(session Session) (Session, error) @@ -47,6 +50,20 @@ func (s *service) Create(title string) (Session, error) { return session, nil } +func (s *service) CreateTaskSession(toolCallID, parentSessionID, title string) (Session, error) { + dbSession, err := s.q.CreateSession(s.ctx, db.CreateSessionParams{ + ID: toolCallID, + ParentSessionID: sql.NullString{String: parentSessionID, Valid: true}, + Title: title, + }) + if err != nil { + return Session{}, err + } + session := s.fromDBItem(dbSession) + s.Publish(pubsub.CreatedEvent, session) + return session, nil +} + func (s *service) Delete(id string) error { session, err := s.Get(id) if err != nil { @@ -99,6 +116,7 @@ func (s *service) List() ([]Session, error) { func (s service) fromDBItem(item db.Session) Session { return Session{ ID: item.ID, + ParentSessionID: item.ParentSessionID.String, Title: item.Title, MessageCount: item.MessageCount, PromptTokens: item.PromptTokens, |
