From 4fb1f254686132588583ba14f6371cd52fa0616d Mon Sep 17 00:00:00 2001 From: Elias Kohout Date: Mon, 20 Jan 2025 21:20:23 +0100 Subject: [PATCH] clean up summarizer function --- src/internal/util/summary.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/internal/util/summary.go b/src/internal/util/summary.go index a6220f8..d474480 100644 --- a/src/internal/util/summary.go +++ b/src/internal/util/summary.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "os" ) @@ -62,25 +62,25 @@ func Summarize(text string) (string, error) { defer resp.Body.Close() // Read the response - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return "", err } - - // Unmarshal the JSON response + + // Unmarshal the JSON response var response Response err = json.Unmarshal(body, &response) if err != nil { - return "", err + return "", err } // Extract and print the content - var content string + var content string if len(response.Choices) > 0 { content = response.Choices[0].Message.Content } else { - return "", errors.New("could not find content in response") + return "", errors.New("could not find content in response") } - return content, nil + return content, nil }