baidu

package
v0.0.0-...-b9c356b Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: AGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CensorTextConclusionTypePass      = 1 // 合规
	CensorTextConclusionTypeIllegal   = 2 // 不合规
	CensorTextConclusionTypeSuspected = 3 // 疑似
	CensorTextConclusionTypeFail      = 4 // 失败
)

审核结果

View Source
const (
	WenXinERNIE4_0_8K = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro"
	WenXinERNIE3_5_8K = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions"
)

文心一言请求接口

View Source
const AccessTokenUrl = "https://aip.baidubce.com/oauth/2.0/token"
View Source
const CensorTextURL = "https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined"
View Source
const TransTextURL = "https://aip.baidubce.com/rpc/2.0/mt/texttrans/v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type CensorTextParams

type CensorTextParams struct {
	Text   string `json:"text"`
	UserId string `json:"userId"`
}

type CensorTextResponse

type CensorTextResponse struct {
	LogId          string                        `json:"log_id"`
	ErrorMsg       string                        `json:"error_msg"`
	ErrorCode      string                        `json:"error_code"`
	Conclusion     string                        `json:"conclusion"`
	ConclusionType int                           `json:"conclusionType"` // 1.合规,2.不合规,3.疑似,4.审核失败
	Data           []*CensorTextResponseDataItem `json:"data"`
}

type CensorTextResponseDataHitsItem

type CensorTextResponseDataHitsItem struct {
	Probability       string      `json:"probability"`
	DatasetName       string      `json:"datasetName"`
	Words             []string    `json:"words"`
	Details           interface{} `json:"details"`
	ModelHitPositions interface{} `json:"modelHitPositions"`
	WordHitPositions  interface{} `json:"wordHitPositions"`
}

type CensorTextResponseDataItem

type CensorTextResponseDataItem struct {
	Type    int                               `json:"type"`
	SubType int                               `json:"subType"`
	Msg     string                            `json:"msg"`
	Hits    []*CensorTextResponseDataHitsItem `json:"hits"`
}

type Client

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

Client 客户端

func Instance

func Instance() *Client

Instance 单例

func (*Client) GetConfig

func (c *Client) GetConfig(feature string) (configData *Config, err error)

GetConfig 获取GetConfig

type Config

type Config struct {
	entity.ConfigBaidu
	AccessToken         string
	AccessTokenExpireIn int64
}

type TransTextParams

type TransTextParams struct {
	From string `json:"from"`
	To   string `json:"to"`
	Q    string `json:"q"`
}

type TransTextResponse

type TransTextResponse struct {
	LogId     string                   `json:"log_id"`
	Result    *TransTextResponseResult `json:"result"`
	ErrorMsg  string                   `json:"error_msg"`
	ErrorCode string                   `json:"error_code"`
}

type TransTextResponseResult

type TransTextResponseResult struct {
	From        string                          `json:"from"`
	To          string                          `json:"to"`
	TransResult []*TransTextResponseTransResult `json:"trans_result"`
}

type TransTextResponseTransResult

type TransTextResponseTransResult struct {
	Src string `json:"src"`
	Dst string `json:"dst"`
}

type WenXinChatCompletionCallbackFunc

type WenXinChatCompletionCallbackFunc func(originContent string, contentObj *WenXinChatCompletionResponse) error

type WenXinChatCompletionParams

type WenXinChatCompletionParams struct {
	Model    string
	Messages WenXinChatCompletionParamsMessages
}

type WenXinChatCompletionParamsMessageItem

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

type WenXinChatCompletionParamsMessages

type WenXinChatCompletionParamsMessages []*WenXinChatCompletionParamsMessageItem

type WenXinChatCompletionRequestParams

type WenXinChatCompletionRequestParams struct {
	Messages        WenXinChatCompletionParamsMessages `json:"messages"`
	MaxOutputTokens int                                `json:"max_output_tokens"`
	Stream          bool                               `json:"stream"`
}

type WenXinChatCompletionResponse

type WenXinChatCompletionResponse struct {
	Id      string                                    `json:"id"`
	Object  string                                    `json:"object"`
	Created int                                       `json:"created"`
	Choices WenXinChatCompletionResponseChoices       `json:"choices"`
	Usage   *WenXinChatCompletionResponseChoicesUsage `json:"usage"`
}

type WenXinChatCompletionResponseChoices

type WenXinChatCompletionResponseChoices []*WenXinChatCompletionResponseChoicesItem

type WenXinChatCompletionResponseChoicesItem

type WenXinChatCompletionResponseChoicesItem struct {
	Index        int                                             `json:"index"`
	Message      *WenXinChatCompletionResponseChoicesItemMessage `json:"message"`
	Delta        *WenXinChatCompletionResponseChoicesItemMessage `json:"delta"`
	FinishReason string                                          `json:"finish_reason"`
}

type WenXinChatCompletionResponseChoicesItemMessage

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

type WenXinChatCompletionResponseChoicesUsage

type WenXinChatCompletionResponseChoicesUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type WenXinChatCompletionResponseError

type WenXinChatCompletionResponseError struct {
	Error *WenXinChatCompletionResponseErrorData `json:"error"`
}

type WenXinChatCompletionResponseErrorData

type WenXinChatCompletionResponseErrorData struct {
	Message string      `json:"message"`
	Type    string      `json:"type"`
	Param   interface{} `json:"param"`
	Code    string      `json:"code"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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