basic llm request stream

This commit is contained in:
fabien committed 2026-09-22 21:15:23 +02:00
1 parent f74e4d1043
commit a92cc76a9a
66 files changed
+1496 -158

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
package brain
import (
"context"
"fmt"
"sync"
"trankilou.fr/lassistanoque/backend/internal/domain"
"trankilou.fr/lassistanoque/backend/internal/utility"
)
type Dependencies struct {
ChatRepository domain.ChatRepository
}
type Router struct {
started bool
mu sync.Mutex
sessions map[string]*Session // running sessions
newSessionChan chan string
closeChan chan bool
}
func NewRouter(deps Dependencies) *Router {
return &Router{
started: true,
sessions: make(map[string]*Session),
newSessionChan: make(chan string),
closeChan: make(chan bool),
}
}
func (s *Router) Start() error {
for {
select {
case _ = <-s.closeChan:
fmt.Println("Closing LLM Server")
return nil
}
}
}
func (s *Router) Stop(ctx context.Context) error {
s.closeChan <- true
s.started = false
return nil
}
func (s *Router) StartSession() (*Session, error) {
sid := utility.GenID()
session := &Session{}
s.mu.Lock()
s.sessions[sid] = session
s.mu.Unlock()
return session, nil
}
func (s *Router) Process(ctx context.Context, Chat *domain.ChatWithMessages) error {
s.closeChan <- true
s.started = false
return nil
}
+6
View File
@@ -0,0 +1,6 @@
package brain
type Session struct {
serverID string
chatID string
}