This commit is contained in:
asrul10
2023-12-19 09:30:22 +07:00
parent ae90ef6cfb
commit 5141cb69a3

View File

@@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@@ -88,7 +88,7 @@ func (gpt3 *Gpt3) loadApiKey() bool {
if _, err := os.Stat(apiKeyFile); os.IsNotExist(err) { if _, err := os.Stat(apiKeyFile); os.IsNotExist(err) {
return false return false
} }
apiKey, err := ioutil.ReadFile(apiKeyFile) apiKey, err := os.ReadFile(apiKeyFile)
if err != nil { if err != nil {
return false return false
} }
@@ -144,7 +144,7 @@ func (gpt3 *Gpt3) Completions(ask string) string {
if err != nil { if err != nil {
panic(err) panic(err)
} }
req.Body = ioutil.NopCloser(bytes.NewBuffer(payloadJson)) req.Body = io.NopCloser(bytes.NewBuffer(payloadJson))
client := &http.Client{} client := &http.Client{}
resp, err := client.Do(req) resp, err := client.Do(req)
@@ -153,7 +153,7 @@ func (gpt3 *Gpt3) Completions(ask string) string {
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
panic(err) panic(err)
} }