Documentation ¶
Index ¶
- Constants
- Variables
- type APIError
- type AccessTokenResponse
- type BaiduChatCompletionStream
- type BaiduChatRequest
- type BaiduChatResponse
- type BaiduTxt2ImgRequest
- type BaiduTxt2ImgResponse
- type Bloomz7b1ChatCompletionStream
- type Bloomz7b1Request
- type Bloomz7b1Response
- type Cache
- type ChatCompletionMessage
- type Client
- func (c *Client) ClearAccessToken(ctx context.Context)
- func (c *Client) CreateBaiduChatCompletion(ctx context.Context, request BaiduChatRequest) (response BaiduChatResponse, err error)
- func (c *Client) CreateBaiduChatCompletionStream(ctx context.Context, request BaiduChatRequest) (stream *BaiduChatCompletionStream, err error)
- func (c *Client) CreateBaiduTxt2Img(ctx context.Context, request BaiduTxt2ImgRequest) (response BaiduTxt2ImgResponse, err error)
- func (c *Client) CreateBgeLargeEnEmbedding(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
- func (c *Client) CreateBgeLargeZhEmbedding(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
- func (c *Client) CreateBloomz7b1ChatCompletion(ctx context.Context, request Bloomz7b1Request) (response Bloomz7b1Response, err error)
- func (c *Client) CreateBloomz7b1ChatCompletionStream(ctx context.Context, request Bloomz7b1Request) (stream *Bloomz7b1ChatCompletionStream, err error)
- func (c *Client) CreateCompletion(ctx context.Context, request CompletionRequest) (response CompletionResponse, err error)
- func (c *Client) CreateCompletionStream(ctx context.Context, request CompletionRequest) (stream *CompletionResponseStream, err error)
- func (c *Client) CreateEmbeddings(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
- func (c *Client) CreateErnieBot4ChatCompletion(ctx context.Context, request ErnieBot4Request) (response ErnieBot4Response, err error)
- func (c *Client) CreateErnieBot4ChatCompletionStream(ctx context.Context, request ErnieBot4Request) (stream *ErnireBot4ChatCompletionStream, err error)
- func (c *Client) CreateErnieBot8KChatCompletion(ctx context.Context, request ErnieBot8KRequest) (response ErnieBot8KResponse, err error)
- func (c *Client) CreateErnieBot8KChatCompletionStream(ctx context.Context, request ErnieBot8KRequest) (stream *ErnireBot8KChatCompletionStream, err error)
- func (c *Client) CreateErnieBotChatCompletion(ctx context.Context, request ErnieBotRequest) (response ErnieBotResponse, err error)
- func (c *Client) CreateErnieBotChatCompletionStream(ctx context.Context, request ErnieBotRequest) (stream *ErnireBotChatCompletionStream, err error)
- func (c *Client) CreateErnieBotTurboAIChatCompletion(ctx context.Context, request ErnieBotTurboAIRequest) (response ErnieBotTurboAIResponse, err error)
- func (c *Client) CreateErnieBotTurboAIChatCompletionStream(ctx context.Context, request ErnieBotTurboAIRequest) (stream *ErnireBotTurboAIChatCompletionStream, err error)
- func (c *Client) CreateErnieBotTurboChatCompletion(ctx context.Context, request ErnieBotTurboRequest) (response ErnieBotTurboResponse, err error)
- func (c *Client) CreateErnieBotTurboChatCompletionStream(ctx context.Context, request ErnieBotTurboRequest) (stream *ErnireBotChatCompletionStream, err error)
- func (c *Client) CreateErnieCustomPluginChatCompletion(ctx context.Context, request ErnieCustomPluginRequest) (response ErnieCustomPluginResponse, err error)
- func (c *Client) CreateErnieCustomPluginStreamChatCompletion(ctx context.Context, request ErnieCustomPluginRequest) (stream *ErnieCustomPluginStream, err error)
- func (c *Client) CreateImageStableDiffusionXL(ctx context.Context, request ImageRequest) (response ImageResponse, err error)
- func (c *Client) CreateImageVisualGLM(ctx context.Context, request ImageRequest) (response ImageResponse, err error)
- func (c *Client) CreateLlamaChatCompletion(ctx context.Context, request LlamaChatRequest) (response LlamaChatResponse, err error)
- func (c *Client) CreateLlamaChatCompletionStream(ctx context.Context, request LlamaChatRequest) (stream *LlamaChatCompletionStream, err error)
- func (c *Client) GetAccessToken(ctx context.Context) (*string, error)
- type ClientConfig
- type CompletionRequest
- type CompletionResponse
- type CompletionResponseStream
- type EmbeddingData
- type EmbeddingRequest
- type EmbeddingResponse
- type EmbeddingUsage
- type ErnieBot4Request
- type ErnieBot4Response
- type ErnieBot8KRequest
- type ErnieBot8KResponse
- type ErnieBotRequest
- type ErnieBotResponse
- type ErnieBotTurboAIRequest
- type ErnieBotTurboAIResponse
- type ErnieBotTurboRequest
- type ErnieBotTurboResponse
- type ErnieBotTurboUsage
- type ErnieCustomPluginRequest
- type ErnieCustomPluginResponse
- type ErnieCustomPluginStream
- type ErnieFunction
- type ErnieFunctionCall
- type ErnieFunctionExample
- type ErniePluginUsage
- type ErnieSearchInfo
- type ErnieSearchInfoResult
- type ErnieUsage
- type ErnireBot4ChatCompletionStream
- type ErnireBot8KChatCompletionStream
- type ErnireBotChatCompletionStream
- type ErnireBotTurboAIChatCompletionStream
- type ErnireBotTurboChatCompletionStream
- type ImageRequest
- type ImageResponse
- type LlamaChatCompletionStream
- type LlamaChatRequest
- type LlamaChatResponse
- type RequestError
Constants ¶
View Source
const ( MessageRoleUser = "user" MessageRoleAssistant = "assistant" MessageRoleFunction = "function" )
Variables ¶
View Source
var (
ErrChatCompletionStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateChatCompletionStream") //nolint:lll
)
View Source
var (
ErrTooManyEmptyStreamMessages = errors.New("stream has sent too many empty messages")
)
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct { RefreshToken string `json:"refresh_token"` ExpiresIn int `json:"expires_in"` SessionKey string `json:"session_key"` AccessToken string `json:"access_token"` Scope string `json:"scope"` SessionSecret string `json:"session_secret"` Error string `json:"error"` ErrorDescription string `json:"error_description"` }
type BaiduChatCompletionStream ¶ added in v1.0.4
type BaiduChatCompletionStream struct {
// contains filtered or unexported fields
}
type BaiduChatRequest ¶ added in v1.0.4
type BaiduChatRequest struct { Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream"` UserId string `json:"user_id"` Model string `json:"-"` }
type BaiduChatResponse ¶ added in v1.0.4
type BaiduChatResponse struct {
ErnieBotResponse
}
type BaiduTxt2ImgRequest ¶ added in v1.0.4
type BaiduTxt2ImgResponse ¶ added in v1.0.4
type Bloomz7b1ChatCompletionStream ¶
type Bloomz7b1ChatCompletionStream struct {
// contains filtered or unexported fields
}
type Bloomz7b1Request ¶
type Bloomz7b1Request struct { Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream"` UserId string `json:"user_id"` }
type Bloomz7b1Response ¶
type Bloomz7b1Response struct {
ErnieBotResponse
}
type ChatCompletionMessage ¶
type ChatCompletionMessage struct { Role string `json:"role"` Content string `json:"content"` Name string `json:"name,omitempty"` FunctionCall *ErnieFunctionCall `json:"function_call,omitempty"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
func NewClientWithConfig(config ClientConfig) *Client
func NewDefaultClient ¶
func (*Client) ClearAccessToken ¶ added in v1.0.8
func (*Client) CreateBaiduChatCompletion ¶ added in v1.0.4
func (c *Client) CreateBaiduChatCompletion( ctx context.Context, request BaiduChatRequest, ) (response BaiduChatResponse, err error)
func (*Client) CreateBaiduChatCompletionStream ¶ added in v1.0.4
func (c *Client) CreateBaiduChatCompletionStream( ctx context.Context, request BaiduChatRequest, ) (stream *BaiduChatCompletionStream, err error)
func (*Client) CreateBaiduTxt2Img ¶ added in v1.0.4
func (c *Client) CreateBaiduTxt2Img( ctx context.Context, request BaiduTxt2ImgRequest, ) (response BaiduTxt2ImgResponse, err error)
func (*Client) CreateBgeLargeEnEmbedding ¶ added in v1.0.5
func (c *Client) CreateBgeLargeEnEmbedding(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
func (*Client) CreateBgeLargeZhEmbedding ¶ added in v1.0.5
func (c *Client) CreateBgeLargeZhEmbedding(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
func (*Client) CreateBloomz7b1ChatCompletion ¶
func (c *Client) CreateBloomz7b1ChatCompletion( ctx context.Context, request Bloomz7b1Request, ) (response Bloomz7b1Response, err error)
func (*Client) CreateBloomz7b1ChatCompletionStream ¶
func (c *Client) CreateBloomz7b1ChatCompletionStream( ctx context.Context, request Bloomz7b1Request, ) (stream *Bloomz7b1ChatCompletionStream, err error)
func (*Client) CreateCompletion ¶ added in v1.0.5
func (c *Client) CreateCompletion( ctx context.Context, request CompletionRequest, ) (response CompletionResponse, err error)
func (*Client) CreateCompletionStream ¶ added in v1.0.5
func (c *Client) CreateCompletionStream( ctx context.Context, request CompletionRequest, ) (stream *CompletionResponseStream, err error)
func (*Client) CreateEmbeddings ¶
func (c *Client) CreateEmbeddings(ctx context.Context, request EmbeddingRequest) (response EmbeddingResponse, err error)
func (*Client) CreateErnieBot4ChatCompletion ¶ added in v1.0.5
func (c *Client) CreateErnieBot4ChatCompletion( ctx context.Context, request ErnieBot4Request, ) (response ErnieBot4Response, err error)
func (*Client) CreateErnieBot4ChatCompletionStream ¶ added in v1.0.5
func (c *Client) CreateErnieBot4ChatCompletionStream( ctx context.Context, request ErnieBot4Request, ) (stream *ErnireBot4ChatCompletionStream, err error)
func (*Client) CreateErnieBot8KChatCompletion ¶ added in v1.0.9
func (c *Client) CreateErnieBot8KChatCompletion( ctx context.Context, request ErnieBot8KRequest, ) (response ErnieBot8KResponse, err error)
func (*Client) CreateErnieBot8KChatCompletionStream ¶ added in v1.0.9
func (c *Client) CreateErnieBot8KChatCompletionStream( ctx context.Context, request ErnieBot8KRequest, ) (stream *ErnireBot8KChatCompletionStream, err error)
func (*Client) CreateErnieBotChatCompletion ¶
func (c *Client) CreateErnieBotChatCompletion( ctx context.Context, request ErnieBotRequest, ) (response ErnieBotResponse, err error)
func (*Client) CreateErnieBotChatCompletionStream ¶
func (c *Client) CreateErnieBotChatCompletionStream( ctx context.Context, request ErnieBotRequest, ) (stream *ErnireBotChatCompletionStream, err error)
func (*Client) CreateErnieBotTurboAIChatCompletion ¶ added in v1.0.9
func (c *Client) CreateErnieBotTurboAIChatCompletion( ctx context.Context, request ErnieBotTurboAIRequest, ) (response ErnieBotTurboAIResponse, err error)
func (*Client) CreateErnieBotTurboAIChatCompletionStream ¶ added in v1.0.9
func (c *Client) CreateErnieBotTurboAIChatCompletionStream( ctx context.Context, request ErnieBotTurboAIRequest, ) (stream *ErnireBotTurboAIChatCompletionStream, err error)
func (*Client) CreateErnieBotTurboChatCompletion ¶
func (c *Client) CreateErnieBotTurboChatCompletion( ctx context.Context, request ErnieBotTurboRequest, ) (response ErnieBotTurboResponse, err error)
func (*Client) CreateErnieBotTurboChatCompletionStream ¶
func (c *Client) CreateErnieBotTurboChatCompletionStream( ctx context.Context, request ErnieBotTurboRequest, ) (stream *ErnireBotChatCompletionStream, err error)
func (*Client) CreateErnieCustomPluginChatCompletion ¶ added in v1.0.4
func (c *Client) CreateErnieCustomPluginChatCompletion( ctx context.Context, request ErnieCustomPluginRequest, ) (response ErnieCustomPluginResponse, err error)
func (*Client) CreateErnieCustomPluginStreamChatCompletion ¶ added in v1.0.4
func (c *Client) CreateErnieCustomPluginStreamChatCompletion( ctx context.Context, request ErnieCustomPluginRequest, ) (stream *ErnieCustomPluginStream, err error)
func (*Client) CreateImageStableDiffusionXL ¶ added in v1.0.5
func (c *Client) CreateImageStableDiffusionXL(ctx context.Context, request ImageRequest) (response ImageResponse, err error)
func (*Client) CreateImageVisualGLM ¶ added in v1.0.5
func (c *Client) CreateImageVisualGLM(ctx context.Context, request ImageRequest) (response ImageResponse, err error)
func (*Client) CreateLlamaChatCompletion ¶
func (c *Client) CreateLlamaChatCompletion( ctx context.Context, request LlamaChatRequest, ) (response LlamaChatResponse, err error)
func (*Client) CreateLlamaChatCompletionStream ¶
func (c *Client) CreateLlamaChatCompletionStream( ctx context.Context, request LlamaChatRequest, ) (stream *LlamaChatCompletionStream, err error)
type ClientConfig ¶
type ClientConfig struct { AccessToken string ClientId string ClientSecret string BaseURL string HTTPClient *http.Client EmptyMessagesLimit uint Cache *Cache }
func DefaultConfig ¶
func DefaultConfig(accessToken string) ClientConfig
type CompletionRequest ¶ added in v1.0.5
type CompletionRequest struct { Model string `json:"-"` Prompt string `json:"prompt"` Stream bool `json:"stream,omitempty"` UserId string `json:"user_id,omitempty"` }
CompletionRequest 文本续写模型
type CompletionResponse ¶ added in v1.0.5
type CompletionResponseStream ¶ added in v1.0.5
type CompletionResponseStream struct {
// contains filtered or unexported fields
}
type EmbeddingData ¶
type EmbeddingRequest ¶
type EmbeddingResponse ¶
type EmbeddingResponse struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Data []EmbeddingData `json:"data"` Usage EmbeddingUsage `json:"usage"` APIError }
type EmbeddingUsage ¶
type ErnieBot4Request ¶ added in v1.0.5
type ErnieBot4Request struct { Messages []ChatCompletionMessage `json:"messages"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` Stream bool `json:"stream"` UserId string `json:"user_id,omitempty"` Functions []ErnieFunction `json:"functions,omitempty"` PenaltyScore float32 `json:"penalty_score,omitempty"` System string `json:"system,omitempty"` Stop []string `json:"stop,omitempty"` DisableSearch bool `json:"disable_search,omitempty"` EnableCitation bool `json:"enable_citation,omitempty"` }
type ErnieBot4Response ¶ added in v1.0.5
type ErnieBot4Response struct {
ErnieBotResponse
}
type ErnieBot8KRequest ¶ added in v1.0.9
type ErnieBot8KRequest struct { Messages []ChatCompletionMessage `json:"messages"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` Stream bool `json:"stream"` UserId string `json:"user_id,omitempty"` Functions []ErnieFunction `json:"functions,omitempty"` PenaltyScore float32 `json:"penalty_score,omitempty"` System string `json:"system,omitempty"` Stop []string `json:"stop,omitempty"` DisableSearch bool `json:"disable_search,omitempty"` EnableCitation bool `json:"enable_citation,omitempty"` }
type ErnieBot8KResponse ¶ added in v1.0.9
type ErnieBot8KResponse struct {
ErnieBotResponse
}
type ErnieBotRequest ¶
type ErnieBotRequest struct { Messages []ChatCompletionMessage `json:"messages"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"` Stream bool `json:"stream"` UserId string `json:"user_id,omitempty"` PenaltyScore float32 `json:"penalty_score,omitempty"` Functions []ErnieFunction `json:"functions,omitempty"` System string `json:"system,omitempty"` Stop []string `json:"stop,omitempty"` DisableSearch bool `json:"disable_search,omitempty"` EnableCitation bool `json:"enable_citation,omitempty"` }
type ErnieBotResponse ¶
type ErnieBotResponse struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` SentenceId int `json:"sentence_id"` IsEnd bool `json:"is_end"` IsTruncated bool `json:"is_truncated"` Result string `json:"result"` NeedClearHistory bool `json:"need_clear_history"` Usage ErnieUsage `json:"usage"` FunctionCall ErnieFunctionCall `json:"function_call"` BanRound int `json:"ban_round"` SearchInfo ErnieSearchInfo `json:"search_info"` APIError }
type ErnieBotTurboAIRequest ¶ added in v1.0.9
type ErnieBotTurboAIRequest struct { Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream"` UserId string `json:"user_id"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"` PenaltyScore float32 `json:"penalty_score,omitempty"` System string `json:"system,omitempty"` }
type ErnieBotTurboAIResponse ¶ added in v1.0.9
type ErnieBotTurboAIResponse struct {
ErnieBotTurboResponse
}
type ErnieBotTurboRequest ¶
type ErnieBotTurboRequest struct { Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream"` UserId string `json:"user_id"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"` PenaltyScore float32 `json:"penalty_score,omitempty"` System string `json:"system,omitempty"` }
type ErnieBotTurboResponse ¶
type ErnieBotTurboResponse struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` SentenceId int `json:"sentence_id"` IsEnd bool `json:"is_end"` IsTruncated bool `json:"is_truncated"` Result string `json:"result"` NeedClearHistory bool `json:"need_clear_history"` Usage ErnieBotTurboUsage `json:"usage"` BanRound int `json:"ban_round"` APIError }
type ErnieBotTurboUsage ¶ added in v1.0.9
type ErnieCustomPluginRequest ¶ added in v1.0.4
type ErnieCustomPluginRequest struct { PluginName string `json:"-"` Query string `json:"query"` Stream bool `json:"stream"` Plugins []string `json:"plugins"` LLM any `json:"llm,omitempty"` InputVariables any `json:"input_variables,omitempty"` History []ChatCompletionMessage `json:"history,omitempty"` Verbose bool `json:"verbose,omitempty"` FileUrl string `json:"fileurl,omitempty"` }
type ErnieCustomPluginResponse ¶ added in v1.0.4
type ErnieCustomPluginResponse struct { LogId int64 `json:"log_id"` Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` SentenceId int `json:"sentence_id"` IsEnd bool `json:"is_end"` Result string `json:"result"` NeedClearHistory bool `json:"need_clear_history"` BanRound int `json:"ban_round"` Usage ErnieUsage `json:"usage"` MetaInfo any `json:"meta_info"` APIError }
type ErnieCustomPluginStream ¶ added in v1.0.4
type ErnieCustomPluginStream struct {
// contains filtered or unexported fields
}
type ErnieFunction ¶ added in v1.0.5
type ErnieFunction struct { Name string `json:"name"` Description string `json:"description"` Parameters any `json:"parameters"` Responses any `json:"responses"` Examples []ErnieFunctionExample `json:"examples,omitempty"` }
type ErnieFunctionCall ¶ added in v1.0.5
type ErnieFunctionExample ¶ added in v1.0.5
type ErnieFunctionExample struct { Role string `json:"role"` Content string `json:"content"` Name string `json:"name,omitempty"` FunctionCall ErnieFunctionCall `json:"function_call,omitempty"` }
type ErniePluginUsage ¶ added in v1.0.5
type ErnieSearchInfo ¶ added in v1.0.9
type ErnieSearchInfo struct { IsBeset bool `json:"is_beset"` ReWrite string `json:"re_write"` SearchResults []ErnieSearchInfoResult `json:"search_results"` }
type ErnieSearchInfoResult ¶ added in v1.0.9
type ErnieUsage ¶
type ErnieUsage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` Plugins []ErniePluginUsage `json:"plugins"` }
type ErnireBot4ChatCompletionStream ¶ added in v1.0.5
type ErnireBot4ChatCompletionStream struct {
// contains filtered or unexported fields
}
type ErnireBot8KChatCompletionStream ¶ added in v1.0.9
type ErnireBot8KChatCompletionStream struct {
// contains filtered or unexported fields
}
type ErnireBotChatCompletionStream ¶
type ErnireBotChatCompletionStream struct {
// contains filtered or unexported fields
}
type ErnireBotTurboAIChatCompletionStream ¶ added in v1.0.9
type ErnireBotTurboAIChatCompletionStream struct {
// contains filtered or unexported fields
}
type ErnireBotTurboChatCompletionStream ¶
type ErnireBotTurboChatCompletionStream struct {
// contains filtered or unexported fields
}
type ImageRequest ¶ added in v1.0.5
type ImageResponse ¶ added in v1.0.5
type LlamaChatCompletionStream ¶
type LlamaChatCompletionStream struct {
// contains filtered or unexported fields
}
type LlamaChatRequest ¶
type LlamaChatRequest struct { Messages []ChatCompletionMessage `json:"messages"` Stream bool `json:"stream"` UserId string `json:"user_id"` Model string `json:"-"` }
type LlamaChatResponse ¶
type LlamaChatResponse struct {
ErnieBotResponse
}
type RequestError ¶
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error
Source Files ¶
- baidu_chat.go
- baidu_chat_stream.go
- baidu_txt2img.go
- bge_large_en.go
- bge_large_zh.go
- bloomz_7b1.go
- bloomz_7b1_stream.go
- cache.go
- client.go
- completion.go
- completion_stream.go
- config.go
- embedding.go
- ernie_bot.go
- ernie_bot_4.go
- ernie_bot_4_stream.go
- ernie_bot_8k.go
- ernie_bot_8k_stream.go
- ernie_bot_stream.go
- ernie_bot_turbo.go
- ernie_bot_turbo_ai.go
- ernie_bot_turbo_ai_stream.go
- ernie_bot_turbo_stream.go
- ernie_custom_plugin.go
- ernie_custom_plugin_stream.go
- error.go
- image.go
- llama_chat.go
- llama_chat_stream.go
- stream.go
- stream_reader.go
Click to show internal directories.
Click to hide internal directories.