Agent par défaut
This commit is contained in:
1 parent
cf10b9073b
commit
f74e4d1043
24 files changed
+385
-37
No files matched your search
@@ -0,0 +1,58 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package llmserver
|
||||
|
||||
type Session struct {
|
||||
server string
|
||||
}
|
||||
Reference in new issue
Block a user