Documentation ¶
Index ¶
- Constants
- func ChatCompletion(ctx context.Context, request openai.ChatCompletionRequest, retry ...int) (openai.ChatCompletionResponse, error)
- func ChatCompletionStream(ctx context.Context, request openai.ChatCompletionRequest, retry ...int) (responseChan chan openai.ChatCompletionStreamResponse, err error)
- func GenImage(ctx context.Context, model, prompt string) (url string, err error)
- func GenImageBase64(ctx context.Context, model, prompt string, retry ...int) (string, error)
- func Init(ctx context.Context, model string)
- func MidjourneyProxy(ctx context.Context, prompt string) (*model.Image, error)
- func MidjourneyProxyBlend(ctx context.Context, midjourneyProxyBlendReq *model.MidjourneyProxyBlendReq) (*model.MidjourneyProxyBlendRes, error)
- func MidjourneyProxyChange(ctx context.Context, midjourneyProxyChangeReq *model.MidjourneyProxyChangeReq) (*model.MidjourneyProxyChangeRes, error)
- func MidjourneyProxyChanges(ctx context.Context, prompt string) (*model.Image, error)
- func MidjourneyProxyDescribe(ctx context.Context, ...) (*model.MidjourneyProxyDescribeRes, error)
- func MidjourneyProxyFetch(ctx context.Context, taskId string) (imageInfo *model.Image, midjourneyProxyFetchRes *model.MidjourneyProxyFetchRes, ...)
- func MidjourneyProxyImagine(ctx context.Context, ...) (*model.MidjourneyProxyImagineRes, error)
- func NumTokensFromMessages(messages []openai.ChatCompletionMessage, model string) (numTokens int, err error)
- func NumTokensFromString(text, model string) (int, error)
- func SparkStream(ctx context.Context, model, uid string, text []Text, ...)
- type Chat
- type Choices
- type ErnieBotMessage
- type ErnieBotReq
- type ErnieBotRes
- type GetAccessTokenRes
- type Header
- type Input
- type Message
- type Parameter
- type Payload
- type QwenChatCompletionMessage
- type QwenChatCompletionReq
- type QwenChatCompletionRes
- type SparkReq
- type SparkRes
- type Text
- type Usage
Constants ¶
View Source
const ACCESS_TOKEN_KEY = "sdk:baidu:access_token:%s"
View Source
const RoleAssistant = "assistant"
View Source
const RoleUser = "user"
Variables ¶
This section is empty.
Functions ¶
func ChatCompletion ¶
func ChatCompletionStream ¶
func GenImageBase64 ¶
func MidjourneyProxy ¶
func MidjourneyProxyBlend ¶
func MidjourneyProxyBlend(ctx context.Context, midjourneyProxyBlendReq *model.MidjourneyProxyBlendReq) (*model.MidjourneyProxyBlendRes, error)
func MidjourneyProxyChange ¶
func MidjourneyProxyChange(ctx context.Context, midjourneyProxyChangeReq *model.MidjourneyProxyChangeReq) (*model.MidjourneyProxyChangeRes, error)
func MidjourneyProxyChanges ¶
func MidjourneyProxyDescribe ¶
func MidjourneyProxyDescribe(ctx context.Context, midjourneyProxyDescribeReq *model.MidjourneyProxyDescribeReq) (*model.MidjourneyProxyDescribeRes, error)
func MidjourneyProxyFetch ¶
func MidjourneyProxyImagine ¶
func MidjourneyProxyImagine(ctx context.Context, midjourneyProxyImagineReq *model.MidjourneyProxyImagineReq) (*model.MidjourneyProxyImagineRes, error)
func NumTokensFromMessages ¶
func NumTokensFromString ¶
Types ¶
type ErnieBotMessage ¶
type ErnieBotReq ¶
type ErnieBotReq struct {
Messages []ErnieBotMessage `json:"messages"`
}
type ErnieBotRes ¶
type ErnieBotRes struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` Result string `json:"result"` IsTruncated bool `json:"is_truncated"` NeedClearHistory bool `json:"need_clear_history"` Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } `json:"usage"` ErrorCode int `json:"error_code"` ErrorMsg string `json:"error_msg"` }
func ErnieBot ¶
func ErnieBot(ctx context.Context, model string, messages []ErnieBotMessage, retry ...int) (res *ErnieBotRes, err error)
type GetAccessTokenRes ¶
type GetAccessTokenRes struct { RefreshToken string `json:"refresh_token"` ExpiresIn int64 `json:"expires_in"` SessionKey string `json:"session_key"` AccessToken string `json:"access_token"` Scope string `json:"scope"` SessionSecret string `json:"session_secret"` ErrorDescription string `json:"error_description"` Error string `json:"error"` }
type Input ¶
type Input struct { Prompt string `json:"prompt"` History []QwenChatCompletionMessage `json:"history"` }
type QwenChatCompletionReq ¶
type QwenChatCompletionRes ¶
type QwenChatCompletionRes struct { Output struct { FinishReason string `json:"finish_reason"` Text string `json:"text"` } `json:"output"` Usage struct { OutputTokens int `json:"output_tokens"` InputTokens int `json:"input_tokens"` } `json:"usage"` RequestId string `json:"request_id"` Code string `json:"code"` Message string `json:"message"` }
func QwenChatCompletion ¶
func QwenChatCompletion(ctx context.Context, model string, messages []QwenChatCompletionMessage, retry ...int) (res *QwenChatCompletionRes, err error)
type SparkRes ¶
type Text ¶
type Text struct { // req res Role string `json:"role"` Content string `json:"content"` // Choices Index int `json:"index,omitempty"` // Usage QuestionTokens int `json:"question_tokens,omitempty"` PromptTokens int `json:"prompt_tokens,omitempty"` CompletionTokens int `json:"completion_tokens,omitempty"` TotalTokens int `json:"total_tokens,omitempty"` }
Click to show internal directories.
Click to hide internal directories.