Documentation
¶
Index ¶
- Constants
- Variables
- func GetAPIErrorCode(err error) string
- func GetAPIErrorMessage(err error) string
- func Ptr[T any](v T) *T
- type APIError
- type APIErrorResponse
- type AsyncResultResponse
- type AsyncResultService
- type AsyncResultVideo
- type BatchCancelService
- type BatchCreateService
- func (s *BatchCreateService) Do(ctx context.Context) (res BatchItem, err error)
- func (s *BatchCreateService) SetCompletionWindow(window string) *BatchCreateService
- func (s *BatchCreateService) SetEndpoint(endpoint string) *BatchCreateService
- func (s *BatchCreateService) SetInputFileID(inputFileID string) *BatchCreateService
- func (s *BatchCreateService) SetMetadata(metadata any) *BatchCreateService
- type BatchFileWriter
- type BatchGetResponse
- type BatchGetService
- type BatchItem
- type BatchListResponse
- type BatchListService
- type BatchRequestCounts
- type BatchResult
- type BatchResultReader
- type BatchResultResponse
- type BatchSupport
- type ChatCompletionChoice
- type ChatCompletionMessage
- type ChatCompletionMessageType
- type ChatCompletionMeta
- type ChatCompletionMultiContent
- type ChatCompletionMultiMessage
- type ChatCompletionResponse
- type ChatCompletionService
- func (s *ChatCompletionService) AddMessage(messages ...ChatCompletionMessageType) *ChatCompletionService
- func (s *ChatCompletionService) AddTool(tools ...ChatCompletionTool) *ChatCompletionService
- func (s *ChatCompletionService) BatchBody() any
- func (s *ChatCompletionService) BatchMethod() string
- func (s *ChatCompletionService) BatchURL() string
- func (s *ChatCompletionService) Do(ctx context.Context) (res ChatCompletionResponse, err error)
- func (s *ChatCompletionService) SetDoSample(doSample bool) *ChatCompletionService
- func (s *ChatCompletionService) SetMaxTokens(maxTokens int) *ChatCompletionService
- func (s *ChatCompletionService) SetMeta(meta ChatCompletionMeta) *ChatCompletionService
- func (s *ChatCompletionService) SetModel(model string) *ChatCompletionService
- func (s *ChatCompletionService) SetRequestID(requestID string) *ChatCompletionService
- func (s *ChatCompletionService) SetResponseFormat(format string) *ChatCompletionService
- func (s *ChatCompletionService) SetStop(stop ...string) *ChatCompletionService
- func (s *ChatCompletionService) SetStreamHandler(handler ChatCompletionStreamHandler) *ChatCompletionService
- func (s *ChatCompletionService) SetTemperature(temperature float64) *ChatCompletionService
- func (s *ChatCompletionService) SetToolChoice(toolChoice string) *ChatCompletionService
- func (s *ChatCompletionService) SetTopP(topP float64) *ChatCompletionService
- func (s *ChatCompletionService) SetUserID(userID string) *ChatCompletionService
- type ChatCompletionStreamHandler
- type ChatCompletionTool
- type ChatCompletionToolCall
- type ChatCompletionToolCallCodeInterpreter
- type ChatCompletionToolCallCodeInterpreterOutput
- type ChatCompletionToolCallDrawingTool
- type ChatCompletionToolCallDrawingToolOutput
- type ChatCompletionToolCallFunction
- type ChatCompletionToolCallWebBrowser
- type ChatCompletionToolCallWebBrowserOutput
- type ChatCompletionToolCodeInterpreter
- type ChatCompletionToolDrawingTool
- type ChatCompletionToolFunction
- type ChatCompletionToolRetrieval
- type ChatCompletionToolWebBrowser
- type ChatCompletionToolWebSearch
- type ChatCompletionUsage
- type ChatCompletionWebSearch
- type Client
- func (c *Client) AsyncResult(id string) *AsyncResultService
- func (c *Client) BatchCancel(batchID string) *BatchCancelService
- func (c *Client) BatchCreate() *BatchCreateService
- func (c *Client) BatchGet(batchID string) *BatchGetService
- func (c *Client) BatchList() *BatchListService
- func (c *Client) ChatCompletion(model string) *ChatCompletionService
- func (c *Client) Embedding(model string) *EmbeddingService
- func (c *Client) FileCreate(purpose string) *FileCreateService
- func (c *Client) FileDelete(fileID string) *FileDeleteService
- func (c *Client) FileDownload(fileID string) *FileDownloadService
- func (c *Client) FileEdit(documentID string) *FileEditService
- func (c *Client) FileGet(documentID string) *FileGetService
- func (c *Client) FileList(purpose string) *FileListService
- func (c *Client) FineTuneCancel(jobID string) *FineTuneCancelService
- func (c *Client) FineTuneCreate(model string) *FineTuneCreateService
- func (c *Client) FineTuneDelete(jobID string) *FineTuneDeleteService
- func (c *Client) FineTuneEventList(jobID string) *FineTuneEventListService
- func (c *Client) FineTuneGet(jobID string) *FineTuneGetService
- func (c *Client) FineTuneList() *FineTuneListService
- func (c *Client) ImageGeneration(model string) *ImageGenerationService
- func (c *Client) KnowledgeCapacity() *KnowledgeCapacityService
- func (c *Client) KnowledgeCreate() *KnowledgeCreateService
- func (c *Client) KnowledgeDelete(knowledgeID string) *KnowledgeDeleteService
- func (c *Client) KnowledgeEdit(knowledgeID string) *KnowledgeEditService
- func (c *Client) KnowledgeList() *KnowledgeListService
- func (c *Client) VideoGeneration(model string) *VideoGenerationService
- type ClientOption
- type EmbeddingData
- type EmbeddingResponse
- type EmbeddingService
- func (s *EmbeddingService) BatchBody() any
- func (s *EmbeddingService) BatchMethod() string
- func (s *EmbeddingService) BatchURL() string
- func (s *EmbeddingService) Do(ctx context.Context) (res EmbeddingResponse, err error)
- func (s *EmbeddingService) SetInput(input string) *EmbeddingService
- func (s *EmbeddingService) SetModel(model string) *EmbeddingService
- type FileCreateFineTuneResponse
- type FileCreateKnowledgeFailedInfo
- type FileCreateKnowledgeResponse
- type FileCreateKnowledgeSuccessInfo
- type FileCreateResponse
- type FileCreateService
- func (s *FileCreateService) Do(ctx context.Context) (res FileCreateResponse, err error)
- func (s *FileCreateService) SetCustomSeparator(customSeparator string) *FileCreateService
- func (s *FileCreateService) SetFile(file io.Reader, filename string) *FileCreateService
- func (s *FileCreateService) SetKnowledgeID(knowledgeID string) *FileCreateService
- func (s *FileCreateService) SetLocalFile(localFile string) *FileCreateService
- func (s *FileCreateService) SetPurpose(purpose string) *FileCreateService
- func (s *FileCreateService) SetSentenceSize(sentenceSize int) *FileCreateService
- type FileDeleteService
- type FileDownloadService
- type FileEditService
- func (s *FileEditService) Do(ctx context.Context) (err error)
- func (s *FileEditService) SetCustomSeparator(customSeparator ...string) *FileEditService
- func (s *FileEditService) SetDocumentID(documentID string) *FileEditService
- func (s *FileEditService) SetKnowledgeType(knowledgeType int) *FileEditService
- func (s *FileEditService) SetSentenceSize(sentenceSize int) *FileEditService
- type FileFailInfo
- type FileGetResponse
- type FileGetService
- type FileListFineTuneItem
- type FileListFineTuneResponse
- type FileListKnowledgeItem
- type FileListKnowledgeResponse
- type FileListResponse
- type FileListService
- func (s *FileListService) Do(ctx context.Context) (res FileListResponse, err error)
- func (s *FileListService) SetAfter(after string) *FileListService
- func (s *FileListService) SetKnowledgeID(knowledgeID string) *FileListService
- func (s *FileListService) SetLimit(limit int) *FileListService
- func (s *FileListService) SetOrder(asc bool) *FileListService
- func (s *FileListService) SetPage(page int) *FileListService
- func (s *FileListService) SetPurpose(purpose string) *FileListService
- type FineTuneCancelService
- type FineTuneCreateResponse
- type FineTuneCreateService
- func (s *FineTuneCreateService) Do(ctx context.Context) (res FineTuneCreateResponse, err error)
- func (s *FineTuneCreateService) SetBatchSize(batchSize int) *FineTuneCreateService
- func (s *FineTuneCreateService) SetBatchSizeAuto() *FineTuneCreateService
- func (s *FineTuneCreateService) SetLearningRateMultiplier(learningRateMultiplier float64) *FineTuneCreateService
- func (s *FineTuneCreateService) SetLearningRateMultiplierAuto() *FineTuneCreateService
- func (s *FineTuneCreateService) SetModel(model string) *FineTuneCreateService
- func (s *FineTuneCreateService) SetNEpochs(nEpochs int) *FineTuneCreateService
- func (s *FineTuneCreateService) SetNEpochsAuto() *FineTuneCreateService
- func (s *FineTuneCreateService) SetRequestID(requestID string) *FineTuneCreateService
- func (s *FineTuneCreateService) SetSuffix(suffix string) *FineTuneCreateService
- func (s *FineTuneCreateService) SetTrainingFile(trainingFile string) *FineTuneCreateService
- func (s *FineTuneCreateService) SetValidationFile(validationFile string) *FineTuneCreateService
- type FineTuneDeleteService
- type FineTuneEventData
- type FineTuneEventItem
- type FineTuneEventListResponse
- type FineTuneEventListService
- func (s *FineTuneEventListService) Do(ctx context.Context) (res FineTuneEventListResponse, err error)
- func (s *FineTuneEventListService) SetAfter(after string) *FineTuneEventListService
- func (s *FineTuneEventListService) SetJobID(jobID string) *FineTuneEventListService
- func (s *FineTuneEventListService) SetLimit(limit int) *FineTuneEventListService
- type FineTuneGetService
- type FineTuneItem
- type FineTuneListResponse
- type FineTuneListService
- type IDItem
- type ImageGenerationResponse
- type ImageGenerationService
- func (s *ImageGenerationService) BatchBody() any
- func (s *ImageGenerationService) BatchMethod() string
- func (s *ImageGenerationService) BatchURL() string
- func (s *ImageGenerationService) Do(ctx context.Context) (res ImageGenerationResponse, err error)
- func (s *ImageGenerationService) SetModel(model string) *ImageGenerationService
- func (s *ImageGenerationService) SetPrompt(prompt string) *ImageGenerationService
- func (s *ImageGenerationService) SetUserID(userID string) *ImageGenerationService
- type KnowledgeCapacityItem
- type KnowledgeCapacityResponse
- type KnowledgeCapacityService
- type KnowledgeCreateResponse
- type KnowledgeCreateService
- func (s *KnowledgeCreateService) Do(ctx context.Context) (res KnowledgeCreateResponse, err error)
- func (s *KnowledgeCreateService) SetDescription(description string) *KnowledgeCreateService
- func (s *KnowledgeCreateService) SetEmbeddingID(embeddingID int) *KnowledgeCreateService
- func (s *KnowledgeCreateService) SetName(name string) *KnowledgeCreateService
- type KnowledgeDeleteService
- type KnowledgeEditService
- func (s *KnowledgeEditService) Do(ctx context.Context) (err error)
- func (s *KnowledgeEditService) SetDescription(description string) *KnowledgeEditService
- func (s *KnowledgeEditService) SetEmbeddingID(embeddingID int) *KnowledgeEditService
- func (s *KnowledgeEditService) SetKnowledgeID(knowledgeID string) *KnowledgeEditService
- func (s *KnowledgeEditService) SetName(name string) *KnowledgeEditService
- type KnowledgeItem
- type KnowledgeListResponse
- type KnowledgeListService
- type M
- type StringOr
- type URLItem
- type VideoGenerationResponse
- type VideoGenerationService
- func (s *VideoGenerationService) BatchBody() any
- func (s *VideoGenerationService) BatchMethod() string
- func (s *VideoGenerationService) BatchURL() string
- func (s *VideoGenerationService) Do(ctx context.Context) (res VideoGenerationResponse, err error)
- func (s *VideoGenerationService) SetImageURL(imageURL string) *VideoGenerationService
- func (s *VideoGenerationService) SetModel(model string) *VideoGenerationService
- func (s *VideoGenerationService) SetPrompt(prompt string) *VideoGenerationService
- func (s *VideoGenerationService) SetRequestID(requestID string) *VideoGenerationService
- func (s *VideoGenerationService) SetUserID(userID string) *VideoGenerationService
Constants ¶
const ( BatchEndpointV4ChatCompletions = "/v4/chat/completions" BatchEndpointV4ImagesGenerations = "/v4/images/generations" BatchEndpointV4Embeddings = "/v4/embeddings" BatchEndpointV4VideosGenerations = "/v4/videos/generations" BatchCompletionWindow24h = "24h" )
const ( RoleSystem = "system" RoleUser = "user" RoleAssistant = "assistant" RoleTool = "tool" ToolChoiceAuto = "auto" FinishReasonStop = "stop" FinishReasonStopSequence = "stop_sequence" FinishReasonToolCalls = "tool_calls" FinishReasonLength = "length" FinishReasonSensitive = "sensitive" FinishReasonNetworkError = "network_error" ToolTypeFunction = "function" ToolTypeWebSearch = "web_search" ToolTypeRetrieval = "retrieval" MultiContentTypeText = "text" MultiContentTypeImageURL = "image_url" // New in GLM-4-AllTools ToolTypeCodeInterpreter = "code_interpreter" ToolTypeDrawingTool = "drawing_tool" ToolTypeWebBrowser = "web_browser" CodeInterpreterSandboxNone = "none" CodeInterpreterSandboxAuto = "auto" ChatCompletionStatusFailed = "failed" ChatCompletionStatusCompleted = "completed" ChatCompletionStatusRequiresAction = "requires_action" // ResponseFormat ResponseFormatText = "text" ResponseFormatJSONObject = "json_object" )
const ( FilePurposeFineTune = "fine-tune" FilePurposeRetrieval = "retrieval" FilePurposeBatch = "batch" KnowledgeTypeArticle = 1 KnowledgeTypeQADocument = 2 KnowledgeTypeQASpreadsheet = 3 KnowledgeTypeProductDatabaseSpreadsheet = 4 KnowledgeTypeCustom = 5 )
const ( HyperParameterAuto = "auto" FineTuneStatusCreate = "create" FineTuneStatusValidatingFiles = "validating_files" FineTuneStatusQueued = "queued" FineTuneStatusRunning = "running" FineTuneStatusSucceeded = "succeeded" FineTuneStatusFailed = "failed" FineTuneStatusCancelled = "cancelled" )
const ( VideoGenerationTaskStatusProcessing = "PROCESSING" VideoGenerationTaskStatusSuccess = "SUCCESS" VideoGenerationTaskStatusFail = "FAIL" )
const (
KnowledgeEmbeddingIDEmbedding2 = 3
)
Variables ¶
var ( // ErrAPIKeyMissing is the error when the api key is missing ErrAPIKeyMissing = errors.New("zhipu: api key is missing") // ErrAPIKeyMalformed is the error when the api key is malformed ErrAPIKeyMalformed = errors.New("zhipu: api key is malformed") )
Functions ¶
func GetAPIErrorCode ¶
GetAPIErrorCode returns the error code of an API error.
func GetAPIErrorMessage ¶
GetAPIErrorMessage returns the error message of an API error.
Types ¶
type APIErrorResponse ¶
type APIErrorResponse struct {
APIError `json:"error"`
}
func (APIErrorResponse) Error ¶
func (e APIErrorResponse) Error() string
type AsyncResultResponse ¶ added in v0.1.2
type AsyncResultResponse struct { Model string `json:"model"` TaskStatus string `json:"task_status"` RequestID string `json:"request_id"` ID string `json:"id"` VideoResult []AsyncResultVideo `json:"video_result"` }
AsyncResultResponse is the response of the AsyncResultService
type AsyncResultService ¶ added in v0.1.2
type AsyncResultService struct {
// contains filtered or unexported fields
}
AsyncResultService creates a new async result get service
func NewAsyncResultService ¶ added in v0.1.2
func NewAsyncResultService(client *Client) *AsyncResultService
NewAsyncResultService creates a new async result get service
func (*AsyncResultService) Do ¶ added in v0.1.2
func (s *AsyncResultService) Do(ctx context.Context) (res AsyncResultResponse, err error)
func (*AsyncResultService) SetID ¶ added in v0.1.2
func (s *AsyncResultService) SetID(id string) *AsyncResultService
SetID sets the id parameter
type AsyncResultVideo ¶ added in v0.1.2
type AsyncResultVideo struct { URL string `json:"url"` CoverImageURL string `json:"cover_image_url"` }
AsyncResultVideo is the video result of the AsyncResultService
type BatchCancelService ¶ added in v0.0.5
type BatchCancelService struct {
// contains filtered or unexported fields
}
BatchCancelService is a service to cancel a batch.
func NewBatchCancelService ¶ added in v0.1.0
func NewBatchCancelService(client *Client) *BatchCancelService
NewBatchCancelService creates a new BatchCancelService.
func (*BatchCancelService) Do ¶ added in v0.0.5
func (s *BatchCancelService) Do(ctx context.Context) (err error)
Do executes the batch cancel service.
func (*BatchCancelService) SetBatchID ¶ added in v0.0.5
func (s *BatchCancelService) SetBatchID(batchID string) *BatchCancelService
SetBatchID sets the batch id for the batch cancel service.
type BatchCreateService ¶ added in v0.0.5
type BatchCreateService struct {
// contains filtered or unexported fields
}
BatchCreateService is a service to create a batch.
func NewBatchCreateService ¶ added in v0.1.0
func NewBatchCreateService(client *Client) *BatchCreateService
NewBatchCreateService creates a new BatchCreateService.
func (*BatchCreateService) Do ¶ added in v0.0.5
func (s *BatchCreateService) Do(ctx context.Context) (res BatchItem, err error)
Do executes the batch create service.
func (*BatchCreateService) SetCompletionWindow ¶ added in v0.0.5
func (s *BatchCreateService) SetCompletionWindow(window string) *BatchCreateService
SetCompletionWindow sets the completion window for the batch.
func (*BatchCreateService) SetEndpoint ¶ added in v0.0.5
func (s *BatchCreateService) SetEndpoint(endpoint string) *BatchCreateService
SetEndpoint sets the endpoint for the batch.
func (*BatchCreateService) SetInputFileID ¶ added in v0.0.5
func (s *BatchCreateService) SetInputFileID(inputFileID string) *BatchCreateService
SetInputFileID sets the input file id for the batch.
func (*BatchCreateService) SetMetadata ¶ added in v0.0.5
func (s *BatchCreateService) SetMetadata(metadata any) *BatchCreateService
SetMetadata sets the metadata for the batch.
type BatchFileWriter ¶ added in v0.0.5
type BatchFileWriter struct {
// contains filtered or unexported fields
}
BatchFileWriter is a writer for batch files.
func NewBatchFileWriter ¶ added in v0.0.5
func NewBatchFileWriter(w io.Writer) *BatchFileWriter
NewBatchFileWriter creates a new BatchFileWriter.
func (*BatchFileWriter) Write ¶ added in v0.0.5
func (b *BatchFileWriter) Write(customID string, s BatchSupport) error
Write writes a batch file.
type BatchGetResponse ¶ added in v0.1.0
type BatchGetResponse = BatchItem
BatchGetResponse represents the response of the batch get service.
type BatchGetService ¶ added in v0.0.5
type BatchGetService struct {
// contains filtered or unexported fields
}
BatchGetService is a service to get a batch.
func NewBatchGetService ¶ added in v0.1.0
func NewBatchGetService(client *Client) *BatchGetService
NewBatchGetService creates a new BatchGetService.
func (*BatchGetService) Do ¶ added in v0.0.5
func (s *BatchGetService) Do(ctx context.Context) (res BatchGetResponse, err error)
Do executes the batch get service.
func (*BatchGetService) SetBatchID ¶ added in v0.0.5
func (s *BatchGetService) SetBatchID(batchID string) *BatchGetService
SetBatchID sets the batch id for the batch get service.
type BatchItem ¶ added in v0.0.5
type BatchItem struct { ID string `json:"id"` Object any `json:"object"` Endpoint string `json:"endpoint"` InputFileID string `json:"input_file_id"` CompletionWindow string `json:"completion_window"` Status string `json:"status"` OutputFileID string `json:"output_file_id"` ErrorFileID string `json:"error_file_id"` CreatedAt int64 `json:"created_at"` InProgressAt int64 `json:"in_progress_at"` ExpiresAt int64 `json:"expires_at"` FinalizingAt int64 `json:"finalizing_at"` CompletedAt int64 `json:"completed_at"` FailedAt int64 `json:"failed_at"` ExpiredAt int64 `json:"expired_at"` CancellingAt int64 `json:"cancelling_at"` CancelledAt int64 `json:"cancelled_at"` RequestCounts BatchRequestCounts `json:"request_counts"` Metadata json.RawMessage `json:"metadata"` }
BatchItem represents a batch item.
type BatchListResponse ¶ added in v0.0.5
type BatchListResponse struct { Object string `json:"object"` Data []BatchItem `json:"data"` FirstID string `json:"first_id"` LastID string `json:"last_id"` HasMore bool `json:"has_more"` }
BatchListResponse represents the response of the batch list service.
type BatchListService ¶ added in v0.0.5
type BatchListService struct {
// contains filtered or unexported fields
}
BatchListService is a service to list batches.
func NewBatchListService ¶ added in v0.1.0
func NewBatchListService(client *Client) *BatchListService
NewBatchListService creates a new BatchListService.
func (*BatchListService) Do ¶ added in v0.0.5
func (s *BatchListService) Do(ctx context.Context) (res BatchListResponse, err error)
Do executes the batch list service.
func (*BatchListService) SetAfter ¶ added in v0.0.5
func (s *BatchListService) SetAfter(after string) *BatchListService
SetAfter sets the after cursor for the batch list service.
func (*BatchListService) SetLimit ¶ added in v0.0.5
func (s *BatchListService) SetLimit(limit int) *BatchListService
SetLimit sets the limit for the batch list service.
type BatchRequestCounts ¶ added in v0.0.5
type BatchRequestCounts struct { Total int64 `json:"total"` Completed int64 `json:"completed"` Failed int64 `json:"failed"` }
BatchRequestCounts represents the counts of the batch requests.
type BatchResult ¶ added in v0.0.6
type BatchResult[T any] struct { ID string `json:"id"` CustomID string `json:"custom_id"` Response BatchResultResponse[T] `json:"response"` }
BatchResult is the result of a batch.
type BatchResultReader ¶ added in v0.0.6
type BatchResultReader[T any] struct { // contains filtered or unexported fields }
BatchResultReader reads batch results.
func NewBatchResultReader ¶ added in v0.0.6
func NewBatchResultReader[T any](r io.Reader) *BatchResultReader[T]
NewBatchResultReader creates a new BatchResultReader.
func (*BatchResultReader[T]) Read ¶ added in v0.0.6
func (r *BatchResultReader[T]) Read(out *BatchResult[T]) error
Read reads a batch result.
type BatchResultResponse ¶ added in v0.0.6
BatchResultResponse is the response of a batch result.
type BatchSupport ¶ added in v0.0.5
BatchSupport is the interface for services with batch support.
type ChatCompletionChoice ¶
type ChatCompletionChoice struct { Index int `json:"index"` FinishReason string `json:"finish_reason"` Delta ChatCompletionMessage `json:"delta"` // stream mode Message ChatCompletionMessage `json:"message"` // non-stream mode }
ChatCompletionChoice is the choice for chat completion
type ChatCompletionMessage ¶
type ChatCompletionMessage struct { Role string `json:"role"` Content string `json:"content,omitempty"` ToolCalls []ChatCompletionToolCall `json:"tool_calls,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` }
ChatCompletionMessage is the message for chat completion
type ChatCompletionMessageType ¶ added in v0.0.3
type ChatCompletionMessageType interface {
// contains filtered or unexported methods
}
type ChatCompletionMeta ¶ added in v0.0.4
type ChatCompletionMeta struct { UserInfo string `json:"user_info"` BotInfo string `json:"bot_info"` UserName string `json:"user_name"` BotName string `json:"bot_name"` }
ChatCompletionMeta is the meta for chat completion
type ChatCompletionMultiContent ¶ added in v0.0.3
type ChatCompletionMultiMessage ¶ added in v0.0.3
type ChatCompletionMultiMessage struct { Role string `json:"role"` Content []ChatCompletionMultiContent `json:"content"` }
ChatCompletionMultiMessage is the multi message for chat completion
type ChatCompletionResponse ¶
type ChatCompletionResponse struct { ID string `json:"id"` Created int64 `json:"created"` Model string `json:"model"` Choices []ChatCompletionChoice `json:"choices"` Usage ChatCompletionUsage `json:"usage"` WebSearch []ChatCompletionWebSearch `json:"web_search"` // Status is the status of the chat completion, only in GLM-4-AllTools Status string `json:"status"` }
ChatCompletionResponse is the response for chat completion
type ChatCompletionService ¶
type ChatCompletionService struct {
// contains filtered or unexported fields
}
ChatCompletionStreamService is the service for chat completion stream
func NewChatCompletionService ¶ added in v0.1.0
func NewChatCompletionService(client *Client) *ChatCompletionService
NewChatCompletionService creates a new ChatCompletionService.
func (*ChatCompletionService) AddMessage ¶
func (s *ChatCompletionService) AddMessage(messages ...ChatCompletionMessageType) *ChatCompletionService
AddMessage add the message to the chat completion
func (*ChatCompletionService) AddTool ¶
func (s *ChatCompletionService) AddTool(tools ...ChatCompletionTool) *ChatCompletionService
AddFunction add the function to the chat completion
func (*ChatCompletionService) BatchBody ¶ added in v0.0.5
func (s *ChatCompletionService) BatchBody() any
func (*ChatCompletionService) BatchMethod ¶ added in v0.0.5
func (s *ChatCompletionService) BatchMethod() string
func (*ChatCompletionService) BatchURL ¶ added in v0.0.5
func (s *ChatCompletionService) BatchURL() string
func (*ChatCompletionService) Do ¶
func (s *ChatCompletionService) Do(ctx context.Context) (res ChatCompletionResponse, err error)
Do send the request of the chat completion and return the response
func (*ChatCompletionService) SetDoSample ¶
func (s *ChatCompletionService) SetDoSample(doSample bool) *ChatCompletionService
SetTemperature set the temperature of the chat completion, optional
func (*ChatCompletionService) SetMaxTokens ¶
func (s *ChatCompletionService) SetMaxTokens(maxTokens int) *ChatCompletionService
SetMaxTokens set the max tokens of the chat completion, optional
func (*ChatCompletionService) SetMeta ¶ added in v0.0.4
func (s *ChatCompletionService) SetMeta(meta ChatCompletionMeta) *ChatCompletionService
SetMeta set the meta of the chat completion, optional
func (*ChatCompletionService) SetModel ¶
func (s *ChatCompletionService) SetModel(model string) *ChatCompletionService
SetModel set the model of the chat completion
func (*ChatCompletionService) SetRequestID ¶
func (s *ChatCompletionService) SetRequestID(requestID string) *ChatCompletionService
SetRequestID set the request id of the chat completion, optional
func (*ChatCompletionService) SetResponseFormat ¶ added in v0.1.5
func (s *ChatCompletionService) SetResponseFormat(format string) *ChatCompletionService
func (*ChatCompletionService) SetStop ¶
func (s *ChatCompletionService) SetStop(stop ...string) *ChatCompletionService
SetStop set the stop of the chat completion, optional
func (*ChatCompletionService) SetStreamHandler ¶
func (s *ChatCompletionService) SetStreamHandler(handler ChatCompletionStreamHandler) *ChatCompletionService
SetStreamHandler set the stream handler of the chat completion, optional this will enable the stream mode
func (*ChatCompletionService) SetTemperature ¶
func (s *ChatCompletionService) SetTemperature(temperature float64) *ChatCompletionService
SetTemperature set the temperature of the chat completion, optional
func (*ChatCompletionService) SetToolChoice ¶
func (s *ChatCompletionService) SetToolChoice(toolChoice string) *ChatCompletionService
SetToolChoice set the tool choice of the chat completion, optional
func (*ChatCompletionService) SetTopP ¶
func (s *ChatCompletionService) SetTopP(topP float64) *ChatCompletionService
SetTopP set the top p of the chat completion, optional
func (*ChatCompletionService) SetUserID ¶
func (s *ChatCompletionService) SetUserID(userID string) *ChatCompletionService
SetUserID set the user id of the chat completion, optional
type ChatCompletionStreamHandler ¶
type ChatCompletionStreamHandler func(chunk ChatCompletionResponse) error
ChatCompletionStreamHandler is the handler for chat completion stream
type ChatCompletionTool ¶
type ChatCompletionTool interface {
// contains filtered or unexported methods
}
ChatCompletionTool is the interface for chat completion tool
type ChatCompletionToolCall ¶
type ChatCompletionToolCall struct { ID string `json:"id"` Type string `json:"type"` Function *ChatCompletionToolCallFunction `json:"function,omitempty"` CodeInterpreter *ChatCompletionToolCallCodeInterpreter `json:"code_interpreter,omitempty"` DrawingTool *ChatCompletionToolCallDrawingTool `json:"drawing_tool,omitempty"` WebBrowser *ChatCompletionToolCallWebBrowser `json:"web_browser,omitempty"` }
ChatCompletionToolCall is the tool call for chat completion
type ChatCompletionToolCallCodeInterpreter ¶ added in v0.1.1
type ChatCompletionToolCallCodeInterpreter struct { Input string `json:"input"` Outputs []ChatCompletionToolCallCodeInterpreterOutput `json:"outputs"` }
ChatCompletionToolCallCodeInterpreter is the code interpreter for chat completion tool call
type ChatCompletionToolCallCodeInterpreterOutput ¶ added in v0.1.1
type ChatCompletionToolCallCodeInterpreterOutput struct { Type string `json:"type"` Logs string `json:"logs"` File string `json:"file"` }
ChatCompletionToolCallCodeInterpreterOutput is the output for chat completion tool call code interpreter
type ChatCompletionToolCallDrawingTool ¶ added in v0.1.1
type ChatCompletionToolCallDrawingTool struct { Input string `json:"input"` Outputs []ChatCompletionToolCallDrawingToolOutput `json:"outputs"` }
ChatCompletionToolCallDrawingTool is the drawing tool for chat completion tool call
type ChatCompletionToolCallDrawingToolOutput ¶ added in v0.1.1
type ChatCompletionToolCallDrawingToolOutput struct {
Image string `json:"image"`
}
ChatCompletionToolCallDrawingToolOutput is the output for chat completion tool call drawing tool
type ChatCompletionToolCallFunction ¶
type ChatCompletionToolCallFunction struct { Name string `json:"name"` Arguments json.RawMessage `json:"arguments"` }
ChatCompletionToolCallFunction is the function for chat completion tool call
type ChatCompletionToolCallWebBrowser ¶ added in v0.1.1
type ChatCompletionToolCallWebBrowser struct { Input string `json:"input"` Outputs []ChatCompletionToolCallWebBrowserOutput `json:"outputs"` }
ChatCompletionToolCallWebBrowser is the web browser for chat completion tool call
type ChatCompletionToolCallWebBrowserOutput ¶ added in v0.1.1
type ChatCompletionToolCallWebBrowserOutput struct { Title string `json:"title"` Link string `json:"link"` Content string `json:"content"` }
ChatCompletionToolCallWebBrowserOutput is the output for chat completion tool call web browser
type ChatCompletionToolCodeInterpreter ¶ added in v0.1.1
type ChatCompletionToolCodeInterpreter struct {
Sandbox *string `json:"sandbox,omitempty"`
}
ChatCompletionToolCodeInterpreter is the code interpreter for chat completion only in GLM-4-AllTools
type ChatCompletionToolDrawingTool ¶ added in v0.1.1
type ChatCompletionToolDrawingTool struct { }
ChatCompletionToolDrawingTool is the drawing tool for chat completion only in GLM-4-AllTools
type ChatCompletionToolFunction ¶
type ChatCompletionToolFunction struct { Name string `json:"name"` Description string `json:"description"` Parameters any `json:"parameters"` }
ChatCompletionToolFunction is the function for chat completion
type ChatCompletionToolRetrieval ¶
type ChatCompletionToolRetrieval struct { KnowledgeID string `json:"knowledge_id"` PromptTemplate string `json:"prompt_template,omitempty"` }
ChatCompletionToolRetrieval is the retrieval for chat completion
type ChatCompletionToolWebBrowser ¶ added in v0.1.1
type ChatCompletionToolWebBrowser struct { }
ChatCompletionToolWebBrowser is the web browser for chat completion
type ChatCompletionToolWebSearch ¶
type ChatCompletionToolWebSearch struct { Enable *bool `json:"enable,omitempty"` SearchQuery string `json:"search_query,omitempty"` SearchResult bool `json:"search_result,omitempty"` }
ChatCompletionToolWebSearch is the web search for chat completion
type ChatCompletionUsage ¶
type ChatCompletionUsage struct { PromptTokens int64 `json:"prompt_tokens"` CompletionTokens int64 `json:"completion_tokens"` TotalTokens int64 `json:"total_tokens"` }
ChatCompletionUsage is the usage for chat completion
type ChatCompletionWebSearch ¶
type ChatCompletionWebSearch struct { Icon string `json:"icon"` Title string `json:"title"` Link string `json:"link"` Media string `json:"media"` Content string `json:"content"` }
ChatCompletionWebSearch is the web search result for chat completion
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client for zhipu ai platform
func NewClient ¶
func NewClient(optFns ...ClientOption) (client *Client, err error)
NewClient creates a new client It will read the api key from the environment variable ZHIPUAI_API_KEY It will read the base url from the environment variable ZHIPUAI_BASE_URL
func (*Client) AsyncResult ¶ added in v0.1.2
func (c *Client) AsyncResult(id string) *AsyncResultService
AsyncResult creates a new async result get service
func (*Client) BatchCancel ¶ added in v0.1.0
func (c *Client) BatchCancel(batchID string) *BatchCancelService
BatchCancel creates a new BatchCancelService.
func (*Client) BatchCreate ¶ added in v0.1.0
func (c *Client) BatchCreate() *BatchCreateService
BatchCreate creates a new BatchCreateService.
func (*Client) BatchGet ¶ added in v0.1.0
func (c *Client) BatchGet(batchID string) *BatchGetService
BatchGet creates a new BatchGetService.
func (*Client) BatchList ¶ added in v0.1.0
func (c *Client) BatchList() *BatchListService
BatchList creates a new BatchListService.
func (*Client) ChatCompletion ¶ added in v0.1.0
func (c *Client) ChatCompletion(model string) *ChatCompletionService
ChatCompletion creates a new ChatCompletionService.
func (*Client) Embedding ¶ added in v0.1.0
func (c *Client) Embedding(model string) *EmbeddingService
Embedding embeds a list of text into a vector space.
func (*Client) FileCreate ¶ added in v0.1.0
func (c *Client) FileCreate(purpose string) *FileCreateService
FileCreate creates a new FileCreateService.
func (*Client) FileDelete ¶ added in v0.1.0
func (c *Client) FileDelete(fileID string) *FileDeleteService
FileDeleteService creates a new FileDeleteService.
func (*Client) FileDownload ¶ added in v0.1.0
func (c *Client) FileDownload(fileID string) *FileDownloadService
FileDownload creates a new FileDownloadService.
func (*Client) FileEdit ¶ added in v0.1.0
func (c *Client) FileEdit(documentID string) *FileEditService
FileEditService creates a new FileEditService.
func (*Client) FileGet ¶ added in v0.1.0
func (c *Client) FileGet(documentID string) *FileGetService
FileGetService creates a new FileGetService.
func (*Client) FileList ¶ added in v0.1.0
func (c *Client) FileList(purpose string) *FileListService
FileList creates a new FileListService.
func (*Client) FineTuneCancel ¶ added in v0.1.0
func (c *Client) FineTuneCancel(jobID string) *FineTuneCancelService
FineTuneCancel creates a new fine tune cancel service
func (*Client) FineTuneCreate ¶ added in v0.1.0
func (c *Client) FineTuneCreate(model string) *FineTuneCreateService
FineTuneCreate creates a new fine tune create service
func (*Client) FineTuneDelete ¶ added in v0.1.0
func (c *Client) FineTuneDelete(jobID string) *FineTuneDeleteService
FineTuneDelete creates a new fine tune delete service
func (*Client) FineTuneEventList ¶ added in v0.1.0
func (c *Client) FineTuneEventList(jobID string) *FineTuneEventListService
FineTuneEventList creates a new fine tune event list service
func (*Client) FineTuneGet ¶ added in v0.1.0
func (c *Client) FineTuneGet(jobID string) *FineTuneGetService
FineTuneGet creates a new fine tune get service
func (*Client) FineTuneList ¶ added in v0.1.0
func (c *Client) FineTuneList() *FineTuneListService
FineTuneList creates a new fine tune list service
func (*Client) ImageGeneration ¶ added in v0.1.0
func (c *Client) ImageGeneration(model string) *ImageGenerationService
ImageGeneration creates a new image generation service
func (*Client) KnowledgeCapacity ¶ added in v0.1.0
func (c *Client) KnowledgeCapacity() *KnowledgeCapacityService
KnowledgeGet creates a new knowledge get service
func (*Client) KnowledgeCreate ¶ added in v0.1.0
func (c *Client) KnowledgeCreate() *KnowledgeCreateService
KnowledgeCreate creates a new knowledge create service
func (*Client) KnowledgeDelete ¶ added in v0.1.0
func (c *Client) KnowledgeDelete(knowledgeID string) *KnowledgeDeleteService
KnowledgeDelete creates a new knowledge delete service
func (*Client) KnowledgeEdit ¶ added in v0.1.0
func (c *Client) KnowledgeEdit(knowledgeID string) *KnowledgeEditService
KnowledgeEdit creates a new knowledge edit service
func (*Client) KnowledgeList ¶ added in v0.1.0
func (c *Client) KnowledgeList() *KnowledgeListService
KnowledgeList list all the knowledge
func (*Client) VideoGeneration ¶ added in v0.1.2
func (c *Client) VideoGeneration(model string) *VideoGenerationService
VideoGeneration creates a new video generation service
type ClientOption ¶
type ClientOption func(opts *clientOptions)
ClientOption is a function that configures the client
func WithAPIKey ¶
func WithAPIKey(apiKey string) ClientOption
WithAPIKey set the api key of the client
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL set the base url of the client
func WithHTTPClient ¶ added in v0.0.4
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient set the http client of the client
func WithRestyClient ¶ added in v0.1.3
func WithRestyClient(client *resty.Client) ClientOption
WithRestyClient set the resty client of the client
type EmbeddingData ¶ added in v0.0.3
type EmbeddingData struct { Embedding []float64 `json:"embedding"` Index int `json:"index"` Object string `json:"object"` }
EmbeddingData is the data for each embedding.
type EmbeddingResponse ¶ added in v0.0.3
type EmbeddingResponse struct { Model string `json:"model"` Data []EmbeddingData `json:"data"` Object string `json:"object"` Usage ChatCompletionUsage `json:"usage"` }
EmbeddingResponse is the response from the embedding service.
type EmbeddingService ¶ added in v0.0.3
type EmbeddingService struct {
// contains filtered or unexported fields
}
EmbeddingService embeds a list of text into a vector space.
func NewEmbeddingService ¶ added in v0.1.0
func NewEmbeddingService(client *Client) *EmbeddingService
NewEmbeddingService creates a new EmbeddingService.
func (*EmbeddingService) BatchBody ¶ added in v0.0.5
func (s *EmbeddingService) BatchBody() any
func (*EmbeddingService) BatchMethod ¶ added in v0.0.5
func (s *EmbeddingService) BatchMethod() string
func (*EmbeddingService) BatchURL ¶ added in v0.0.5
func (s *EmbeddingService) BatchURL() string
func (*EmbeddingService) Do ¶ added in v0.0.3
func (s *EmbeddingService) Do(ctx context.Context) (res EmbeddingResponse, err error)
func (*EmbeddingService) SetInput ¶ added in v0.0.3
func (s *EmbeddingService) SetInput(input string) *EmbeddingService
SetInput sets the input text to embed.
func (*EmbeddingService) SetModel ¶ added in v0.0.3
func (s *EmbeddingService) SetModel(model string) *EmbeddingService
SetModel sets the model to use for the embedding.
type FileCreateFineTuneResponse ¶ added in v0.0.5
type FileCreateFineTuneResponse struct { Bytes int64 `json:"bytes"` CreatedAt int64 `json:"created_at"` Filename string `json:"filename"` Object string `json:"object"` Purpose string `json:"purpose"` ID string `json:"id"` }
FileCreateFineTuneResponse is the response of the FileCreateService.
type FileCreateKnowledgeFailedInfo ¶ added in v0.0.5
type FileCreateKnowledgeFailedInfo struct { Filename string `json:"fileName"` FailReason string `json:"failReason"` }
FileCreateKnowledgeFailedInfo is the failed info of the FileCreateKnowledgeResponse.
type FileCreateKnowledgeResponse ¶ added in v0.0.5
type FileCreateKnowledgeResponse struct { SuccessInfos []FileCreateKnowledgeSuccessInfo `json:"successInfos"` FailedInfos []FileCreateKnowledgeFailedInfo `json:"failedInfos"` }
FileCreateKnowledgeResponse is the response of the FileCreateService.
type FileCreateKnowledgeSuccessInfo ¶ added in v0.0.5
type FileCreateKnowledgeSuccessInfo struct { Filename string `json:"fileName"` DocumentID string `json:"documentId"` }
FileCreateKnowledgeSuccessInfo is the success info of the FileCreateKnowledgeResponse.
type FileCreateResponse ¶ added in v0.0.5
type FileCreateResponse struct { FileCreateFineTuneResponse FileCreateKnowledgeResponse }
FileCreateResponse is the response of the FileCreateService.
type FileCreateService ¶ added in v0.0.5
type FileCreateService struct {
// contains filtered or unexported fields
}
FileCreateService is a service to create a file.
func NewFileCreateService ¶ added in v0.1.0
func NewFileCreateService(client *Client) *FileCreateService
NewFileCreateService creates a new FileCreateService.
func (*FileCreateService) Do ¶ added in v0.0.5
func (s *FileCreateService) Do(ctx context.Context) (res FileCreateResponse, err error)
Do makes the request.
func (*FileCreateService) SetCustomSeparator ¶ added in v0.0.5
func (s *FileCreateService) SetCustomSeparator(customSeparator string) *FileCreateService
SetCustomSeparator sets the custom_separator parameter of the FileCreateService.
func (*FileCreateService) SetFile ¶ added in v0.0.5
func (s *FileCreateService) SetFile(file io.Reader, filename string) *FileCreateService
SetFile sets the file parameter of the FileCreateService.
func (*FileCreateService) SetKnowledgeID ¶ added in v0.0.5
func (s *FileCreateService) SetKnowledgeID(knowledgeID string) *FileCreateService
SetKnowledgeID sets the knowledge_id parameter of the FileCreateService.
func (*FileCreateService) SetLocalFile ¶ added in v0.0.5
func (s *FileCreateService) SetLocalFile(localFile string) *FileCreateService
SetLocalFile sets the local_file parameter of the FileCreateService.
func (*FileCreateService) SetPurpose ¶ added in v0.0.5
func (s *FileCreateService) SetPurpose(purpose string) *FileCreateService
SetPurpose sets the purpose parameter of the FileCreateService.
func (*FileCreateService) SetSentenceSize ¶ added in v0.0.5
func (s *FileCreateService) SetSentenceSize(sentenceSize int) *FileCreateService
SetSentenceSize sets the sentence_size parameter of the FileCreateService.
type FileDeleteService ¶ added in v0.0.5
type FileDeleteService struct {
// contains filtered or unexported fields
}
FileDeleteService is a service to delete a file.
func NewFileDeleteService ¶ added in v0.1.0
func NewFileDeleteService(client *Client) *FileDeleteService
NewFileDeleteService creates a new FileDeleteService.
func (*FileDeleteService) Do ¶ added in v0.0.5
func (s *FileDeleteService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileDeleteService) SetDocumentID
deprecated
added in
v0.1.0
func (s *FileDeleteService) SetDocumentID(documentID string) *FileDeleteService
Deprecated: use SetFileID instead.
func (*FileDeleteService) SetFileID ¶ added in v0.1.4
func (s *FileDeleteService) SetFileID(fileID string) *FileDeleteService
SetFileID sets the file_id parameter of the FileDeleteService.
type FileDownloadService ¶ added in v0.0.5
type FileDownloadService struct {
// contains filtered or unexported fields
}
FileDownloadService is a service to download a file.
func NewFileDownloadService ¶ added in v0.1.0
func NewFileDownloadService(client *Client) *FileDownloadService
NewFileDownloadService creates a new FileDownloadService.
func (*FileDownloadService) Do ¶ added in v0.0.5
func (s *FileDownloadService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileDownloadService) SetFileID ¶ added in v0.1.0
func (s *FileDownloadService) SetFileID(fileID string) *FileDownloadService
SetFileID sets the file_id parameter of the FileDownloadService.
func (*FileDownloadService) SetOutput ¶ added in v0.0.5
func (s *FileDownloadService) SetOutput(w io.Writer) *FileDownloadService
SetOutput sets the output parameter of the FileDownloadService.
func (*FileDownloadService) SetOutputFile ¶ added in v0.0.5
func (s *FileDownloadService) SetOutputFile(filename string) *FileDownloadService
SetOutputFile sets the output_file parameter of the FileDownloadService.
type FileEditService ¶ added in v0.0.5
type FileEditService struct {
// contains filtered or unexported fields
}
FileEditService is a service to edit a file.
func NewFileEditService ¶ added in v0.1.0
func NewFileEditService(client *Client) *FileEditService
NewFileEditService creates a new FileEditService.
func (*FileEditService) Do ¶ added in v0.0.5
func (s *FileEditService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileEditService) SetCustomSeparator ¶ added in v0.0.5
func (s *FileEditService) SetCustomSeparator(customSeparator ...string) *FileEditService
SetSentenceSize sets the sentence_size parameter of the FileEditService.
func (*FileEditService) SetDocumentID ¶ added in v0.1.0
func (s *FileEditService) SetDocumentID(documentID string) *FileEditService
SetDocumentID sets the document_id parameter of the FileEditService.
func (*FileEditService) SetKnowledgeType ¶ added in v0.0.5
func (s *FileEditService) SetKnowledgeType(knowledgeType int) *FileEditService
SetKnowledgeType sets the knowledge_type parameter of the FileEditService.
func (*FileEditService) SetSentenceSize ¶ added in v0.0.5
func (s *FileEditService) SetSentenceSize(sentenceSize int) *FileEditService
SetSentenceSize sets the sentence_size parameter of the FileEditService.
type FileFailInfo ¶ added in v0.0.5
type FileFailInfo struct { EmbeddingCode int `json:"embedding_code"` EmbeddingMsg string `json:"embedding_msg"` }
FileFailInfo is the failed info of the FileListKnowledgeItem.
type FileGetResponse ¶ added in v0.0.5
type FileGetResponse = FileListKnowledgeItem
FileGetResponse is the response of the FileGetService.
type FileGetService ¶ added in v0.0.5
type FileGetService struct {
// contains filtered or unexported fields
}
FileGetService is a service to get a file.
func NewFileGetService ¶ added in v0.1.0
func NewFileGetService(client *Client) *FileGetService
NewFileGetService creates a new FileGetService.
func (*FileGetService) Do ¶ added in v0.0.5
func (s *FileGetService) Do(ctx context.Context) (res FileGetResponse, err error)
Do makes the request.
func (*FileGetService) SetDocumentID ¶ added in v0.1.0
func (s *FileGetService) SetDocumentID(documentID string) *FileGetService
SetDocumentID sets the document_id parameter of the FileGetService.
type FileListFineTuneItem ¶ added in v0.0.5
type FileListFineTuneItem struct { Bytes int64 `json:"bytes"` CreatedAt int64 `json:"created_at"` Filename string `json:"filename"` ID string `json:"id"` Object string `json:"object"` Purpose string `json:"purpose"` }
FileListFineTuneItem is the item of the FileListFineTuneResponse.
type FileListFineTuneResponse ¶ added in v0.0.5
type FileListFineTuneResponse struct { Object string `json:"object"` Data []FileListFineTuneItem `json:"data"` }
FileListFineTuneResponse is the response of the FileListService.
type FileListKnowledgeItem ¶ added in v0.0.5
type FileListKnowledgeItem struct { ID string `json:"id"` Name string `json:"name"` URL string `json:"url"` Length int64 `json:"length"` SentenceSize int64 `json:"sentence_size"` CustomSeparator []string `json:"custom_separator"` EmbeddingStat int `json:"embedding_stat"` FailInfo *FileFailInfo `json:"failInfo"` WordNum int64 `json:"word_num"` ParseImage int `json:"parse_image"` }
FileListKnowledgeItem is the item of the FileListKnowledgeResponse.
type FileListKnowledgeResponse ¶ added in v0.0.5
type FileListKnowledgeResponse struct { Total int `json:"total"` List []FileListKnowledgeItem `json:"list"` }
FileListKnowledgeResponse is the response of the FileListService.
type FileListResponse ¶ added in v0.0.5
type FileListResponse struct { FileListKnowledgeResponse FileListFineTuneResponse }
FileListResponse is the response of the FileListService.
type FileListService ¶ added in v0.0.5
type FileListService struct {
// contains filtered or unexported fields
}
FileListService is a service to list files.
func NewFileListService ¶ added in v0.1.0
func NewFileListService(client *Client) *FileListService
NewFileListService creates a new FileListService.
func (*FileListService) Do ¶ added in v0.0.5
func (s *FileListService) Do(ctx context.Context) (res FileListResponse, err error)
Do makes the request.
func (*FileListService) SetAfter ¶ added in v0.0.5
func (s *FileListService) SetAfter(after string) *FileListService
SetAfter sets the after parameter of the FileListService.
func (*FileListService) SetKnowledgeID ¶ added in v0.0.5
func (s *FileListService) SetKnowledgeID(knowledgeID string) *FileListService
SetKnowledgeID sets the knowledge_id parameter of the FileListService.
func (*FileListService) SetLimit ¶ added in v0.0.5
func (s *FileListService) SetLimit(limit int) *FileListService
SetLimit sets the limit parameter of the FileListService.
func (*FileListService) SetOrder ¶ added in v0.0.5
func (s *FileListService) SetOrder(asc bool) *FileListService
SetOrder sets the order parameter of the FileListService.
func (*FileListService) SetPage ¶ added in v0.0.5
func (s *FileListService) SetPage(page int) *FileListService
SetPage sets the page parameter of the FileListService.
func (*FileListService) SetPurpose ¶ added in v0.0.5
func (s *FileListService) SetPurpose(purpose string) *FileListService
SetPurpose sets the purpose parameter of the FileListService.
type FineTuneCancelService ¶ added in v0.0.6
type FineTuneCancelService struct {
// contains filtered or unexported fields
}
FineTuneCancelService creates a new fine tune cancel
func NewFineTuneCancelService ¶ added in v0.1.0
func NewFineTuneCancelService(client *Client) *FineTuneCancelService
NewFineTuneCancelService creates a new FineTuneCancelService
func (*FineTuneCancelService) Do ¶ added in v0.0.6
func (s *FineTuneCancelService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneCancelService) SetJobID ¶ added in v0.0.6
func (s *FineTuneCancelService) SetJobID(jobID string) *FineTuneCancelService
SetJobID sets the jobID parameter
type FineTuneCreateResponse ¶ added in v0.0.6
type FineTuneCreateResponse = FineTuneItem
FineTuneCreateResponse is the response of the FineTuneCreateService
type FineTuneCreateService ¶ added in v0.0.6
type FineTuneCreateService struct {
// contains filtered or unexported fields
}
FineTuneCreateService creates a new fine tune
func NewFineTuneCreateService ¶ added in v0.1.0
func NewFineTuneCreateService(client *Client) *FineTuneCreateService
NewFineTuneCreateService creates a new FineTuneCreateService
func (*FineTuneCreateService) Do ¶ added in v0.0.6
func (s *FineTuneCreateService) Do(ctx context.Context) (res FineTuneCreateResponse, err error)
Do makes the request
func (*FineTuneCreateService) SetBatchSize ¶ added in v0.0.6
func (s *FineTuneCreateService) SetBatchSize(batchSize int) *FineTuneCreateService
SetBatchSize sets the batchSize parameter
func (*FineTuneCreateService) SetBatchSizeAuto ¶ added in v0.0.6
func (s *FineTuneCreateService) SetBatchSizeAuto() *FineTuneCreateService
SetBatchSizeAuto sets the batchSize parameter to auto
func (*FineTuneCreateService) SetLearningRateMultiplier ¶ added in v0.0.6
func (s *FineTuneCreateService) SetLearningRateMultiplier(learningRateMultiplier float64) *FineTuneCreateService
SetLearningRateMultiplier sets the learningRateMultiplier parameter
func (*FineTuneCreateService) SetLearningRateMultiplierAuto ¶ added in v0.0.6
func (s *FineTuneCreateService) SetLearningRateMultiplierAuto() *FineTuneCreateService
SetLearningRateMultiplierAuto sets the learningRateMultiplier parameter to auto
func (*FineTuneCreateService) SetModel ¶ added in v0.0.6
func (s *FineTuneCreateService) SetModel(model string) *FineTuneCreateService
SetModel sets the model parameter
func (*FineTuneCreateService) SetNEpochs ¶ added in v0.0.6
func (s *FineTuneCreateService) SetNEpochs(nEpochs int) *FineTuneCreateService
SetNEpochs sets the nEpochs parameter
func (*FineTuneCreateService) SetNEpochsAuto ¶ added in v0.0.6
func (s *FineTuneCreateService) SetNEpochsAuto() *FineTuneCreateService
SetNEpochsAuto sets the nEpochs parameter to auto
func (*FineTuneCreateService) SetRequestID ¶ added in v0.0.6
func (s *FineTuneCreateService) SetRequestID(requestID string) *FineTuneCreateService
SetRequestID sets the requestID parameter
func (*FineTuneCreateService) SetSuffix ¶ added in v0.0.6
func (s *FineTuneCreateService) SetSuffix(suffix string) *FineTuneCreateService
SetSuffix sets the suffix parameter
func (*FineTuneCreateService) SetTrainingFile ¶ added in v0.0.6
func (s *FineTuneCreateService) SetTrainingFile(trainingFile string) *FineTuneCreateService
SetTrainingFile sets the trainingFile parameter
func (*FineTuneCreateService) SetValidationFile ¶ added in v0.0.6
func (s *FineTuneCreateService) SetValidationFile(validationFile string) *FineTuneCreateService
SetValidationFile sets the validationFile parameter
type FineTuneDeleteService ¶ added in v0.0.6
type FineTuneDeleteService struct {
// contains filtered or unexported fields
}
FineTuneDeleteService creates a new fine tune delete
func NewFineTuneDeleteService ¶ added in v0.1.0
func NewFineTuneDeleteService(client *Client) *FineTuneDeleteService
NewFineTuneDeleteService creates a new FineTuneDeleteService
func (*FineTuneDeleteService) Do ¶ added in v0.0.6
func (s *FineTuneDeleteService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneDeleteService) SetJobID ¶ added in v0.0.6
func (s *FineTuneDeleteService) SetJobID(jobID string) *FineTuneDeleteService
SetJobID sets the jobID parameter
type FineTuneEventData ¶ added in v0.0.6
type FineTuneEventData struct { Acc float64 `json:"acc"` Loss float64 `json:"loss"` CurrentSteps int64 `json:"current_steps"` RemainingTime string `json:"remaining_time"` ElapsedTime string `json:"elapsed_time"` TotalSteps int64 `json:"total_steps"` Epoch int64 `json:"epoch"` TrainedTokens int64 `json:"trained_tokens"` LearningRate float64 `json:"learning_rate"` }
FineTuneEventData is the data of the FineTuneEventItem
type FineTuneEventItem ¶ added in v0.0.6
type FineTuneEventItem struct { ID string `json:"id"` Type string `json:"type"` Level string `json:"level"` Message string `json:"message"` Object string `json:"object"` CreatedAt int64 `json:"created_at"` Data FineTuneEventData `json:"data"` }
FineTuneEventItem is the item of the FineTuneEventListResponse
type FineTuneEventListResponse ¶ added in v0.0.6
type FineTuneEventListResponse struct { Data []FineTuneEventItem `json:"data"` HasMore bool `json:"has_more"` Object string `json:"object"` }
FineTuneEventListResponse is the response of the FineTuneEventListService
type FineTuneEventListService ¶ added in v0.0.6
type FineTuneEventListService struct {
// contains filtered or unexported fields
}
FineTuneEventListService creates a new fine tune event list
func NewFineTuneEventListService ¶ added in v0.1.0
func NewFineTuneEventListService(client *Client) *FineTuneEventListService
NewFineTuneEventListService creates a new FineTuneEventListService
func (*FineTuneEventListService) Do ¶ added in v0.0.6
func (s *FineTuneEventListService) Do(ctx context.Context) (res FineTuneEventListResponse, err error)
Do makes the request
func (*FineTuneEventListService) SetAfter ¶ added in v0.0.6
func (s *FineTuneEventListService) SetAfter(after string) *FineTuneEventListService
SetAfter sets the after parameter
func (*FineTuneEventListService) SetJobID ¶ added in v0.0.6
func (s *FineTuneEventListService) SetJobID(jobID string) *FineTuneEventListService
SetJobID sets the jobID parameter
func (*FineTuneEventListService) SetLimit ¶ added in v0.0.6
func (s *FineTuneEventListService) SetLimit(limit int) *FineTuneEventListService
SetLimit sets the limit parameter
type FineTuneGetService ¶ added in v0.0.6
type FineTuneGetService struct {
// contains filtered or unexported fields
}
FineTuneGetService creates a new fine tune get
func NewFineTuneGetService ¶ added in v0.1.0
func NewFineTuneGetService(client *Client) *FineTuneGetService
NewFineTuneGetService creates a new FineTuneGetService
func (*FineTuneGetService) Do ¶ added in v0.0.6
func (s *FineTuneGetService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneGetService) SetJobID ¶ added in v0.0.6
func (s *FineTuneGetService) SetJobID(jobID string) *FineTuneGetService
SetJobID sets the jobID parameter
type FineTuneItem ¶ added in v0.0.6
type FineTuneItem struct { ID string `json:"id"` RequestID string `json:"request_id"` FineTunedModel string `json:"fine_tuned_model"` Status string `json:"status"` Object string `json:"object"` TrainingFile string `json:"training_file"` ValidationFile string `json:"validation_file"` Error APIError `json:"error"` }
FineTuneItem is the item of the FineTune
type FineTuneListResponse ¶ added in v0.0.6
type FineTuneListResponse struct { Data []FineTuneItem `json:"data"` Object string `json:"object"` }
FineTuneListResponse is the response of the FineTuneListService
type FineTuneListService ¶ added in v0.0.6
type FineTuneListService struct {
// contains filtered or unexported fields
}
FineTuneListService creates a new fine tune list
func NewFineTuneListService ¶ added in v0.1.0
func NewFineTuneListService(client *Client) *FineTuneListService
NewFineTuneListService creates a new FineTuneListService
func (*FineTuneListService) Do ¶ added in v0.0.6
func (s *FineTuneListService) Do(ctx context.Context) (res FineTuneListResponse, err error)
Do makes the request
func (*FineTuneListService) SetAfter ¶ added in v0.0.6
func (s *FineTuneListService) SetAfter(after string) *FineTuneListService
SetAfter sets the after parameter
func (*FineTuneListService) SetLimit ¶ added in v0.0.6
func (s *FineTuneListService) SetLimit(limit int) *FineTuneListService
SetLimit sets the limit parameter
type IDItem ¶ added in v0.0.6
type IDItem struct {
ID string `json:"id,omitempty"`
}
IDItem is a struct that contains an ID.
type ImageGenerationResponse ¶ added in v0.0.3
ImageGenerationResponse is the response of the ImageGenerationService
type ImageGenerationService ¶ added in v0.0.3
type ImageGenerationService struct {
// contains filtered or unexported fields
}
ImageGenerationService creates a new image generation
func NewImageGenerationService ¶ added in v0.1.0
func NewImageGenerationService(client *Client) *ImageGenerationService
NewImageGenerationService creates a new ImageGenerationService
func (*ImageGenerationService) BatchBody ¶ added in v0.0.5
func (s *ImageGenerationService) BatchBody() any
func (*ImageGenerationService) BatchMethod ¶ added in v0.0.5
func (s *ImageGenerationService) BatchMethod() string
func (*ImageGenerationService) BatchURL ¶ added in v0.0.5
func (s *ImageGenerationService) BatchURL() string
func (*ImageGenerationService) Do ¶ added in v0.0.3
func (s *ImageGenerationService) Do(ctx context.Context) (res ImageGenerationResponse, err error)
func (*ImageGenerationService) SetModel ¶ added in v0.0.3
func (s *ImageGenerationService) SetModel(model string) *ImageGenerationService
SetModel sets the model parameter
func (*ImageGenerationService) SetPrompt ¶ added in v0.0.3
func (s *ImageGenerationService) SetPrompt(prompt string) *ImageGenerationService
SetPrompt sets the prompt parameter
func (*ImageGenerationService) SetUserID ¶ added in v0.0.3
func (s *ImageGenerationService) SetUserID(userID string) *ImageGenerationService
SetUserID sets the userID parameter
type KnowledgeCapacityItem ¶ added in v0.1.0
KnowledgeCapacityItem is an item in the knowledge capacity
type KnowledgeCapacityResponse ¶ added in v0.1.0
type KnowledgeCapacityResponse struct { Used KnowledgeCapacityItem `json:"used"` Total KnowledgeCapacityItem `json:"total"` }
KnowledgeCapacityResponse is the response of the KnowledgeCapacityService
type KnowledgeCapacityService ¶ added in v0.1.0
type KnowledgeCapacityService struct {
// contains filtered or unexported fields
}
KnowledgeCapacityService query the capacity of the knowledge
func NewKnowledgeCapacityService ¶ added in v0.1.0
func NewKnowledgeCapacityService(client *Client) *KnowledgeCapacityService
SetKnowledgeID sets the knowledge id
func (*KnowledgeCapacityService) Do ¶ added in v0.1.0
func (s *KnowledgeCapacityService) Do(ctx context.Context) (res KnowledgeCapacityResponse, err error)
Do query the capacity of the knowledge
type KnowledgeCreateResponse ¶ added in v0.0.6
type KnowledgeCreateResponse = IDItem
KnowledgeCreateResponse is the response of the KnowledgeCreateService
type KnowledgeCreateService ¶ added in v0.0.6
type KnowledgeCreateService struct {
// contains filtered or unexported fields
}
KnowledgeCreateService creates a new knowledge
func NewKnowledgeCreateService ¶ added in v0.1.0
func NewKnowledgeCreateService(client *Client) *KnowledgeCreateService
NewKnowledgeCreateService creates a new KnowledgeCreateService
func (*KnowledgeCreateService) Do ¶ added in v0.0.6
func (s *KnowledgeCreateService) Do(ctx context.Context) (res KnowledgeCreateResponse, err error)
Do creates the knowledge
func (*KnowledgeCreateService) SetDescription ¶ added in v0.0.6
func (s *KnowledgeCreateService) SetDescription(description string) *KnowledgeCreateService
SetDescription sets the description of the knowledge
func (*KnowledgeCreateService) SetEmbeddingID ¶ added in v0.0.6
func (s *KnowledgeCreateService) SetEmbeddingID(embeddingID int) *KnowledgeCreateService
SetEmbeddingID sets the embedding id of the knowledge
func (*KnowledgeCreateService) SetName ¶ added in v0.0.6
func (s *KnowledgeCreateService) SetName(name string) *KnowledgeCreateService
SetName sets the name of the knowledge
type KnowledgeDeleteService ¶ added in v0.0.6
type KnowledgeDeleteService struct {
// contains filtered or unexported fields
}
KnowledgeDeleteService deletes a knowledge
func NewKnowledgeDeleteService ¶ added in v0.1.0
func NewKnowledgeDeleteService(client *Client) *KnowledgeDeleteService
NewKnowledgeDeleteService creates a new KnowledgeDeleteService
func (*KnowledgeDeleteService) Do ¶ added in v0.0.6
func (s *KnowledgeDeleteService) Do(ctx context.Context) (err error)
Do deletes the knowledge
func (*KnowledgeDeleteService) SetKnowledgeID ¶ added in v0.0.6
func (s *KnowledgeDeleteService) SetKnowledgeID(knowledgeID string) *KnowledgeDeleteService
SetKnowledgeID sets the knowledge id
type KnowledgeEditService ¶ added in v0.0.6
type KnowledgeEditService struct {
// contains filtered or unexported fields
}
KnowledgeEditService edits a knowledge
func NewKnowledgeEditService ¶ added in v0.1.0
func NewKnowledgeEditService(client *Client) *KnowledgeEditService
NewKnowledgeEditService creates a new KnowledgeEditService
func (*KnowledgeEditService) Do ¶ added in v0.0.6
func (s *KnowledgeEditService) Do(ctx context.Context) (err error)
Do edits the knowledge
func (*KnowledgeEditService) SetDescription ¶ added in v0.0.6
func (s *KnowledgeEditService) SetDescription(description string) *KnowledgeEditService
SetDescription sets the description of the knowledge
func (*KnowledgeEditService) SetEmbeddingID ¶ added in v0.0.6
func (s *KnowledgeEditService) SetEmbeddingID(embeddingID int) *KnowledgeEditService
SetEmbeddingID sets the embedding id of the knowledge
func (*KnowledgeEditService) SetKnowledgeID ¶ added in v0.1.0
func (s *KnowledgeEditService) SetKnowledgeID(knowledgeID string) *KnowledgeEditService
SetKnowledgeID sets the knowledge id
func (*KnowledgeEditService) SetName ¶ added in v0.0.6
func (s *KnowledgeEditService) SetName(name string) *KnowledgeEditService
SetName sets the name of the knowledge
type KnowledgeItem ¶ added in v0.0.6
type KnowledgeItem struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Background string `json:"background"` EmbeddingID int `json:"embedding_id"` CustomIdentifier string `json:"custom_identifier"` WordNum int64 `json:"word_num"` Length int64 `json:"length"` DocumentSize int64 `json:"document_size"` }
KnowledgeItem is an item in the knowledge list
type KnowledgeListResponse ¶ added in v0.0.6
type KnowledgeListResponse struct { List []KnowledgeItem `json:"list"` Total int `json:"total"` }
KnowledgeListResponse is the response of the KnowledgeListService
type KnowledgeListService ¶ added in v0.0.6
type KnowledgeListService struct {
// contains filtered or unexported fields
}
KnowledgeListService lists the knowledge
func NewKnowledgeListService ¶ added in v0.1.0
func NewKnowledgeListService(client *Client) *KnowledgeListService
NewKnowledgeListService creates a new KnowledgeListService
func (*KnowledgeListService) Do ¶ added in v0.0.6
func (s *KnowledgeListService) Do(ctx context.Context) (res KnowledgeListResponse, err error)
Do lists the knowledge
func (*KnowledgeListService) SetPage ¶ added in v0.0.6
func (s *KnowledgeListService) SetPage(page int) *KnowledgeListService
SetPage sets the page of the knowledge list
func (*KnowledgeListService) SetSize ¶ added in v0.0.6
func (s *KnowledgeListService) SetSize(size int) *KnowledgeListService
SetSize sets the size of the knowledge list
type StringOr ¶ added in v0.0.6
StringOr is a struct that can be either a string or a value of type T.
func (StringOr[T]) MarshalJSON ¶ added in v0.0.6
func (*StringOr[T]) SetValue ¶ added in v0.0.6
func (f *StringOr[T]) SetValue(v T)
SetValue sets the value of the struct.
func (*StringOr[T]) UnmarshalJSON ¶ added in v0.0.6
type URLItem ¶ added in v0.1.0
type URLItem struct {
URL string `json:"url,omitempty"`
}
URLItem is a struct that contains a URL.
type VideoGenerationResponse ¶ added in v0.1.2
type VideoGenerationResponse struct { RequestID string `json:"request_id"` ID string `json:"id"` Model string `json:"model"` TaskStatus string `json:"task_status"` }
VideoGenerationResponse is the response of the VideoGenerationService
type VideoGenerationService ¶ added in v0.1.2
type VideoGenerationService struct {
// contains filtered or unexported fields
}
VideoGenerationService creates a new video generation
func NewVideoGenerationService ¶ added in v0.1.2
func NewVideoGenerationService(client *Client) *VideoGenerationService
func (*VideoGenerationService) BatchBody ¶ added in v0.1.2
func (s *VideoGenerationService) BatchBody() any
func (*VideoGenerationService) BatchMethod ¶ added in v0.1.2
func (s *VideoGenerationService) BatchMethod() string
func (*VideoGenerationService) BatchURL ¶ added in v0.1.2
func (s *VideoGenerationService) BatchURL() string
func (*VideoGenerationService) Do ¶ added in v0.1.2
func (s *VideoGenerationService) Do(ctx context.Context) (res VideoGenerationResponse, err error)
func (*VideoGenerationService) SetImageURL ¶ added in v0.1.2
func (s *VideoGenerationService) SetImageURL(imageURL string) *VideoGenerationService
SetImageURL sets the imageURL parameter
func (*VideoGenerationService) SetModel ¶ added in v0.1.2
func (s *VideoGenerationService) SetModel(model string) *VideoGenerationService
SetModel sets the model parameter
func (*VideoGenerationService) SetPrompt ¶ added in v0.1.2
func (s *VideoGenerationService) SetPrompt(prompt string) *VideoGenerationService
SetPrompt sets the prompt parameter
func (*VideoGenerationService) SetRequestID ¶ added in v0.1.2
func (s *VideoGenerationService) SetRequestID(requestID string) *VideoGenerationService
SetRequestID sets the requestID parameter
func (*VideoGenerationService) SetUserID ¶ added in v0.1.2
func (s *VideoGenerationService) SetUserID(userID string) *VideoGenerationService
SetUserID sets the userID parameter