Первоначальный коммит

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
poignatov-home
2026-02-08 17:01:36 +03:00
commit bad198ce29
217 changed files with 57075 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package server
import (
"net/http"
"play-life-llm/internal/handler"
"play-life-llm/internal/ollama"
"play-life-llm/internal/tavily"
"github.com/gorilla/mux"
)
// Config holds server and client configuration.
type Config struct {
OllamaHost string
TavilyAPIKey string
DefaultModel string
}
// NewRouter returns an HTTP router with /health and /ask registered.
func NewRouter(cfg Config) http.Handler {
ollamaClient := ollama.NewClient(cfg.OllamaHost)
tavilyClient := tavily.NewClient(cfg.TavilyAPIKey)
askHandler := &handler.AskHandler{
Ollama: ollamaClient,
Tavily: tavilyClient,
DefaultModel: cfg.DefaultModel,
}
r := mux.NewRouter()
r.HandleFunc("/health", handler.Health).Methods(http.MethodGet)
r.Handle("/ask", askHandler).Methods(http.MethodPost)
return r
}