mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
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:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"}},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user