add better res
This commit is contained in:
+3
-2
@@ -50,11 +50,12 @@ func (client Client) GenerateContent(message string) (string, error) {
|
|||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
body, err := io.ReadAll(res.Body)
|
||||||
|
|
||||||
if res.StatusCode != 200 {
|
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 {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to read the llm response body: %w", err)
|
return "", fmt.Errorf("failed to read the llm response body: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"hal/env"
|
"hal/env"
|
||||||
"hal/handlers"
|
"hal/handlers"
|
||||||
|
"hal/llm"
|
||||||
|
|
||||||
discordbot "github.com/bwmarrin/discordgo"
|
discordbot "github.com/bwmarrin/discordgo"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
@@ -35,6 +36,15 @@ func main() {
|
|||||||
return
|
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.
|
// Wait here until CTRL-C or other term signal is received.
|
||||||
sc := make(chan os.Signal, 1)
|
sc := make(chan os.Signal, 1)
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||||
|
|||||||
Reference in New Issue
Block a user