feat(llm): add LLM integration instructions and handler
* Serve LLM instructions at `/llm` * Include markdown content for memory instructions * Update README with LLM integration details * Add tests for LLM instructions handler * Modify database migrations to use GUIDs for thoughts and projects
This commit is contained in:
@@ -114,6 +114,7 @@ func routes(logger *slog.Logger, cfg *config.Config, db *store.DB, provider ai.P
|
||||
mcpHandler := mcpserver.New(cfg.MCP, toolSet)
|
||||
mux.Handle(cfg.MCP.Path, auth.Middleware(cfg.Auth, keyring, logger)(mcpHandler))
|
||||
mux.HandleFunc("/favicon.ico", serveFavicon)
|
||||
mux.HandleFunc("/llm", serveLLMInstructions)
|
||||
|
||||
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
22
internal/app/llm.go
Normal file
22
internal/app/llm.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
amcsllm "git.warky.dev/wdevs/amcs/llm"
|
||||
)
|
||||
|
||||
func serveLLMInstructions(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/llm" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/markdown; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method == http.MethodHead {
|
||||
return
|
||||
}
|
||||
_, _ = w.Write(amcsllm.MemoryInstructions)
|
||||
}
|
||||
29
internal/app/llm_test.go
Normal file
29
internal/app/llm_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
amcsllm "git.warky.dev/wdevs/amcs/llm"
|
||||
)
|
||||
|
||||
func TestServeLLMInstructions(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "/llm", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
serveLLMInstructions(rec, req)
|
||||
|
||||
res := rec.Result()
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", res.StatusCode, http.StatusOK)
|
||||
}
|
||||
if got := res.Header.Get("Content-Type"); got != "text/markdown; charset=utf-8" {
|
||||
t.Fatalf("content-type = %q, want %q", got, "text/markdown; charset=utf-8")
|
||||
}
|
||||
if body := rec.Body.String(); body != string(amcsllm.MemoryInstructions) {
|
||||
t.Fatalf("body = %q, want embedded instructions", body)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user