yxw21 / chatgpt

chatgpt api
9 stars 0 forks source link

An error occurred #1

Closed helloxz closed 1 year ago

helloxz commented 1 year ago

Based on the example you provided, the following error occurred:

NewSessionWithCredential not declared by package chatgptcompilerUndeclaredImportedName

helloxz commented 1 year ago

This is my code:

package controller

import (
    "fmt"

    "github.com/gin-gonic/gin"
    "github.com/yxw21/chatgpt"
)

func NewChat(c *gin.Context) {
    chat := chatgpt.NewChat(chatgpt.NewSessionWithCredential("xxx", "xxx", "xxx").AutoRefresh())
    res, err := chat.Send("hi")
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(res.Message.Content.Parts)
}
yxw21 commented 1 year ago

The readme was wrong, updated.