fix(memory): fix LLMClient parameter mismatch and add nil logger check

- Update LLMClient test to match NewLLMClient signature by passing nil logger
- Add nil check for logger in NewLLMClient to prevent panic, defaulting to slog.Default()
This commit is contained in:
BBQ
2026-02-01 17:52:18 +08:00
parent 50e9d48cef
commit d12092870f
8 changed files with 45 additions and 4 deletions
+3
View File
@@ -21,6 +21,9 @@ type LLMClient struct {
}
func NewLLMClient(log *slog.Logger, baseURL, apiKey, model string, timeout time.Duration) *LLMClient {
if log == nil {
log = slog.Default()
}
if baseURL == "" {
baseURL = "https://api.openai.com/v1"
}
+1 -1
View File
@@ -20,7 +20,7 @@ func TestLLMClientExtract(t *testing.T) {
}))
defer server.Close()
client := NewLLMClient(server.URL, "test-key", "gpt-4.1-nano-2025-04-14", 0)
client := NewLLMClient(nil, server.URL, "test-key", "gpt-4.1-nano-2025-04-14", 0)
resp, err := client.Extract(context.Background(), ExtractRequest{
Messages: []Message{{Role: "user", Content: "hi"}},
})