Documentation ¶
Index ¶
- Constants
- Variables
- type Annotation
- type Assistant
- type AssistantCreateRequest
- type AssistantDeleteResponse
- type AssistantFile
- type AssistantFileListResponse
- type AssistantFilesCreateRequest
- type AssistantFilesCreateResponse
- type AssistantListOption
- type AssistantListResponse
- type AssistantRetrieveResponse
- type AsstMessage
- type BaseResp
- type BotSetting
- type CallFunction
- type CallRetrieval
- type ChatCompletionProRequest
- type ChatCompletionProResponse
- type ChatCompletionProStream
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatCompletionStream
- type ChatMessageChoice
- type ChatMessageProChoice
- type Client
- func (c *Client) CreateAssistantFiles(ctx context.Context, request *AssistantFilesCreateRequest) (*AssistantFilesCreateResponse, error)
- func (c *Client) CreateAssistants(ctx context.Context, request *AssistantCreateRequest) (*Assistant, error)
- func (c *Client) CreateCompletion(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionResponse, error)
- func (c *Client) CreateCompletionPro(ctx context.Context, request *ChatCompletionProRequest, ...) (*ChatCompletionProResponse, error)
- func (c *Client) CreateCompletionProStream(ctx context.Context, request *ChatCompletionProRequest, ...) (*ChatCompletionProStream, error)
- func (c *Client) CreateCompletionStream(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionStream, error)
- func (c *Client) CreateEmbeddings(ctx context.Context, request *CreateEmbeddingsRequest) (*CreateEmbeddingsResponse, error)
- func (c *Client) CreateMessages(ctx context.Context, request *MessageCreateRequest) (*MessageResponse, error)
- func (c *Client) CreateRun(ctx context.Context, request *RunCreateRequest) (*RunResponse, error)
- func (c *Client) CreateTextToSpeech(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)
- func (c *Client) CreateTextToSpeechPro(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)
- func (c *Client) CreateThreads(ctx context.Context, meta map[string]string) (*Thread, error)
- func (c *Client) DeleteAssistants(ctx context.Context, assistantId string) (*AssistantDeleteResponse, error)
- func (c *Client) DeleteFile(ctx context.Context, request *DeleteFileRequest) (*DeleteFileResponse, error)
- func (c *Client) ListAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFileListResponse, error)
- func (c *Client) ListAssistants(ctx context.Context, opt *AssistantListOption) (*AssistantListResponse, error)
- func (c *Client) ListFiles(ctx context.Context, purpose PurposeType) (*ListFileResponse, error)
- func (c *Client) ListMessages(ctx context.Context, request *ListMessageOption) (*ListMessagesResponse, error)
- func (c *Client) ListRun(ctx context.Context, request *ListRunOption) (*ListRunResponse, error)
- func (c *Client) ListRunStep(ctx context.Context, opt *RunStepOption) (*RunStepListResponse, error)
- func (c *Client) RetrieveAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFilesCreateResponse, error)
- func (c *Client) RetrieveAssistants(ctx context.Context, assistantId string) (*AssistantRetrieveResponse, error)
- func (c *Client) RetrieveFile(ctx context.Context, fileId int64) (*RetrieveFileResponse, error)
- func (c *Client) RetrieveMessages(ctx context.Context, request *MessageRetrieveRequest) (*MessageResponse, error)
- func (c *Client) RetrieveRun(ctx context.Context, request *RunRetrieveRequest) (*RunResponse, error)
- func (c *Client) RetrieveRunStep(ctx context.Context, request *RunStepRetrieveRequest) (*RunStepResponse, error)
- func (c *Client) RetrieveThreads(ctx context.Context, threadId string) (*Thread, error)
- func (c *Client) SumbmitToolOutputsRun(ctx context.Context, request *SubmitRequest) (*RunResponse, error)
- func (c *Client) UploadFile(ctx context.Context, request *FileRequest) (*FileResponse, error)
- type CodeInterpreter
- type CompletionProOption
- type Config
- type Content
- type CreateEmbeddingsRequest
- type CreateEmbeddingsResponse
- type CreateT2ARequest
- type CreateT2AResponse
- type DeleteFileRequest
- type DeleteFileResponse
- type ExtraInfo
- type File
- type FileCitation
- type FileRequest
- type FileResponse
- type Function
- type FunctionCall
- type Glyph
- type ImageFile
- type ListFileResponse
- type ListMessageOption
- type ListMessagesResponse
- type ListRunOption
- type ListRunResponse
- type Message
- type MessageCreateRequest
- type MessageCreation
- type MessageResponse
- type MessageRetrieveRequest
- type Parameters
- type ProMessage
- type PurposeType
- type ReplyConstraints
- type RequiredAction
- type RetrieveFileResponse
- type RoleMeta
- type Run
- type RunCreateRequest
- type RunError
- type RunFunction
- type RunResponse
- type RunRetrieveRequest
- type RunStep
- type RunStepListResponse
- type RunStepOption
- type RunStepResponse
- type RunStepRetrieveRequest
- type RunTool
- type StepDetails
- type SubmitRequest
- type TextContent
- type Thread
- type TimberWeight
- type Tool
- type ToolCall
- type ToolOutput
- type Usage
- type WebCitation
- type WebSearch
Constants ¶
View Source
const ( Abab5 = "abab5-chat" Abab5Dot5 = "abab5.5-chat" Abab5Dot5s = "abab5.5s-chat" Abab6 = "abab6-chat" Embo01 = "embo-01" Speech01 = "speech-01" Speech02 = "speech-02" Speech01Pro = "speech-01-pro" // alias speech-01=speech-01-pro ModelBot = "MM智能助理" ChatMessageRoleUser = "USER" ChatMessageRoleBot = "BOT" EmbeddingsDbType = "db" EmbeddingsQueryType = "query" ToolCodeInterpreter = "code_interpreter" ToolRetrieval = "retrieval" ToolFunction = "function" ToolWebSearch = "web_search" )
View Source
const ( VoiceMaleQnQingSe = "male-qn-qingse" // 青涩青年音色 VoiceMaleQnJingYing = "male-qn-jingying" // 精英青年音色 VoiceMaleQnBaDao = "male-qn-badao" // 霸道青年音色 VoiceMaleQnDaXueSheng = "male-qn-daxuesheng" // 青年大学生音色 VoiceFemaleShaoNv = "female-shaonv" // 少女音色 VoiceFemaleYuJie = "female-yujie" // 御姐音色 VoiceFemaleChengShu = "female-chengshu" // 成熟女性音色 VoiceFemaleTianMei = "female-tianmei" // 甜美女性音色 VoicePresenterMale = "presenter_male" // 男性主持人 VoicePresenterFemale = "presenter_female" // 女性主持人 VoiceAudiobookMale1 = "audiobook_male_1" // 男性有声书1 VoiceAudiobookMale2 = "audiobook_male_2" // 男性有声书2 VoiceAudiobookFemale1 = "audiobook_female_1" // 女性有声书1 VoiceAudiobookFemale2 = "audiobook_female_2" // 女性有声书2 VoiceMaleQnQingSeJingPin = "male-qn-qingse-jingpin" // 青涩青年音色-beta VoiceMaleQnJingYingJingPin = "male-qn-jingying-jingpin" // 精英青年音色-beta VoiceMaleQnBaDaoJingPin = "male-qn-badao-jingpin" // 霸道青年音色-beta VoiceMaleQnDaXueShengJingPin = "male-qn-daxuesheng-jingpin" // 青年大学生音色-beta VoiceFemaleShaoNvJingPin = "female-shaonv-jingpin" // 少女音色-beta VoiceFemaleYuJieJingPin = "female-yujie-jingpin" // 御姐音色-beta VoiceFemaleChengShuJingPin = "female-chengshu-jingpin" // 成熟女性音色-beta VoiceFemaleTianMeiJingPin = "female-tianmei-jingpin" // 甜美女性音色-beta )
voice_id:音色编号支,持系统音色(id)以及复刻音色(id)两种类型,其中系统音色(ID)如下:
View Source
const (
APIV1 = "https://api.minimax.chat/v1"
)
Variables ¶
View Source
var ( ErrCompletionUnsupportedModel = errors.New("this model is not supported with this method, please use CreateChatCompletion client method instead") //nolint:lll ErrCompletionStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateCompletionStream") //nolint:lll ErrTooManyEmptyStreamMessages = errors.New("too many empty messages") ErrCreateTextToSpeechProNotSupported = errors.New("params is not supported, please use CreateTextToSpeechPro") )
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Annotation struct { Typ string `json:"type"` Text string `json:"text"` StartIndex int64 `json:"start_index"` EndIndex int64 `json:"end_index"` FileCitation *FileCitation `json:"file_citation"` WebCitation *WebCitation `json:"web_citation"` }
type Assistant ¶
type Assistant struct { ID string `json:"id"` Object string `json:"object"` CreatedAt int64 `json:"created_at"` Name string `json:"name"` Description string `json:"description"` Model string `json:"model"` Instructions string `json:"instructions"` Tools []*Tool `json:"tools"` FileIds []string `json:"file_ids"` MetaData map[string]string `json:"meta_data"` RoleMeta *RoleMeta `json:"role_meta"` Status string `json:"status"` }
type AssistantCreateRequest ¶
type AssistantCreateRequest struct { Model string `json:"model"` RoleMeta *RoleMeta `json:"role_meta"` Instructions string `json:"instructions,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Tools []*Tool `json:"tools,omitempty"` FileIds []string `json:"file_ids,omitempty"` MetaData map[string]string `json:"meta_data,omitempty"` }
type AssistantDeleteResponse ¶
type AssistantFile ¶
type AssistantListOption ¶
type AssistantListResponse ¶
type AsstMessage ¶
type AsstMessage struct { ID string `json:"id"` Object string `json:"object"` CreatedAt int64 `json:"created_at"` ThreadId string `json:"thread_id"` Role string `json:"role"` Content []*Content `json:"content"` FileIds []string `json:"file_ids"` AssistantId string `json:"assistant_id"` RunId string `json:"run_id"` MetaData map[string]string `json:"metadata"` }
type BotSetting ¶
type CallFunction ¶
type CallRetrieval ¶
type ChatCompletionProRequest ¶
type ChatCompletionProRequest struct { Model string `json:"model"` Messages []ProMessage `json:"messages"` BotSetting []BotSetting `json:"bot_setting"` SampleMessages []Message `json:"sample_messages,omitempty"` Stream bool `json:"stream,omitempty"` TokensToGenerate int64 `json:"tokens_to_generate,omitempty"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` MaskSensitiveInfo bool `json:"mask_sensitive_info,omitempty"` Functions []*Function `json:"functions,omitempty"` FunctionCall *FunctionCall `json:"function_call,omitempty"` ReplyConstraints ReplyConstraints `json:"reply_constraints"` Plugins []string `json:"plugins"` }
type ChatCompletionProResponse ¶
type ChatCompletionProResponse struct { ID string `json:"id"` Created int64 `json:"created"` Model string `json:"model"` Reply string `json:"reply"` Choices []ChatMessageProChoice `json:"choices"` Usage Usage `json:"usage"` InputSensitive bool `json:"input_sensitive,omitempty"` InputSensitiveType int64 `json:"input_sensitive_type,omitempty"` OutputSensitive bool `json:"output_sensitive,omitempty"` OutputSensitiveType int64 `json:"output_sensitive_type"` BaseResp BaseResp `json:"base_resp,omitempty"` }
type ChatCompletionProStream ¶
type ChatCompletionProStream struct {
// contains filtered or unexported fields
}
type ChatCompletionRequest ¶
type ChatCompletionRequest struct { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream,omitempty"` Prompt string `json:"prompt"` TokensToGenerate int64 `json:"tokens_to_generate,omitempty"` Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` UseStandardSSE bool `json:"use_standard_sse,omitempty"` BeamWidth int `json:"beam_width,omitempty"` RoleMeta *RoleMeta `json:"role_meta"` ContinueLastMessage bool `json:"continue_last_message"` SkipInfoMask bool `json:"skip_info_mask"` }
type ChatCompletionResponse ¶
type ChatCompletionResponse struct { ID string `json:"id"` Created int64 `json:"created"` Model string `json:"model"` Reply string `json:"reply"` Choices []ChatMessageChoice `json:"choices"` Usage Usage `json:"usage"` InputSensitive bool `json:"input_sensitive,omitempty"` InputSensitiveType int64 `json:"input_sensitive_type,omitempty"` OutputSensitive bool `json:"output_sensitive,omitempty"` OutputSensitiveType int64 `json:"output_sensitive_type"` BaseResp BaseResp `json:"base_resp,omitempty"` }
type ChatCompletionStream ¶
type ChatCompletionStream struct {
// contains filtered or unexported fields
}
type ChatMessageChoice ¶
type ChatMessageProChoice ¶
type ChatMessageProChoice struct { FinishReason string `json:"finish_reason,omitempty"` Index int64 `json:"index"` Messages []ProMessage `json:"messages"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
func (*Client) CreateAssistantFiles ¶
func (c *Client) CreateAssistantFiles(ctx context.Context, request *AssistantFilesCreateRequest) (*AssistantFilesCreateResponse, error)
func (*Client) CreateAssistants ¶
func (*Client) CreateCompletion ¶
func (c *Client) CreateCompletion(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionResponse, error)
func (*Client) CreateCompletionPro ¶
func (c *Client) CreateCompletionPro(ctx context.Context, request *ChatCompletionProRequest, opts ...CompletionProOption) (*ChatCompletionProResponse, error)
func (*Client) CreateCompletionProStream ¶
func (c *Client) CreateCompletionProStream(ctx context.Context, request *ChatCompletionProRequest, opts ...CompletionProOption) (*ChatCompletionProStream, error)
func (*Client) CreateCompletionStream ¶
func (c *Client) CreateCompletionStream(ctx context.Context, request *ChatCompletionRequest) (*ChatCompletionStream, error)
func (*Client) CreateEmbeddings ¶
func (c *Client) CreateEmbeddings(ctx context.Context, request *CreateEmbeddingsRequest) (*CreateEmbeddingsResponse, error)
func (*Client) CreateMessages ¶
func (c *Client) CreateMessages(ctx context.Context, request *MessageCreateRequest) (*MessageResponse, error)
func (*Client) CreateRun ¶
func (c *Client) CreateRun(ctx context.Context, request *RunCreateRequest) (*RunResponse, error)
func (*Client) CreateTextToSpeech ¶
func (c *Client) CreateTextToSpeech(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)
func (*Client) CreateTextToSpeechPro ¶
func (c *Client) CreateTextToSpeechPro(ctx context.Context, request *CreateT2ARequest) (*CreateT2AResponse, error)
func (*Client) CreateThreads ¶
func (*Client) DeleteAssistants ¶
func (*Client) DeleteFile ¶
func (c *Client) DeleteFile(ctx context.Context, request *DeleteFileRequest) (*DeleteFileResponse, error)
func (*Client) ListAssistantFiles ¶
func (c *Client) ListAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFileListResponse, error)
func (*Client) ListAssistants ¶
func (c *Client) ListAssistants(ctx context.Context, opt *AssistantListOption) (*AssistantListResponse, error)
func (*Client) ListFiles ¶
func (c *Client) ListFiles(ctx context.Context, purpose PurposeType) (*ListFileResponse, error)
func (*Client) ListMessages ¶
func (c *Client) ListMessages(ctx context.Context, request *ListMessageOption) (*ListMessagesResponse, error)
func (*Client) ListRun ¶
func (c *Client) ListRun(ctx context.Context, request *ListRunOption) (*ListRunResponse, error)
func (*Client) ListRunStep ¶
func (c *Client) ListRunStep(ctx context.Context, opt *RunStepOption) (*RunStepListResponse, error)
func (*Client) RetrieveAssistantFiles ¶
func (c *Client) RetrieveAssistantFiles(ctx context.Context, opt *AssistantListOption) (*AssistantFilesCreateResponse, error)
func (*Client) RetrieveAssistants ¶
func (*Client) RetrieveFile ¶
func (*Client) RetrieveMessages ¶
func (c *Client) RetrieveMessages(ctx context.Context, request *MessageRetrieveRequest) (*MessageResponse, error)
func (*Client) RetrieveRun ¶
func (c *Client) RetrieveRun(ctx context.Context, request *RunRetrieveRequest) (*RunResponse, error)
func (*Client) RetrieveRunStep ¶
func (c *Client) RetrieveRunStep(ctx context.Context, request *RunStepRetrieveRequest) (*RunStepResponse, error)
func (*Client) RetrieveThreads ¶
func (*Client) SumbmitToolOutputsRun ¶
func (c *Client) SumbmitToolOutputsRun(ctx context.Context, request *SubmitRequest) (*RunResponse, error)
func (*Client) UploadFile ¶ added in v1.0.1
func (c *Client) UploadFile(ctx context.Context, request *FileRequest) (*FileResponse, error)
type CodeInterpreter ¶
type CompletionProOption ¶
type CompletionProOption func(*ChatCompletionProRequest)
func WithBotSetting ¶
func WithBotSetting(rolePrompt string, settings ...[]BotSetting) CompletionProOption
func WithReplyConstraints ¶
func WithReplyConstraints(v ReplyConstraints) CompletionProOption
type Config ¶
type Config struct { BaseURL string HTTPClient *http.Client EmptyMessageLimit uint // contains filtered or unexported fields }
func DefaultConfig ¶
type Content ¶
type Content struct { Typ string `json:"type"` Text *TextContent `json:"text"` ImageFile *ImageFile `json:"image_file"` }
type CreateEmbeddingsRequest ¶
type CreateT2ARequest ¶
type CreateT2ARequest struct { Model string `json:"model"` Text string `json:"text"` TimberWeights []TimberWeight `json:"timber_weights,omitempty"` VoiceID string `json:"voice_id,omitempty"` Speed float32 `json:"speed,omitempty"` Vol float32 `json:"vol,omitempty"` Pitch int `json:"pitch,omitempty"` AudioSampleRate int `json:"audio_sample_rate,omitempty"` Bitrate int `json:"bitrate,omitempty"` Path string `json:"-"` Name string `json:"-"` }
type CreateT2AResponse ¶
type DeleteFileRequest ¶
type DeleteFileRequest struct {
FileId int64 `json:"file_id"`
}
type DeleteFileResponse ¶
type FileCitation ¶
type FileRequest ¶
type FileRequest struct { Purpose PurposeType `json:"purpose"` FilePath string `json:"-"` }
type FileResponse ¶
type Function ¶
type Function struct { Name string `json:"name"` Description string `json:"description"` Parameters Parameters `json:"parameters"` }
type FunctionCall ¶
type ListFileResponse ¶
type ListMessageOption ¶
type ListMessagesResponse ¶
type ListMessagesResponse struct { Object string `json:"object"` Data []*AsstMessage `json:"data"` FirstId string `json:"first_id"` LastId string `json:"last_id"` BaseResp *BaseResp `json:"base_resp"` }
type ListRunOption ¶
type ListRunResponse ¶
type ListRunResponse struct { *RunResponse BaseResp *BaseResp `json:"base_resp"` }
type MessageCreateRequest ¶
type MessageCreation ¶
type MessageCreation struct {
MessageId string `json:"message_id"`
}
type MessageResponse ¶
type MessageResponse struct { *AsstMessage BaseResp *BaseResp `json:"base_resp"` }
type MessageRetrieveRequest ¶
type Parameters ¶
type ProMessage ¶
type PurposeType ¶
type PurposeType string
var ( Retrieval PurposeType = "retrieval" FineTune PurposeType = "fine-tune" FineTuneResult PurposeType = "fine-tune-result" VoiceClone PurposeType = "voice_clone" Assistants PurposeType = "assistants" RoleRecognition PurposeType = "role-recognition" )
type ReplyConstraints ¶
type RequiredAction ¶
type RequiredAction struct { Typ string `json:"type"` SubmitToolOutputs *ToolOutput `json:"submit_tool_outputs"` }
type RetrieveFileResponse ¶
type Run ¶
type Run struct { ID string `json:"id"` Object string `json:"object"` CreatedAt int64 `json:"created_at"` AssistantId string `json:"assistant_id"` ThreadId string `json:"thread_id"` Status string `json:"status"` StartedAt int64 `json:"started_at"` ExpiresAt int64 `json:"expires_at"` CancelledAt int64 `json:"cancelled_at"` FailedAt int64 `json:"failed_at"` CompletedAt int64 `json:"completed_at"` LastError *RunError `json:"last_error"` Model string `json:"model"` Instructions string `json:"instructions"` Tools []*RunTool `json:"tools"` FileIds []string `json:"file_ids"` RequiredAction any `json:"required_action"` Metadata map[string]string `json:"metadata"` }
type RunCreateRequest ¶
type RunFunction ¶
type RunResponse ¶
type RunRetrieveRequest ¶
type RunStep ¶
type RunStep struct { ID string `json:"id"` Object string `json:"object"` CreatedAt int64 `json:"created_at"` AssistantId string `json:"assistant_id"` ThreadId string `json:"thread_id"` Typ string `json:"type"` Status string `json:"status"` StartedAt int64 `json:"started_at"` ExpiresAt int64 `json:"expires_at"` CancelledAt int64 `json:"cancelled_at"` FailedAt int64 `json:"failed_at"` CompletedAt int64 `json:"completed_at"` LastError map[string]string `json:"last_error"` StepDetails *StepDetails `json:"step_details"` }
type RunStepListResponse ¶
type RunStepListResponse struct { Object string `json:"object"` Data []*RunStepResponse `json:"data"` BaseResp *BaseResp `json:"base_resp"` }
type RunStepOption ¶
type RunStepResponse ¶
type RunStepRetrieveRequest ¶
type RunTool ¶
type RunTool struct { Typ string `json:"type"` Function *RunFunction `json:"function"` }
type StepDetails ¶
type StepDetails struct { Typ string `json:"type"` MessageCreation *MessageCreation `json:"message_creation"` ToolCalls []*ToolCall `json:"tool_calls"` }
type SubmitRequest ¶
type TextContent ¶
type TextContent struct { Value string `json:"value"` Annotations []*Annotation `json:"annotations"` }
type TimberWeight ¶
type ToolCall ¶
type ToolCall struct { Typ string `json:"type"` CodeInterpreter *CodeInterpreter `json:"code_interpreter"` WebSearch *WebSearch `json:"web_search"` Retrieval *CallRetrieval `json:"retrieval"` Function *CallFunction `json:"function"` }
type ToolOutput ¶
type WebCitation ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.