Ajout de SEARXNG pour les recherches web
This commit is contained in:
1 parent
87eeb41364
commit
345129c7bf
30 files changed
+919
-166
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package gateway
|
||||
|
||||
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
|
||||
}
|
||||
Reference in new issue
Block a user