baidu

package
v0.0.0-...-ed23b36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaiduClient

type BaiduClient struct {
	// contains filtered or unexported fields
}

func NewBaiduClient

func NewBaiduClient(key, secret string) *BaiduClient

func (*BaiduClient) Close

func (bc *BaiduClient) Close()

func (*BaiduClient) Complete

func (bc *BaiduClient) Complete(text string) (*ErnieBotResponse, error)

func (*BaiduClient) GetAccessToken

func (bc *BaiduClient) GetAccessToken() string

func (*BaiduClient) RefreshToken

func (bc *BaiduClient) RefreshToken()

RefreshToken periodically refreshes the access token

type Credentials

type Credentials struct {
	// contains filtered or unexported fields
}

type ErnieBotResponse

type ErnieBotResponse struct {
	ID               string                 `json:"id"`
	Object           string                 `json:"object"`
	Created          int64                  `json:"created"`
	Result           string                 `json:"result"`
	IsTruncated      bool                   `json:"is_truncated"`
	NeedClearHistory bool                   `json:"need_clear_history"`
	Usage            map[string]interface{} `json:"usage"`
}

ErnieBotResponse represents the response from ERNIE Bot

type Request

type Request struct {
	Messages []UserMessage `json:"messages"`
}

Update Request structure to use UserMessage

type UserMessage

type UserMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

UserMessage represents the user message structure for the Baidu API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL