Documentation
¶
Index ¶
- Constants
- func ResponseToError(resp *httpx.Response) error
- type ChatCompletionsFinishReason
- type ChatCompletionsMessage
- type ChatCompletionsMessageRole
- type ChatCompletionsModelFamily
- type ChatCompletionsModelID
- type ChatCompletionsParametersType
- type ChatCompletionsRequest
- type ChatCompletionsRequestResponseFormat
- type ChatCompletionsResponse
- type ChatCompletionsResponseChoices
- type ChatCompletionsResponseFormatType
- type ChatCompletionsResponseToolCalls
- type ChatCompletionsResponseToolCallsFunction
- type ChatCompletionsResponseUsage
- type ChatCompletionsStreamResponse
- type ChatCompletionsStreamResponseReceive
- type ChatCompletionsTool
- type ChatCompletionsToolBuiltinFunctionWebSearchArguments
- type ChatCompletionsToolFunction
- type ChatCompletionsToolFunctionParameters
- type ChatCompletionsToolFunctionProperties
- type ChatCompletionsToolType
- type Client
- type CommonAPIResponse
- type CommonAPIResponseError
- type CommonResponse
- type Config
- type ContextCache
- type ContextCacheContent
- type ContextCacheCreateRequest
- type ContextCacheCreateResponse
- type ContextCacheCreateTagRequest
- type ContextCacheCreateTagResponse
- type ContextCacheDeleteRequest
- type ContextCacheDeleteResponse
- type ContextCacheDeleteTagRequest
- type ContextCacheDeleteTagResponse
- type ContextCacheGetRequest
- type ContextCacheGetResponse
- type ContextCacheGetTagContentRequest
- type ContextCacheGetTagContentResponse
- type ContextCacheGetTagRequest
- type ContextCacheGetTagResponse
- type ContextCacheListRequest
- type ContextCacheListResponse
- type ContextCacheListTagRequest
- type ContextCacheListTagResponse
- type ContextCacheOrder
- type ContextCacheStatus
- type ContextCacheTag
- type ContextCacheUpdateRequest
- type ContextCacheUpdateResponse
- type FileContentResponse
- type FilesBatchDeleteRequest
- type FilesBatchDeleteResponse
- type FilesDeleteResponse
- type FilesInfoResponse
- type FilesListRequest
- type FilesListResponse
- type FilesListResponseData
- type FilesPurpose
- type FilesUploadBytesRequest
- type FilesUploadBytesResponse
- type FilesUploadRequest
- type FilesUploadResponse
- type IChat
- type IChatCompletionsBuilder
- type IContextCache
- type IFiles
- type IModels
- type ITokenizers
- type IUsers
- type ListModelResponseData
- type ListModelsRequest
- type ListModelsResponse
- type ListModelsResponseDataPermission
- type Option
- type TokenizersEstimateTokenCountRequest
- type TokenizersEstimateTokenCountResponse
- type TokenizersEstimateTokenCountResponseData
- type UsersBalanceResponse
- type UsersBalanceResponseData
Constants ¶
const ( ResetTTLNever = -1 // ResetTTLNever is the value for never reset ttl ResetTTLImmediate = 0 // ResetTTLImmediate is the value for immediate reset ttl )
const (
BuiltinFunctionWebSearch string = "$web_search"
)
const DefaultHost = "https://api.moonshot.cn"
Variables ¶
This section is empty.
Functions ¶
func ResponseToError ¶ added in v0.4.1
ResponseToError bind and return error from response
Types ¶
type ChatCompletionsFinishReason ¶
type ChatCompletionsFinishReason string
const ( FinishReasonStop ChatCompletionsFinishReason = "stop" FinishReasonLength ChatCompletionsFinishReason = "length" FinishReasonToolCalls ChatCompletionsFinishReason = "tool_calls" )
func (ChatCompletionsFinishReason) String ¶ added in v0.4.0
func (c ChatCompletionsFinishReason) String() string
type ChatCompletionsMessage ¶
type ChatCompletionsMessage struct { Role ChatCompletionsMessageRole `json:"role"` Content string `json:"content"` Partial bool `json:"partial,omitempty"` Name string `json:"name,omitempty"` // returns only in use tool response ToolCalls []*ChatCompletionsResponseToolCalls `json:"tool_calls,omitempty"` // use tool request need it ToolCallID string `json:"tool_call_id,omitempty"` }
type ChatCompletionsMessageRole ¶
type ChatCompletionsMessageRole string
const ( RoleSystem ChatCompletionsMessageRole = "system" RoleUser ChatCompletionsMessageRole = "user" RoleAssistant ChatCompletionsMessageRole = "assistant" RoleTool ChatCompletionsMessageRole = "tool" RoleContextCache ChatCompletionsMessageRole = "cache" )
func (ChatCompletionsMessageRole) String ¶ added in v0.4.0
func (c ChatCompletionsMessageRole) String() string
type ChatCompletionsModelFamily ¶ added in v0.5.0
type ChatCompletionsModelFamily string
const (
ModelFamilyMoonshotV1 ChatCompletionsModelFamily = "moonshot-v1"
)
func (ChatCompletionsModelFamily) String ¶ added in v0.5.0
func (c ChatCompletionsModelFamily) String() string
type ChatCompletionsModelID ¶
type ChatCompletionsModelID string
const ( ModelMoonshotV1Auto ChatCompletionsModelID = "moonshot-v1-auto" ModelMoonshotV18K ChatCompletionsModelID = "moonshot-v1-8k" ModelMoonshotV132K ChatCompletionsModelID = "moonshot-v1-32k" ModelMoonshotV1128K ChatCompletionsModelID = "moonshot-v1-128k" )
func (ChatCompletionsModelID) String ¶ added in v0.4.0
func (c ChatCompletionsModelID) String() string
type ChatCompletionsParametersType ¶ added in v0.5.0
type ChatCompletionsParametersType string
const (
ChatCompletionsParametersTypeObject ChatCompletionsParametersType = "object"
)
func (ChatCompletionsParametersType) String ¶ added in v0.5.0
func (c ChatCompletionsParametersType) String() string
type ChatCompletionsRequest ¶
type ChatCompletionsRequest struct { Messages []*ChatCompletionsMessage `json:"messages"` Model ChatCompletionsModelID `json:"model"` MaxTokens int `json:"max_tokens"` Temperature float64 `json:"temperature"` TopP float64 `json:"top_p"` N int `json:"n"` PresencePenalty float64 `json:"presence_penalty"` FrequencyPenalty float64 `json:"frequency_penalty"` ResponseFormat *ChatCompletionsRequestResponseFormat `json:"response_format"` Stop []string `json:"stop"` Stream bool `json:"stream"` // When you use a tool, you need to define it Tools []*ChatCompletionsTool `json:"tools,omitempty"` }
type ChatCompletionsRequestResponseFormat ¶ added in v0.5.1
type ChatCompletionsRequestResponseFormat struct {
Type ChatCompletionsResponseFormatType `json:"type"`
}
type ChatCompletionsResponse ¶
type ChatCompletionsResponse struct { ID string `json:"id"` Object string `json:"object"` Created int `json:"created"` Model string `json:"model"` Choices []*ChatCompletionsResponseChoices `json:"choices"` // returns only in non-stream mode Usage *ChatCompletionsResponseUsage `json:"usage,omitempty"` }
func (*ChatCompletionsResponse) GetMessage ¶ added in v0.4.2
func (c *ChatCompletionsResponse) GetMessage() (*ChatCompletionsMessage, error)
type ChatCompletionsResponseChoices ¶
type ChatCompletionsResponseChoices struct { Index int `json:"index"` // return with no stream Message *ChatCompletionsMessage `json:"message,omitempty"` // return With stream Delta *ChatCompletionsMessage `json:"delta,omitempty"` FinishReason ChatCompletionsFinishReason `json:"finish_reason"` // returns only in stream mode Usage *ChatCompletionsResponseUsage `json:"usage,omitempty"` }
type ChatCompletionsResponseFormatType ¶ added in v0.5.1
type ChatCompletionsResponseFormatType string
const ( ChatCompletionsResponseFormatJSONObject ChatCompletionsResponseFormatType = "json_object" ChatCompletionsResponseFormatText ChatCompletionsResponseFormatType = "text" )
func (ChatCompletionsResponseFormatType) String ¶ added in v0.5.1
func (c ChatCompletionsResponseFormatType) String() string
type ChatCompletionsResponseToolCalls ¶ added in v0.5.0
type ChatCompletionsResponseToolCalls struct { Index int64 `json:"index"` ID string `json:"id"` Type string `json:"type"` Function *ChatCompletionsResponseToolCallsFunction `json:"function"` }
type ChatCompletionsResponseToolCallsFunction ¶ added in v0.5.0
type ChatCompletionsStreamResponse ¶
type ChatCompletionsStreamResponse struct {
// contains filtered or unexported fields
}
func (*ChatCompletionsStreamResponse) Receive ¶ added in v0.2.0
func (c *ChatCompletionsStreamResponse) Receive() <-chan *ChatCompletionsStreamResponseReceive
Receive returns a channel to receive messages from the stream
type ChatCompletionsStreamResponseReceive ¶
type ChatCompletionsStreamResponseReceive struct { ChatCompletionsResponse // contains filtered or unexported fields }
func (*ChatCompletionsStreamResponseReceive) GetMessage ¶
func (c *ChatCompletionsStreamResponseReceive) GetMessage() (*ChatCompletionsMessage, error)
GetMessage returns the message from the stream
type ChatCompletionsTool ¶ added in v0.5.0
type ChatCompletionsTool struct { Type ChatCompletionsToolType `json:"type"` Function *ChatCompletionsToolFunction `json:"function"` }
type ChatCompletionsToolBuiltinFunctionWebSearchArguments ¶ added in v0.5.2
type ChatCompletionsToolFunction ¶ added in v0.5.0
type ChatCompletionsToolFunction struct { Name string `json:"name"` Description string `json:"description,omitempty"` Parameters *ChatCompletionsToolFunctionParameters `json:"parameters,omitempty"` }
type ChatCompletionsToolFunctionParameters ¶ added in v0.5.0
type ChatCompletionsToolFunctionParameters struct { Type ChatCompletionsParametersType `json:"type"` Properties map[string]*ChatCompletionsToolFunctionProperties `json:"properties"` Required []string `json:"required,omitempty"` }
type ChatCompletionsToolFunctionProperties ¶ added in v0.5.0
type ChatCompletionsToolType ¶ added in v0.5.0
type ChatCompletionsToolType string
const ( ChatCompletionsToolTypeFunction ChatCompletionsToolType = "function" ChatCompletionsToolTypeBuiltinFunction ChatCompletionsToolType = "builtin_function" )
func (ChatCompletionsToolType) String ¶ added in v0.5.0
func (c ChatCompletionsToolType) String() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
NewClientWithConfig creates a new client with a custom configuration
func (*Client) ContextCache ¶ added in v0.5.0
func (c *Client) ContextCache() IContextCache
ContextCache returns a new context cache controller
func (*Client) HTTPClient ¶
HTTPClient returns a new http client
func (*Client) Tokenizers ¶
func (c *Client) Tokenizers() ITokenizers
Tokenizers returns a new tokenizers controller
type CommonAPIResponse ¶
type CommonAPIResponse struct {
Error *CommonAPIResponseError `json:"error,omitempty"`
}
type CommonAPIResponseError ¶
type CommonResponse ¶
type CommonResponse struct { Code int `json:"code,omitempty"` Error string `json:"error,omitempty"` Message string `json:"message,omitempty"` Method string `json:"method,omitempty"` Scode string `json:"scode,omitempty"` Status bool `json:"status,omitempty"` UA string `json:"ua,omitempty"` URL string `json:"url,omitempty"` }
type ContextCache ¶ added in v0.5.0
type ContextCache struct { Id string `json:"id"` // 缓存的唯一标识 Status ContextCacheStatus `json:"status"` // 缓存的状态 Object string `json:"object"` // 缓存的类型 CreatedAt int64 `json:"created_at"` // 缓存的创建时间 ExpiredAt int64 `json:"expired_at"` // 缓存的过期时间 Tokens int `json:"tokens"` // 缓存的 Token 数量 Model ChatCompletionsModelFamily `json:"model"` // 缓存的模型组名称 Messages []ChatCompletionsMessage `json:"messages"` // 缓存的消息内容 Tools []ChatCompletionsTool `json:"tools"` // 缓存使用的工具 Name string `json:"name"` // 缓存的名称 Description string `json:"description"` // 缓存的描述信息 Metadata map[string]string `json:"metadata"` // 缓存的元信息 }
ContextCache is the cache of the context
type ContextCacheContent ¶ added in v0.5.0
type ContextCacheContent struct { CacheId string `json:"cache_id"` Tag string `json:"tag"` ResetTTL int64 `json:"reset_ttl"` DryRun bool `json:"dry_run"` }
ContextCacheContent is the content for the context cache
func NewContextCacheContentWithId ¶ added in v0.5.0
func NewContextCacheContentWithId(cacheId string) *ContextCacheContent
func NewContextCacheContentWithTag ¶ added in v0.5.0
func NewContextCacheContentWithTag(tag string) *ContextCacheContent
func (*ContextCacheContent) Content ¶ added in v0.5.0
func (c *ContextCacheContent) Content() string
func (*ContextCacheContent) WithDryRun ¶ added in v0.5.0
func (c *ContextCacheContent) WithDryRun(dryRun bool) *ContextCacheContent
WithDryRun set the dry run for the context cache
func (*ContextCacheContent) WithResetTTL ¶ added in v0.5.0
func (c *ContextCacheContent) WithResetTTL(resetTTL int64) *ContextCacheContent
WithResetTTL set the reset ttl for the context cache
type ContextCacheCreateRequest ¶ added in v0.5.0
type ContextCacheCreateRequest struct { Model ChatCompletionsModelFamily `json:"model"` // 模型组(model family)名称 Messages []ChatCompletionsMessage `json:"messages"` // 消息内容 Tools []ChatCompletionsTool `json:"tools,omitempty"` // 使用的工具 Name string `json:"name,omitempty"` // 缓存名称 Description string `json:"description,omitempty"` // 缓存描述信息 Metadata map[string]string `json:"metadata,omitempty"` // 缓存的元信息 ExpiredAt int64 `json:"expired_at"` // 缓存的过期时间 TTL int64 `json:"ttl,omitempty"` // 缓存的有效期 }
ContextCacheCreateRequest is the request for creating a context cache
type ContextCacheCreateResponse ¶ added in v0.5.0
type ContextCacheCreateResponse ContextCache
ContextCacheCreateResponse is the response for creating a context cache
type ContextCacheCreateTagRequest ¶ added in v0.5.0
type ContextCacheCreateTagRequest struct { Tag string `json:"tag"` // 缓存的标签 CacheId string `json:"cache_id"` // 缓存的唯一标识 }
ContextCacheCreateTagRequest is the request for creating a context cache tag
type ContextCacheCreateTagResponse ¶ added in v0.5.0
type ContextCacheCreateTagResponse ContextCacheTag
ContextCacheCreateTagResponse is the response for creating a context cache tag
type ContextCacheDeleteRequest ¶ added in v0.5.0
type ContextCacheDeleteRequest struct {
Id string `json:"id"` // 缓存的唯一标识
}
ContextCacheDeleteRequest is the request for deleting a context cache
type ContextCacheDeleteResponse ¶ added in v0.5.0
type ContextCacheDeleteResponse struct { Deleted bool `json:"deleted"` // 缓存是否被删除 Id string `json:"id"` // 被删除的缓存的唯一标识 Object string `json:"object"` // 返回的数据类型 }
ContextCacheDeleteResponse is the response for deleting a context cache
type ContextCacheDeleteTagRequest ¶ added in v0.5.0
type ContextCacheDeleteTagRequest struct {
Tag string `json:"_"` // 缓存的标签
}
ContextCacheDeleteTagRequest is the request for deleting a context cache tag
type ContextCacheDeleteTagResponse ¶ added in v0.5.0
type ContextCacheDeleteTagResponse struct { Deleted bool `json:"deleted"` // 缓存是否被删除 Object string `json:"object"` // 返回的数据类型 Tag string `json:"tag"` // 被删除的缓存的标签 }
ContextCacheDeleteTagResponse is the response for deleting a context cache tag
type ContextCacheGetRequest ¶ added in v0.5.0
type ContextCacheGetRequest struct {
Id string `json:"_"` // 缓存的唯一标识
}
ContextCacheGetRequest is the request for getting a context cache
type ContextCacheGetResponse ¶ added in v0.5.0
type ContextCacheGetResponse ContextCache
ContextCacheGetResponse is the response for getting a context cache
type ContextCacheGetTagContentRequest ¶ added in v0.5.0
type ContextCacheGetTagContentRequest struct {
Tag string `json:"_"` // 缓存的标签
}
ContextCacheGetTagContentRequest is the request for getting a context cache tag content
type ContextCacheGetTagContentResponse ¶ added in v0.5.0
type ContextCacheGetTagContentResponse ContextCache
ContextCacheGetTagContentResponse is the response for getting a context cache tag content
type ContextCacheGetTagRequest ¶ added in v0.5.0
type ContextCacheGetTagRequest struct {
Tag string `json:"_"` // 缓存的标签
}
ContextCacheGetTagRequest is the request for getting a context cache tag
type ContextCacheGetTagResponse ¶ added in v0.5.0
type ContextCacheGetTagResponse ContextCacheTag
ContextCacheGetTagResponse is the response for getting a context cache tag
type ContextCacheListRequest ¶ added in v0.5.0
type ContextCacheListRequest struct { Limit int `json:"limit,omitempty"` // 当前请求单页返回的缓存数量 Order ContextCacheOrder `json:"order,omitempty"` // 当前请求时查询缓存的排序规则 After string `json:"after,omitempty"` // 当前请求时,应该从哪一个缓存开始进行查找 Before string `json:"before,omitempty"` // 当前请求时,应该查询到哪一个缓存为止 Metadata map[string]string `json:"metadata,omitempty"` // 用于筛选缓存的 metadata 信息 }
ContextCacheListRequest is the request for listing context caches
type ContextCacheListResponse ¶ added in v0.5.0
type ContextCacheListResponse struct { Object string `json:"object"` // 返回的数据类型 Data []ContextCache `json:"data"` // 返回的缓存列表 }
ContextCacheListResponse is the response for listing context caches
type ContextCacheListTagRequest ¶ added in v0.5.0
type ContextCacheListTagRequest struct { Limit int `json:"limit,omitempty"` // 当前请求单页返回的缓存数量 Order ContextCacheOrder `json:"order,omitempty"` // 当前请求时查询缓存的排序规则 After string `json:"after,omitempty"` // 当前请求时,应该从哪一个缓存开始进行查找 Before string `json:"before,omitempty"` // 当前请求时,应该查询到哪一个缓存为止 }
ContextCacheListTagRequest is the request for listing context cache tags
type ContextCacheListTagResponse ¶ added in v0.5.0
type ContextCacheListTagResponse struct { Object string `json:"object"` // 返回的数据类型 Data []ContextCacheTag `json:"data"` // 返回的缓存标签列表 }
ContextCacheListTagResponse is the response for listing context cache tags
type ContextCacheOrder ¶ added in v0.5.0
type ContextCacheOrder string
const ( ContextCacheOrderAsc ContextCacheOrder = "asc" // 升序 ContextCacheOrderDesc ContextCacheOrder = "desc" // 降序 )
func (ContextCacheOrder) String ¶ added in v0.5.0
func (c ContextCacheOrder) String() string
type ContextCacheStatus ¶ added in v0.5.0
type ContextCacheStatus string
const ( ContextCacheStatusPending ContextCacheStatus = "pending" // 当缓存被初次创建时,其初始状态为 pending ContextCacheStatusReady ContextCacheStatus = "ready" // 如果参数合法,缓存创建成功,其状态变更为 ready ContextCacheStatusError ContextCacheStatus = "error" // 如果参数不合法,或因其他原因缓存创建失败,其状态变更为 error ContextCacheStatusInactive ContextCacheStatus = "inactive" // 对于已过期的缓存,其状态变更为 inactive )
func (ContextCacheStatus) String ¶ added in v0.5.0
func (c ContextCacheStatus) String() string
type ContextCacheTag ¶ added in v0.5.0
type ContextCacheTag struct { Tag string `json:"tag"` // 缓存的标签 CacheId string `json:"cache_id"` // 缓存的唯一标识 Object string `json:"object"` // 缓存的类型 OwnedBy string `json:"owned_by"` // 缓存的拥有者 CreatedAt int `json:"created_at"` // 缓存的创建时间 }
ContextCacheTag is the tag of the context cache
type ContextCacheUpdateRequest ¶ added in v0.5.0
type ContextCacheUpdateRequest struct { Id string `json:"_"` // 缓存的唯一标识 Metadata map[string]string `json:"metadata,omitempty"` // 缓存的元信息 ExpiredAt int64 `json:"expired_at"` // 缓存的过期时间 TTL int64 `json:"ttl,omitempty"` // 缓存的有效期 }
ContextCacheUpdateRequest is the request for updating a context cache
type ContextCacheUpdateResponse ¶ added in v0.5.0
type ContextCacheUpdateResponse ContextCache
ContextCacheUpdateResponse is the response for updating a context cache
type FileContentResponse ¶
type FilesBatchDeleteRequest ¶ added in v0.3.0
type FilesBatchDeleteRequest struct {
FileIDList []string `json:"file_ids"`
}
type FilesBatchDeleteResponse ¶ added in v0.3.0
type FilesBatchDeleteResponse struct { RespList []*FilesDeleteResponse `json:"resp_list"` ErrorList []error `json:"error_list"` }
type FilesDeleteResponse ¶
type FilesInfoResponse ¶
type FilesListRequest ¶
type FilesListRequest struct { }
type FilesListResponse ¶
type FilesListResponse struct { Object string `json:"object"` Data []*FilesListResponseData `json:"data"` }
type FilesListResponseData ¶
type FilesPurpose ¶
type FilesPurpose string
const (
FilePurposeExtract FilesPurpose = "file-extract"
)
func (FilesPurpose) String ¶
func (f FilesPurpose) String() string
type FilesUploadBytesRequest ¶
type FilesUploadBytesRequest struct { Name string Bytes []byte Purpose FilesPurpose }
type FilesUploadRequest ¶
type FilesUploadRequest struct { Name string Path string Purpose FilesPurpose }
type FilesUploadResponse ¶
type IChat ¶ added in v0.3.0
type IChat interface { Completions(ctx context.Context, req *ChatCompletionsRequest) (*ChatCompletionsResponse, error) CompletionsStream(ctx context.Context, req *ChatCompletionsRequest) (*ChatCompletionsStreamResponse, error) }
type IChatCompletionsBuilder ¶ added in v0.4.1
type IChatCompletionsBuilder interface { AddUserContent(content string) IChatCompletionsBuilder AddSystemContent(content string) IChatCompletionsBuilder AddAssistantContent(content string, partialMode ...bool) IChatCompletionsBuilder AddToolContent(content, name, toolCallID string) IChatCompletionsBuilder AddPrompt(prompt string) IChatCompletionsBuilder AddMessage(message *ChatCompletionsMessage) IChatCompletionsBuilder AddMessageFromChoices(choices []*ChatCompletionsResponseChoices) IChatCompletionsBuilder SetModel(model ChatCompletionsModelID) IChatCompletionsBuilder SetTemperature(temperature float64) IChatCompletionsBuilder SetStream(enable bool) IChatCompletionsBuilder SetMaxTokens(num int) IChatCompletionsBuilder SetTopP(num float64) IChatCompletionsBuilder SetN(num int) IChatCompletionsBuilder SetPresencePenalty(num float64) IChatCompletionsBuilder SetFrequencyPenalty(num float64) IChatCompletionsBuilder SetStop(stop []string) IChatCompletionsBuilder SetTool(tool *ChatCompletionsTool) IChatCompletionsBuilder SetTools(tools []*ChatCompletionsTool) IChatCompletionsBuilder SetContextCacheContent(content *ContextCacheContent) IChatCompletionsBuilder SetResponseFormat(format ChatCompletionsResponseFormatType) IChatCompletionsBuilder ToRequest() *ChatCompletionsRequest }
func NewChatCompletionsBuilder ¶ added in v0.4.1
func NewChatCompletionsBuilder(req ...ChatCompletionsRequest) IChatCompletionsBuilder
NewChatCompletionsBuilder creates a new chat completions builder, or with the given request
type IContextCache ¶ added in v0.5.0
type IContextCache interface { Create(ctx context.Context, req *ContextCacheCreateRequest) (*ContextCacheCreateResponse, error) List(ctx context.Context, req *ContextCacheListRequest) (*ContextCacheListResponse, error) Delete(ctx context.Context, req *ContextCacheDeleteRequest) (*ContextCacheDeleteResponse, error) Update(ctx context.Context, req *ContextCacheUpdateRequest) (*ContextCacheUpdateResponse, error) Get(ctx context.Context, req *ContextCacheGetRequest) (*ContextCacheGetResponse, error) CreateTag(ctx context.Context, req *ContextCacheCreateTagRequest) (*ContextCacheCreateTagResponse, error) ListTag(ctx context.Context, req *ContextCacheListTagRequest) (*ContextCacheListTagResponse, error) DeleteTag(ctx context.Context, req *ContextCacheDeleteTagRequest) (*ContextCacheDeleteTagResponse, error) GetTag(ctx context.Context, req *ContextCacheGetTagRequest) (*ContextCacheGetTagResponse, error) GetTagContent(ctx context.Context, req *ContextCacheGetTagContentRequest) (*ContextCacheGetTagContentResponse, error) }
type IFiles ¶ added in v0.3.0
type IFiles interface { Upload(ctx context.Context, req *FilesUploadRequest) (resp *FilesUploadResponse, err error) UploadBytes(ctx context.Context, req *FilesUploadBytesRequest) (resp *FilesUploadBytesResponse, err error) List(ctx context.Context) (res *FilesListResponse, err error) Delete(ctx context.Context, fileID string) (resp *FilesDeleteResponse, err error) BatchDelete(ctx context.Context, req *FilesBatchDeleteRequest) (resp *FilesBatchDeleteResponse, err error) Info(ctx context.Context, fileID string) (resp *FilesInfoResponse, err error) Content(ctx context.Context, fileID string) (resp *FileContentResponse, err error) }
type IModels ¶ added in v0.3.0
type IModels interface {
List(ctx context.Context) (*ListModelsResponse, error)
}
type ITokenizers ¶ added in v0.3.0
type ITokenizers interface {
EstimateTokenCount(ctx context.Context, req *TokenizersEstimateTokenCountRequest) (resp *TokenizersEstimateTokenCountResponse, err error)
}
type IUsers ¶ added in v0.4.0
type IUsers interface {
Balance(ctx context.Context) (*UsersBalanceResponse, error)
}
type ListModelResponseData ¶
type ListModelsRequest ¶
type ListModelsRequest struct { }
type ListModelsResponse ¶
type ListModelsResponse struct { CommonResponse Object string `json:"object"` Data []*ListModelResponseData `json:"data"` }
type ListModelsResponseDataPermission ¶
type ListModelsResponseDataPermission struct { Created int `json:"created"` ID string `json:"id"` Object string `json:"object"` AllowCreateEngine bool `json:"allow_create_engine"` AllowSampling bool `json:"allow_sampling"` AllowLogprobs bool `json:"allow_logprobs"` AllowSearchIndices bool `json:"allow_search_indices"` AllowView bool `json:"allow_view"` AllowFineTuning bool `json:"allow_fine_tuning"` Organization string `json:"organization"` Group string `json:"group"` IsBlocking bool `json:"is_blocking"` }
type TokenizersEstimateTokenCountRequest ¶
type TokenizersEstimateTokenCountRequest struct { Model ChatCompletionsModelID `json:"model"` Messages []*ChatCompletionsMessage `json:"messages"` }
type TokenizersEstimateTokenCountResponse ¶
type TokenizersEstimateTokenCountResponse struct { CommonResponse Data *TokenizersEstimateTokenCountResponseData `json:"data"` }
type TokenizersEstimateTokenCountResponseData ¶
type TokenizersEstimateTokenCountResponseData struct {
TotalTokens int `json:"total_tokens"`
}
type UsersBalanceResponse ¶ added in v0.4.0
type UsersBalanceResponse struct { Code int `json:"code"` Data *UsersBalanceResponseData `json:"data"` Scode string `json:"scode"` Status bool `json:"status"` }
type UsersBalanceResponseData ¶ added in v0.4.0
type UsersBalanceResponseData struct { // AvailableBalance including cash balance and voucher balance. When it is less than or equal to 0, the user cannot call the completions API AvailableBalance float64 `json:"available_balance"` // VoucherBalance will not be negative VoucherBalance float64 `json:"voucher_balance"` // CashBalance may be negative, which means that the user owes the cost. When it is negative, the AvailableBalance can be the amount of VoucherBalance CashBalance float64 `json:"cash_balance"` }
Source Files
¶
- api_chat_completions.go
- api_chat_completions_tool.go
- api_context_cache.go
- api_context_cache_content.go
- api_files.go
- api_models.go
- api_tokenizers_estimate_token_count.go
- api_users.go
- chat_completions_builder.go
- client.go
- config.go
- enum_builtin_function.go
- enum_chat_completions.go
- enum_context_cache.go
- enum_files.go
- errors.go
- response.go