Files
lassistanoque/backend/internal/llmserver/server.go
T
2026-09-07 21:04:48 +02:00

59 lines
979 B
Go

package llmserver
import (
"context"
"fmt"
"sync"
"trankilou.fr/lassistanoque/backend/internal/utility"
)
type Dependencies struct {
}
type LLMServer struct {
started bool
mu sync.Mutex
sessions map[string]*Session // running sessions
newSessionChan chan string
closeChan chan bool
}
func NewLLMServer(deps Dependencies) *LLMServer {
return &LLMServer{
started: true,
sessions: make(map[string]*Session),
newSessionChan: make(chan string),
closeChan: make(chan bool),
}
}
func (s *LLMServer) Start() error {
for {
select {
case _ = <-s.closeChan:
fmt.Println("Closing LLM Server")
return nil
}
}
}
func (s *LLMServer) Stop(ctx context.Context) error {
s.closeChan <- true
s.started = false
return nil
}
func (s *LLMServer) StartSession() (*Session, error) {
sid := utility.GenID()
session := &Session{}
s.mu.Lock()
s.sessions[sid] = session
s.mu.Unlock()
return session, nil
}