prise en charge des outils + weather
This commit is contained in:
1 parent
a36f1231cd
commit
0a6ffab050
14 files changed
+623
-113
No files matched your search
+9
-44
@@ -11,11 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/auth/password"
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/database"
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/file"
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/llm"
|
||||
"trankilou.fr/lassistanoque/backend/internal/adapter/security"
|
||||
"trankilou.fr/lassistanoque/backend/internal/brain"
|
||||
"trankilou.fr/lassistanoque/backend/internal/http"
|
||||
"trankilou.fr/lassistanoque/backend/internal/service/agent"
|
||||
@@ -46,60 +41,30 @@ func newServeCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
func runServe() {
|
||||
// database
|
||||
db, err := database.GetDatabase()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
err = db.Migrate()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// storage
|
||||
store, err := file.GetStorageProvider(db.FileRepository())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Adapters
|
||||
tokenManager := security.NewJwtTokenManager(12*time.Hour, 7*24*time.Hour, "lassistanoque")
|
||||
pwdAuth := password.NewPasswordAuthenticator(tokenManager, db.UserRepository())
|
||||
llmEngine := llm.NewAnyLLMEngine()
|
||||
repoUser := db.UserRepository()
|
||||
repoProvider := db.ProviderRepository()
|
||||
repoAgent := db.AgentRepository()
|
||||
repoChat := db.ChatRepository()
|
||||
defer Close()
|
||||
|
||||
// services
|
||||
authService := auth.NewService(
|
||||
db.SettingsRepository(),
|
||||
db.UserRepository(),
|
||||
map[string]auth.Authenticator{
|
||||
"password": pwdAuth,
|
||||
},
|
||||
)
|
||||
userService := user.NewService(repoUser)
|
||||
storageService := storage.NewService(store)
|
||||
providerService := provider.NewService(repoProvider, repoUser, llmEngine)
|
||||
agentService := agent.NewService(repoAgent, repoUser)
|
||||
chatService := chat.NewService(repoUser, repoAgent, repoProvider, repoChat, llmEngine)
|
||||
authService := auth.NewService(GetSettingsRepository(), GetUserRepository(), GetAuthenticators())
|
||||
userService := user.NewService(GetUserRepository())
|
||||
storageService := storage.NewService(GetStorageProvider())
|
||||
providerService := provider.NewService(GetProviderRepository(), GetUserRepository(), GetLLMEngine())
|
||||
agentService := agent.NewService(GetAgentRepository(), GetUserRepository())
|
||||
chatService := chat.NewService(GetUserRepository(), GetAgentRepository(), GetProviderRepository(), GetChatRepository(), GetLLMEngine())
|
||||
|
||||
// http server
|
||||
httpRouter := http.NewRouter(http.Dependencies{
|
||||
StorageService: storageService,
|
||||
AuthService: authService,
|
||||
UserService: userService,
|
||||
TokenManager: tokenManager,
|
||||
ProviderService: providerService,
|
||||
AgentService: agentService,
|
||||
ChatService: chatService,
|
||||
TokenManager: GetTokenManager(),
|
||||
})
|
||||
|
||||
brainRouter := brain.NewRouter(brain.Dependencies{
|
||||
ChatRepository: db.ChatRepository(),
|
||||
ChatRepository: GetChatRepository(),
|
||||
})
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
Reference in new issue
Block a user