From c7a9c78ea3b846e947267a60282b87ba3123c8ac Mon Sep 17 00:00:00 2001 From: unintendedfraud Date: Thu, 25 Dec 2025 18:35:52 +0100 Subject: [PATCH] add better res --- llm/client.go | 5 +++-- main.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/llm/client.go b/llm/client.go index a9f3fe8..41ca3c6 100644 --- a/llm/client.go +++ b/llm/client.go @@ -50,11 +50,12 @@ func (client Client) GenerateContent(message string) (string, error) { } defer res.Body.Close() + body, err := io.ReadAll(res.Body) + if res.StatusCode != 200 { - return "", fmt.Errorf("LLM returned status code: [%d]", res.StatusCode) + return "", fmt.Errorf("LLM returned status code [%d]: %s", res.StatusCode, string(body)) } - body, err := io.ReadAll(res.Body) if err != nil { return "", fmt.Errorf("failed to read the llm response body: %w", err) } diff --git a/main.go b/main.go index 8aa07ad..d2a7c7c 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "hal/env" "hal/handlers" + "hal/llm" discordbot "github.com/bwmarrin/discordgo" "github.com/joho/godotenv" @@ -35,6 +36,15 @@ func main() { return } + // --- + llmClient := llm.NewClient(&env) + res, err := llmClient.GenerateContent("Yo poto") + if err != nil { + panic(err) + } + fmt.Println(res) + // --- + // Wait here until CTRL-C or other term signal is received. sc := make(chan os.Signal, 1) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)