Ajout de SEARXNG pour les recherches web

This commit is contained in:
fabien committed 2026-10-05 19:05:24 +02:00
1 parent 87eeb41364
commit 345129c7bf
30 files changed
+919 -166

No files matched your search

+19 -3
View File
@@ -3,9 +3,11 @@ package chat
import (
"context"
_ "embed"
"log/slog"
"sync"
"trankilou.fr/lassistanoque/backend/internal/domain"
"trankilou.fr/lassistanoque/backend/internal/service/tool"
)
//go:embed system_prompt.md
@@ -20,6 +22,7 @@ type ChatSession struct {
modelID string
messages []*domain.Message
llmEngine domain.LLMEngine
toolService *tool.Service
repoChat domain.ChatRepository
subscribers []domain.StreamCallback
mu sync.Mutex
@@ -30,7 +33,7 @@ func (s *ChatSession) run(ctx context.Context) error {
params := &domain.LLMParams{}
tools := make([]*domain.ToolDefinition, 0)
for _, t := range allTools {
for _, t := range s.toolService.GetAllToolImpl() {
tools = append(tools, t.Definition(ctx))
}
params.Tools = tools
@@ -76,8 +79,21 @@ func (s *ChatSession) run(ctx context.Context) error {
continue_loop = true
for _, tc := range msg.ToolCalls {
tool := GetTool(tc.Function.Name)
output, err := tool.Execute(ctx, []byte(tc.Function.Arguments))
toolImpl := s.toolService.GetToolImpl(tc.Function.Name)
slog.Info("Execute tool", "name", tc.Function.Name, "impl", toolImpl)
toolRecord, err := s.toolService.GetToolByName(s.userID, s.teamID, toolImpl.Name())
if err != nil {
slog.Info("Execute tool", "error", err)
toolResponse := &domain.Message{
ChatID: s.chatID,
TeamID: s.teamID,
ToolCallID: tc.ID,
Role: string(domain.RoleTool),
Content: "ERROR: " + err.Error(),
}
s.repoChat.CreateChatMessage(s.userID, toolResponse)
}
output, err := toolImpl.Execute(ctx, []byte(tc.Function.Arguments), toolRecord.Configuration)
var toolResponse *domain.Message
if err != nil {
toolResponse = &domain.Message{