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) 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(documentID 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) SetSize(size 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" MultiContentTypeVideoURL = "video_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" )
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 ¶
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 ¶
type AsyncResultService struct {
// contains filtered or unexported fields
}
AsyncResultService creates a new async result get service
func NewAsyncResultService ¶
func NewAsyncResultService(client *Client) *AsyncResultService
NewAsyncResultService creates a new async result get service
func (*AsyncResultService) Do ¶
func (s *AsyncResultService) Do(ctx context.Context) (res AsyncResultResponse, err error)
func (*AsyncResultService) SetID ¶
func (s *AsyncResultService) SetID(id string) *AsyncResultService
SetID sets the id parameter
type AsyncResultVideo ¶
type AsyncResultVideo struct {
URL string `json:"url"`
CoverImageURL string `json:"cover_image_url"`
}
AsyncResultVideo is the video result of the AsyncResultService
type BatchCancelService ¶
type BatchCancelService struct {
// contains filtered or unexported fields
}
BatchCancelService is a service to cancel a batch.
func NewBatchCancelService ¶
func NewBatchCancelService(client *Client) *BatchCancelService
NewBatchCancelService creates a new BatchCancelService.
func (*BatchCancelService) Do ¶
func (s *BatchCancelService) Do(ctx context.Context) (err error)
Do executes the batch cancel service.
func (*BatchCancelService) SetBatchID ¶
func (s *BatchCancelService) SetBatchID(batchID string) *BatchCancelService
SetBatchID sets the batch id for the batch cancel service.
type BatchCreateService ¶
type BatchCreateService struct {
// contains filtered or unexported fields
}
BatchCreateService is a service to create a batch.
func NewBatchCreateService ¶
func NewBatchCreateService(client *Client) *BatchCreateService
NewBatchCreateService creates a new BatchCreateService.
func (*BatchCreateService) Do ¶
func (s *BatchCreateService) Do(ctx context.Context) (res BatchItem, err error)
Do executes the batch create service.
func (*BatchCreateService) SetCompletionWindow ¶
func (s *BatchCreateService) SetCompletionWindow(window string) *BatchCreateService
SetCompletionWindow sets the completion window for the batch.
func (*BatchCreateService) SetEndpoint ¶
func (s *BatchCreateService) SetEndpoint(endpoint string) *BatchCreateService
SetEndpoint sets the endpoint for the batch.
func (*BatchCreateService) SetInputFileID ¶
func (s *BatchCreateService) SetInputFileID(inputFileID string) *BatchCreateService
SetInputFileID sets the input file id for the batch.
func (*BatchCreateService) SetMetadata ¶
func (s *BatchCreateService) SetMetadata(metadata any) *BatchCreateService
SetMetadata sets the metadata for the batch.
type BatchFileWriter ¶
type BatchFileWriter struct {
// contains filtered or unexported fields
}
BatchFileWriter is a writer for batch files.
func NewBatchFileWriter ¶
func NewBatchFileWriter(w io.Writer) *BatchFileWriter
NewBatchFileWriter creates a new BatchFileWriter.
func (*BatchFileWriter) Write ¶
func (b *BatchFileWriter) Write(customID string, s BatchSupport) error
Write writes a batch file.
type BatchGetResponse ¶
type BatchGetResponse = BatchItem
BatchGetResponse represents the response of the batch get service.
type BatchGetService ¶
type BatchGetService struct {
// contains filtered or unexported fields
}
BatchGetService is a service to get a batch.
func NewBatchGetService ¶
func NewBatchGetService(client *Client) *BatchGetService
NewBatchGetService creates a new BatchGetService.
func (*BatchGetService) Do ¶
func (s *BatchGetService) Do(ctx context.Context) (res BatchGetResponse, err error)
Do executes the batch get service.
func (*BatchGetService) SetBatchID ¶
func (s *BatchGetService) SetBatchID(batchID string) *BatchGetService
SetBatchID sets the batch id for the batch get service.
type BatchItem ¶
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 ¶
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 ¶
type BatchListService struct {
// contains filtered or unexported fields
}
BatchListService is a service to list batches.
func NewBatchListService ¶
func NewBatchListService(client *Client) *BatchListService
NewBatchListService creates a new BatchListService.
func (*BatchListService) Do ¶
func (s *BatchListService) Do(ctx context.Context) (res BatchListResponse, err error)
Do executes the batch list service.
func (*BatchListService) SetAfter ¶
func (s *BatchListService) SetAfter(after string) *BatchListService
SetAfter sets the after cursor for the batch list service.
func (*BatchListService) SetLimit ¶
func (s *BatchListService) SetLimit(limit int) *BatchListService
SetLimit sets the limit for the batch list service.
type BatchRequestCounts ¶
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 ¶
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 ¶
type BatchResultReader[T any] struct { // contains filtered or unexported fields }
BatchResultReader reads batch results.
func NewBatchResultReader ¶
func NewBatchResultReader[T any](r io.Reader) *BatchResultReader[T]
NewBatchResultReader creates a new BatchResultReader.
func (*BatchResultReader[T]) Read ¶
func (r *BatchResultReader[T]) Read(out *BatchResult[T]) error
Read reads a batch result.
type BatchResultResponse ¶
BatchResultResponse is the response of a batch result.
type BatchSupport ¶
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 ¶
type ChatCompletionMessageType interface {
// contains filtered or unexported methods
}
type ChatCompletionMeta ¶
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 ChatCompletionMultiMessage ¶
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 ¶
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 ¶
func (s *ChatCompletionService) BatchBody() any
func (*ChatCompletionService) BatchMethod ¶
func (s *ChatCompletionService) BatchMethod() string
func (*ChatCompletionService) BatchURL ¶
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 ¶
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) 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 ¶
type ChatCompletionToolCallCodeInterpreter struct {
Input string `json:"input"`
Outputs []ChatCompletionToolCallCodeInterpreterOutput `json:"outputs"`
}
ChatCompletionToolCallCodeInterpreter is the code interpreter for chat completion tool call
type ChatCompletionToolCallCodeInterpreterOutput ¶
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 ¶
type ChatCompletionToolCallDrawingTool struct {
Input string `json:"input"`
Outputs []ChatCompletionToolCallDrawingToolOutput `json:"outputs"`
}
ChatCompletionToolCallDrawingTool is the drawing tool for chat completion tool call
type ChatCompletionToolCallDrawingToolOutput ¶
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 ¶
type ChatCompletionToolCallWebBrowser struct {
Input string `json:"input"`
Outputs []ChatCompletionToolCallWebBrowserOutput `json:"outputs"`
}
ChatCompletionToolCallWebBrowser is the web browser for chat completion tool call
type ChatCompletionToolCallWebBrowserOutput ¶
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 ¶
type ChatCompletionToolCodeInterpreter struct {
Sandbox *string `json:"sandbox,omitempty"`
}
ChatCompletionToolCodeInterpreter is the code interpreter for chat completion only in GLM-4-AllTools
type ChatCompletionToolDrawingTool ¶
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 ¶
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 ¶
func (c *Client) AsyncResult(id string) *AsyncResultService
AsyncResult creates a new async result get service
func (*Client) BatchCancel ¶
func (c *Client) BatchCancel(batchID string) *BatchCancelService
BatchCancel creates a new BatchCancelService.
func (*Client) BatchCreate ¶
func (c *Client) BatchCreate() *BatchCreateService
BatchCreate creates a new BatchCreateService.
func (*Client) BatchGet ¶
func (c *Client) BatchGet(batchID string) *BatchGetService
BatchGet creates a new BatchGetService.
func (*Client) BatchList ¶
func (c *Client) BatchList() *BatchListService
BatchList creates a new BatchListService.
func (*Client) ChatCompletion ¶
func (c *Client) ChatCompletion(model string) *ChatCompletionService
ChatCompletion creates a new ChatCompletionService.
func (*Client) Embedding ¶
func (c *Client) Embedding(model string) *EmbeddingService
Embedding embeds a list of text into a vector space.
func (*Client) FileCreate ¶
func (c *Client) FileCreate(purpose string) *FileCreateService
FileCreate creates a new FileCreateService.
func (*Client) FileDelete ¶
func (c *Client) FileDelete(documentID string) *FileDeleteService
FileDeleteService creates a new FileDeleteService.
func (*Client) FileDownload ¶
func (c *Client) FileDownload(fileID string) *FileDownloadService
FileDownload creates a new FileDownloadService.
func (*Client) FileEdit ¶
func (c *Client) FileEdit(documentID string) *FileEditService
FileEditService creates a new FileEditService.
func (*Client) FileGet ¶
func (c *Client) FileGet(documentID string) *FileGetService
FileGetService creates a new FileGetService.
func (*Client) FileList ¶
func (c *Client) FileList(purpose string) *FileListService
FileList creates a new FileListService.
func (*Client) FineTuneCancel ¶
func (c *Client) FineTuneCancel(jobID string) *FineTuneCancelService
FineTuneCancel creates a new fine tune cancel service
func (*Client) FineTuneCreate ¶
func (c *Client) FineTuneCreate(model string) *FineTuneCreateService
FineTuneCreate creates a new fine tune create service
func (*Client) FineTuneDelete ¶
func (c *Client) FineTuneDelete(jobID string) *FineTuneDeleteService
FineTuneDelete creates a new fine tune delete service
func (*Client) FineTuneEventList ¶
func (c *Client) FineTuneEventList(jobID string) *FineTuneEventListService
FineTuneEventList creates a new fine tune event list service
func (*Client) FineTuneGet ¶
func (c *Client) FineTuneGet(jobID string) *FineTuneGetService
FineTuneGet creates a new fine tune get service
func (*Client) FineTuneList ¶
func (c *Client) FineTuneList() *FineTuneListService
FineTuneList creates a new fine tune list service
func (*Client) ImageGeneration ¶
func (c *Client) ImageGeneration(model string) *ImageGenerationService
ImageGeneration creates a new image generation service
func (*Client) KnowledgeCapacity ¶
func (c *Client) KnowledgeCapacity() *KnowledgeCapacityService
KnowledgeGet creates a new knowledge get service
func (*Client) KnowledgeCreate ¶
func (c *Client) KnowledgeCreate() *KnowledgeCreateService
KnowledgeCreate creates a new knowledge create service
func (*Client) KnowledgeDelete ¶
func (c *Client) KnowledgeDelete(knowledgeID string) *KnowledgeDeleteService
KnowledgeDelete creates a new knowledge delete service
func (*Client) KnowledgeEdit ¶
func (c *Client) KnowledgeEdit(knowledgeID string) *KnowledgeEditService
KnowledgeEdit creates a new knowledge edit service
func (*Client) KnowledgeList ¶
func (c *Client) KnowledgeList() *KnowledgeListService
KnowledgeList list all the knowledge
func (*Client) VideoGeneration ¶
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 ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient set the http client of the client
type EmbeddingData ¶
type EmbeddingData struct {
Embedding []float64 `json:"embedding"`
Index int `json:"index"`
Object string `json:"object"`
}
EmbeddingData is the data for each embedding.
type EmbeddingResponse ¶
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 ¶
type EmbeddingService struct {
// contains filtered or unexported fields
}
EmbeddingService embeds a list of text into a vector space.
func NewEmbeddingService ¶
func NewEmbeddingService(client *Client) *EmbeddingService
NewEmbeddingService creates a new EmbeddingService.
func (*EmbeddingService) BatchBody ¶
func (s *EmbeddingService) BatchBody() any
func (*EmbeddingService) BatchMethod ¶
func (s *EmbeddingService) BatchMethod() string
func (*EmbeddingService) BatchURL ¶
func (s *EmbeddingService) BatchURL() string
func (*EmbeddingService) Do ¶
func (s *EmbeddingService) Do(ctx context.Context) (res EmbeddingResponse, err error)
func (*EmbeddingService) SetInput ¶
func (s *EmbeddingService) SetInput(input string) *EmbeddingService
SetInput sets the input text to embed.
func (*EmbeddingService) SetModel ¶
func (s *EmbeddingService) SetModel(model string) *EmbeddingService
SetModel sets the model to use for the embedding.
type FileCreateFineTuneResponse ¶
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 ¶
type FileCreateKnowledgeFailedInfo struct {
Filename string `json:"fileName"`
FailReason string `json:"failReason"`
}
FileCreateKnowledgeFailedInfo is the failed info of the FileCreateKnowledgeResponse.
type FileCreateKnowledgeResponse ¶
type FileCreateKnowledgeResponse struct {
SuccessInfos []FileCreateKnowledgeSuccessInfo `json:"successInfos"`
FailedInfos []FileCreateKnowledgeFailedInfo `json:"failedInfos"`
}
FileCreateKnowledgeResponse is the response of the FileCreateService.
type FileCreateKnowledgeSuccessInfo ¶
type FileCreateKnowledgeSuccessInfo struct {
Filename string `json:"fileName"`
DocumentID string `json:"documentId"`
}
FileCreateKnowledgeSuccessInfo is the success info of the FileCreateKnowledgeResponse.
type FileCreateResponse ¶
type FileCreateResponse struct {
FileCreateFineTuneResponse
FileCreateKnowledgeResponse
}
FileCreateResponse is the response of the FileCreateService.
type FileCreateService ¶
type FileCreateService struct {
// contains filtered or unexported fields
}
FileCreateService is a service to create a file.
func NewFileCreateService ¶
func NewFileCreateService(client *Client) *FileCreateService
NewFileCreateService creates a new FileCreateService.
func (*FileCreateService) Do ¶
func (s *FileCreateService) Do(ctx context.Context) (res FileCreateResponse, err error)
Do makes the request.
func (*FileCreateService) SetCustomSeparator ¶
func (s *FileCreateService) SetCustomSeparator(customSeparator string) *FileCreateService
SetCustomSeparator sets the custom_separator parameter of the FileCreateService.
func (*FileCreateService) SetFile ¶
func (s *FileCreateService) SetFile(file io.Reader, filename string) *FileCreateService
SetFile sets the file parameter of the FileCreateService.
func (*FileCreateService) SetKnowledgeID ¶
func (s *FileCreateService) SetKnowledgeID(knowledgeID string) *FileCreateService
SetKnowledgeID sets the knowledge_id parameter of the FileCreateService.
func (*FileCreateService) SetLocalFile ¶
func (s *FileCreateService) SetLocalFile(localFile string) *FileCreateService
SetLocalFile sets the local_file parameter of the FileCreateService.
func (*FileCreateService) SetPurpose ¶
func (s *FileCreateService) SetPurpose(purpose string) *FileCreateService
SetPurpose sets the purpose parameter of the FileCreateService.
func (*FileCreateService) SetSentenceSize ¶
func (s *FileCreateService) SetSentenceSize(sentenceSize int) *FileCreateService
SetSentenceSize sets the sentence_size parameter of the FileCreateService.
type FileDeleteService ¶
type FileDeleteService struct {
// contains filtered or unexported fields
}
FileDeleteService is a service to delete a file.
func NewFileDeleteService ¶
func NewFileDeleteService(client *Client) *FileDeleteService
NewFileDeleteService creates a new FileDeleteService.
func (*FileDeleteService) Do ¶
func (s *FileDeleteService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileDeleteService) SetDocumentID ¶
func (s *FileDeleteService) SetDocumentID(documentID string) *FileDeleteService
SetDocumentID sets the document_id parameter of the FileDeleteService.
type FileDownloadService ¶
type FileDownloadService struct {
// contains filtered or unexported fields
}
FileDownloadService is a service to download a file.
func NewFileDownloadService ¶
func NewFileDownloadService(client *Client) *FileDownloadService
NewFileDownloadService creates a new FileDownloadService.
func (*FileDownloadService) Do ¶
func (s *FileDownloadService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileDownloadService) SetFileID ¶
func (s *FileDownloadService) SetFileID(fileID string) *FileDownloadService
SetFileID sets the file_id parameter of the FileDownloadService.
func (*FileDownloadService) SetOutput ¶
func (s *FileDownloadService) SetOutput(w io.Writer) *FileDownloadService
SetOutput sets the output parameter of the FileDownloadService.
func (*FileDownloadService) SetOutputFile ¶
func (s *FileDownloadService) SetOutputFile(filename string) *FileDownloadService
SetOutputFile sets the output_file parameter of the FileDownloadService.
type FileEditService ¶
type FileEditService struct {
// contains filtered or unexported fields
}
FileEditService is a service to edit a file.
func NewFileEditService ¶
func NewFileEditService(client *Client) *FileEditService
NewFileEditService creates a new FileEditService.
func (*FileEditService) Do ¶
func (s *FileEditService) Do(ctx context.Context) (err error)
Do makes the request.
func (*FileEditService) SetCustomSeparator ¶
func (s *FileEditService) SetCustomSeparator(customSeparator ...string) *FileEditService
SetSentenceSize sets the sentence_size parameter of the FileEditService.
func (*FileEditService) SetDocumentID ¶
func (s *FileEditService) SetDocumentID(documentID string) *FileEditService
SetDocumentID sets the document_id parameter of the FileEditService.
func (*FileEditService) SetKnowledgeType ¶
func (s *FileEditService) SetKnowledgeType(knowledgeType int) *FileEditService
SetKnowledgeType sets the knowledge_type parameter of the FileEditService.
func (*FileEditService) SetSentenceSize ¶
func (s *FileEditService) SetSentenceSize(sentenceSize int) *FileEditService
SetSentenceSize sets the sentence_size parameter of the FileEditService.
type FileFailInfo ¶
type FileFailInfo struct {
EmbeddingCode int `json:"embedding_code"`
EmbeddingMsg string `json:"embedding_msg"`
}
FileFailInfo is the failed info of the FileListKnowledgeItem.
type FileGetResponse ¶
type FileGetResponse = FileListKnowledgeItem
FileGetResponse is the response of the FileGetService.
type FileGetService ¶
type FileGetService struct {
// contains filtered or unexported fields
}
FileGetService is a service to get a file.
func NewFileGetService ¶
func NewFileGetService(client *Client) *FileGetService
NewFileGetService creates a new FileGetService.
func (*FileGetService) Do ¶
func (s *FileGetService) Do(ctx context.Context) (res FileGetResponse, err error)
Do makes the request.
func (*FileGetService) SetDocumentID ¶
func (s *FileGetService) SetDocumentID(documentID string) *FileGetService
SetDocumentID sets the document_id parameter of the FileGetService.
type FileListFineTuneItem ¶
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 ¶
type FileListFineTuneResponse struct {
Object string `json:"object"`
Data []FileListFineTuneItem `json:"data"`
}
FileListFineTuneResponse is the response of the FileListService.
type FileListKnowledgeItem ¶
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 ¶
type FileListKnowledgeResponse struct {
Total int `json:"total"`
List []FileListKnowledgeItem `json:"list"`
}
FileListKnowledgeResponse is the response of the FileListService.
type FileListResponse ¶
type FileListResponse struct {
FileListKnowledgeResponse
FileListFineTuneResponse
}
FileListResponse is the response of the FileListService.
type FileListService ¶
type FileListService struct {
// contains filtered or unexported fields
}
FileListService is a service to list files.
func NewFileListService ¶
func NewFileListService(client *Client) *FileListService
NewFileListService creates a new FileListService.
func (*FileListService) Do ¶
func (s *FileListService) Do(ctx context.Context) (res FileListResponse, err error)
Do makes the request.
func (*FileListService) SetAfter ¶
func (s *FileListService) SetAfter(after string) *FileListService
SetAfter sets the after parameter of the FileListService.
func (*FileListService) SetKnowledgeID ¶
func (s *FileListService) SetKnowledgeID(knowledgeID string) *FileListService
SetKnowledgeID sets the knowledge_id parameter of the FileListService.
func (*FileListService) SetLimit ¶
func (s *FileListService) SetLimit(limit int) *FileListService
SetLimit sets the limit parameter of the FileListService.
func (*FileListService) SetOrder ¶
func (s *FileListService) SetOrder(asc bool) *FileListService
SetOrder sets the order parameter of the FileListService.
func (*FileListService) SetPage ¶
func (s *FileListService) SetPage(page int) *FileListService
SetPage sets the page parameter of the FileListService.
func (*FileListService) SetPurpose ¶
func (s *FileListService) SetPurpose(purpose string) *FileListService
SetPurpose sets the purpose parameter of the FileListService.
type FineTuneCancelService ¶
type FineTuneCancelService struct {
// contains filtered or unexported fields
}
FineTuneCancelService creates a new fine tune cancel
func NewFineTuneCancelService ¶
func NewFineTuneCancelService(client *Client) *FineTuneCancelService
NewFineTuneCancelService creates a new FineTuneCancelService
func (*FineTuneCancelService) Do ¶
func (s *FineTuneCancelService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneCancelService) SetJobID ¶
func (s *FineTuneCancelService) SetJobID(jobID string) *FineTuneCancelService
SetJobID sets the jobID parameter
type FineTuneCreateResponse ¶
type FineTuneCreateResponse = FineTuneItem
FineTuneCreateResponse is the response of the FineTuneCreateService
type FineTuneCreateService ¶
type FineTuneCreateService struct {
// contains filtered or unexported fields
}
FineTuneCreateService creates a new fine tune
func NewFineTuneCreateService ¶
func NewFineTuneCreateService(client *Client) *FineTuneCreateService
NewFineTuneCreateService creates a new FineTuneCreateService
func (*FineTuneCreateService) Do ¶
func (s *FineTuneCreateService) Do(ctx context.Context) (res FineTuneCreateResponse, err error)
Do makes the request
func (*FineTuneCreateService) SetBatchSize ¶
func (s *FineTuneCreateService) SetBatchSize(batchSize int) *FineTuneCreateService
SetBatchSize sets the batchSize parameter
func (*FineTuneCreateService) SetBatchSizeAuto ¶
func (s *FineTuneCreateService) SetBatchSizeAuto() *FineTuneCreateService
SetBatchSizeAuto sets the batchSize parameter to auto
func (*FineTuneCreateService) SetLearningRateMultiplier ¶
func (s *FineTuneCreateService) SetLearningRateMultiplier(learningRateMultiplier float64) *FineTuneCreateService
SetLearningRateMultiplier sets the learningRateMultiplier parameter
func (*FineTuneCreateService) SetLearningRateMultiplierAuto ¶
func (s *FineTuneCreateService) SetLearningRateMultiplierAuto() *FineTuneCreateService
SetLearningRateMultiplierAuto sets the learningRateMultiplier parameter to auto
func (*FineTuneCreateService) SetModel ¶
func (s *FineTuneCreateService) SetModel(model string) *FineTuneCreateService
SetModel sets the model parameter
func (*FineTuneCreateService) SetNEpochs ¶
func (s *FineTuneCreateService) SetNEpochs(nEpochs int) *FineTuneCreateService
SetNEpochs sets the nEpochs parameter
func (*FineTuneCreateService) SetNEpochsAuto ¶
func (s *FineTuneCreateService) SetNEpochsAuto() *FineTuneCreateService
SetNEpochsAuto sets the nEpochs parameter to auto
func (*FineTuneCreateService) SetRequestID ¶
func (s *FineTuneCreateService) SetRequestID(requestID string) *FineTuneCreateService
SetRequestID sets the requestID parameter
func (*FineTuneCreateService) SetSuffix ¶
func (s *FineTuneCreateService) SetSuffix(suffix string) *FineTuneCreateService
SetSuffix sets the suffix parameter
func (*FineTuneCreateService) SetTrainingFile ¶
func (s *FineTuneCreateService) SetTrainingFile(trainingFile string) *FineTuneCreateService
SetTrainingFile sets the trainingFile parameter
func (*FineTuneCreateService) SetValidationFile ¶
func (s *FineTuneCreateService) SetValidationFile(validationFile string) *FineTuneCreateService
SetValidationFile sets the validationFile parameter
type FineTuneDeleteService ¶
type FineTuneDeleteService struct {
// contains filtered or unexported fields
}
FineTuneDeleteService creates a new fine tune delete
func NewFineTuneDeleteService ¶
func NewFineTuneDeleteService(client *Client) *FineTuneDeleteService
NewFineTuneDeleteService creates a new FineTuneDeleteService
func (*FineTuneDeleteService) Do ¶
func (s *FineTuneDeleteService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneDeleteService) SetJobID ¶
func (s *FineTuneDeleteService) SetJobID(jobID string) *FineTuneDeleteService
SetJobID sets the jobID parameter
type FineTuneEventData ¶
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 ¶
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 ¶
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 ¶
type FineTuneEventListService struct {
// contains filtered or unexported fields
}
FineTuneEventListService creates a new fine tune event list
func NewFineTuneEventListService ¶
func NewFineTuneEventListService(client *Client) *FineTuneEventListService
NewFineTuneEventListService creates a new FineTuneEventListService
func (*FineTuneEventListService) Do ¶
func (s *FineTuneEventListService) Do(ctx context.Context) (res FineTuneEventListResponse, err error)
Do makes the request
func (*FineTuneEventListService) SetAfter ¶
func (s *FineTuneEventListService) SetAfter(after string) *FineTuneEventListService
SetAfter sets the after parameter
func (*FineTuneEventListService) SetJobID ¶
func (s *FineTuneEventListService) SetJobID(jobID string) *FineTuneEventListService
SetJobID sets the jobID parameter
func (*FineTuneEventListService) SetLimit ¶
func (s *FineTuneEventListService) SetLimit(limit int) *FineTuneEventListService
SetLimit sets the limit parameter
type FineTuneGetService ¶
type FineTuneGetService struct {
// contains filtered or unexported fields
}
FineTuneGetService creates a new fine tune get
func NewFineTuneGetService ¶
func NewFineTuneGetService(client *Client) *FineTuneGetService
NewFineTuneGetService creates a new FineTuneGetService
func (*FineTuneGetService) Do ¶
func (s *FineTuneGetService) Do(ctx context.Context) (res FineTuneItem, err error)
Do makes the request
func (*FineTuneGetService) SetJobID ¶
func (s *FineTuneGetService) SetJobID(jobID string) *FineTuneGetService
SetJobID sets the jobID parameter
type FineTuneItem ¶
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 ¶
type FineTuneListResponse struct {
Data []FineTuneItem `json:"data"`
Object string `json:"object"`
}
FineTuneListResponse is the response of the FineTuneListService
type FineTuneListService ¶
type FineTuneListService struct {
// contains filtered or unexported fields
}
FineTuneListService creates a new fine tune list
func NewFineTuneListService ¶
func NewFineTuneListService(client *Client) *FineTuneListService
NewFineTuneListService creates a new FineTuneListService
func (*FineTuneListService) Do ¶
func (s *FineTuneListService) Do(ctx context.Context) (res FineTuneListResponse, err error)
Do makes the request
func (*FineTuneListService) SetAfter ¶
func (s *FineTuneListService) SetAfter(after string) *FineTuneListService
SetAfter sets the after parameter
func (*FineTuneListService) SetLimit ¶
func (s *FineTuneListService) SetLimit(limit int) *FineTuneListService
SetLimit sets the limit parameter
type IDItem ¶
type IDItem struct {
ID string `json:"id,omitempty"`
}
IDItem is a struct that contains an ID.
type ImageGenerationResponse ¶
ImageGenerationResponse is the response of the ImageGenerationService
type ImageGenerationService ¶
type ImageGenerationService struct {
// contains filtered or unexported fields
}
ImageGenerationService creates a new image generation
func NewImageGenerationService ¶
func NewImageGenerationService(client *Client) *ImageGenerationService
NewImageGenerationService creates a new ImageGenerationService
func (*ImageGenerationService) BatchBody ¶
func (s *ImageGenerationService) BatchBody() any
func (*ImageGenerationService) BatchMethod ¶
func (s *ImageGenerationService) BatchMethod() string
func (*ImageGenerationService) BatchURL ¶
func (s *ImageGenerationService) BatchURL() string
func (*ImageGenerationService) Do ¶
func (s *ImageGenerationService) Do(ctx context.Context) (res ImageGenerationResponse, err error)
func (*ImageGenerationService) SetModel ¶
func (s *ImageGenerationService) SetModel(model string) *ImageGenerationService
SetModel sets the model parameter
func (*ImageGenerationService) SetPrompt ¶
func (s *ImageGenerationService) SetPrompt(prompt string) *ImageGenerationService
SetPrompt sets the prompt parameter
func (*ImageGenerationService) SetSize ¶
func (s *ImageGenerationService) SetSize(size string) *ImageGenerationService
func (*ImageGenerationService) SetUserID ¶
func (s *ImageGenerationService) SetUserID(userID string) *ImageGenerationService
SetUserID sets the userID parameter
type KnowledgeCapacityItem ¶
KnowledgeCapacityItem is an item in the knowledge capacity
type KnowledgeCapacityResponse ¶
type KnowledgeCapacityResponse struct {
Used KnowledgeCapacityItem `json:"used"`
Total KnowledgeCapacityItem `json:"total"`
}
KnowledgeCapacityResponse is the response of the KnowledgeCapacityService
type KnowledgeCapacityService ¶
type KnowledgeCapacityService struct {
// contains filtered or unexported fields
}
KnowledgeCapacityService query the capacity of the knowledge
func NewKnowledgeCapacityService ¶
func NewKnowledgeCapacityService(client *Client) *KnowledgeCapacityService
SetKnowledgeID sets the knowledge id
func (*KnowledgeCapacityService) Do ¶
func (s *KnowledgeCapacityService) Do(ctx context.Context) (res KnowledgeCapacityResponse, err error)
Do query the capacity of the knowledge
type KnowledgeCreateResponse ¶
type KnowledgeCreateResponse = IDItem
KnowledgeCreateResponse is the response of the KnowledgeCreateService
type KnowledgeCreateService ¶
type KnowledgeCreateService struct {
// contains filtered or unexported fields
}
KnowledgeCreateService creates a new knowledge
func NewKnowledgeCreateService ¶
func NewKnowledgeCreateService(client *Client) *KnowledgeCreateService
NewKnowledgeCreateService creates a new KnowledgeCreateService
func (*KnowledgeCreateService) Do ¶
func (s *KnowledgeCreateService) Do(ctx context.Context) (res KnowledgeCreateResponse, err error)
Do creates the knowledge
func (*KnowledgeCreateService) SetDescription ¶
func (s *KnowledgeCreateService) SetDescription(description string) *KnowledgeCreateService
SetDescription sets the description of the knowledge
func (*KnowledgeCreateService) SetEmbeddingID ¶
func (s *KnowledgeCreateService) SetEmbeddingID(embeddingID int) *KnowledgeCreateService
SetEmbeddingID sets the embedding id of the knowledge
func (*KnowledgeCreateService) SetName ¶
func (s *KnowledgeCreateService) SetName(name string) *KnowledgeCreateService
SetName sets the name of the knowledge
type KnowledgeDeleteService ¶
type KnowledgeDeleteService struct {
// contains filtered or unexported fields
}
KnowledgeDeleteService deletes a knowledge
func NewKnowledgeDeleteService ¶
func NewKnowledgeDeleteService(client *Client) *KnowledgeDeleteService
NewKnowledgeDeleteService creates a new KnowledgeDeleteService
func (*KnowledgeDeleteService) Do ¶
func (s *KnowledgeDeleteService) Do(ctx context.Context) (err error)
Do deletes the knowledge
func (*KnowledgeDeleteService) SetKnowledgeID ¶
func (s *KnowledgeDeleteService) SetKnowledgeID(knowledgeID string) *KnowledgeDeleteService
SetKnowledgeID sets the knowledge id
type KnowledgeEditService ¶
type KnowledgeEditService struct {
// contains filtered or unexported fields
}
KnowledgeEditService edits a knowledge
func NewKnowledgeEditService ¶
func NewKnowledgeEditService(client *Client) *KnowledgeEditService
NewKnowledgeEditService creates a new KnowledgeEditService
func (*KnowledgeEditService) Do ¶
func (s *KnowledgeEditService) Do(ctx context.Context) (err error)
Do edits the knowledge
func (*KnowledgeEditService) SetDescription ¶
func (s *KnowledgeEditService) SetDescription(description string) *KnowledgeEditService
SetDescription sets the description of the knowledge
func (*KnowledgeEditService) SetEmbeddingID ¶
func (s *KnowledgeEditService) SetEmbeddingID(embeddingID int) *KnowledgeEditService
SetEmbeddingID sets the embedding id of the knowledge
func (*KnowledgeEditService) SetKnowledgeID ¶
func (s *KnowledgeEditService) SetKnowledgeID(knowledgeID string) *KnowledgeEditService
SetKnowledgeID sets the knowledge id
func (*KnowledgeEditService) SetName ¶
func (s *KnowledgeEditService) SetName(name string) *KnowledgeEditService
SetName sets the name of the knowledge
type KnowledgeItem ¶
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 ¶
type KnowledgeListResponse struct {
List []KnowledgeItem `json:"list"`
Total int `json:"total"`
}
KnowledgeListResponse is the response of the KnowledgeListService
type KnowledgeListService ¶
type KnowledgeListService struct {
// contains filtered or unexported fields
}
KnowledgeListService lists the knowledge
func NewKnowledgeListService ¶
func NewKnowledgeListService(client *Client) *KnowledgeListService
NewKnowledgeListService creates a new KnowledgeListService
func (*KnowledgeListService) Do ¶
func (s *KnowledgeListService) Do(ctx context.Context) (res KnowledgeListResponse, err error)
Do lists the knowledge
func (*KnowledgeListService) SetPage ¶
func (s *KnowledgeListService) SetPage(page int) *KnowledgeListService
SetPage sets the page of the knowledge list
func (*KnowledgeListService) SetSize ¶
func (s *KnowledgeListService) SetSize(size int) *KnowledgeListService
SetSize sets the size of the knowledge list
type StringOr ¶
StringOr is a struct that can be either a string or a value of type T.
func (StringOr[T]) MarshalJSON ¶
func (*StringOr[T]) SetValue ¶
func (f *StringOr[T]) SetValue(v T)
SetValue sets the value of the struct.
func (*StringOr[T]) UnmarshalJSON ¶
type URLItem ¶
type URLItem struct {
URL string `json:"url,omitempty"`
}
URLItem is a struct that contains a URL.
type VideoGenerationResponse ¶
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 ¶
type VideoGenerationService struct {
// contains filtered or unexported fields
}
VideoGenerationService creates a new video generation
func NewVideoGenerationService ¶
func NewVideoGenerationService(client *Client) *VideoGenerationService
func (*VideoGenerationService) BatchBody ¶
func (s *VideoGenerationService) BatchBody() any
func (*VideoGenerationService) BatchMethod ¶
func (s *VideoGenerationService) BatchMethod() string
func (*VideoGenerationService) BatchURL ¶
func (s *VideoGenerationService) BatchURL() string
func (*VideoGenerationService) Do ¶
func (s *VideoGenerationService) Do(ctx context.Context) (res VideoGenerationResponse, err error)
func (*VideoGenerationService) SetImageURL ¶
func (s *VideoGenerationService) SetImageURL(imageURL string) *VideoGenerationService
SetImageURL sets the imageURL parameter
func (*VideoGenerationService) SetModel ¶
func (s *VideoGenerationService) SetModel(model string) *VideoGenerationService
SetModel sets the model parameter
func (*VideoGenerationService) SetPrompt ¶
func (s *VideoGenerationService) SetPrompt(prompt string) *VideoGenerationService
SetPrompt sets the prompt parameter
func (*VideoGenerationService) SetRequestID ¶
func (s *VideoGenerationService) SetRequestID(requestID string) *VideoGenerationService
SetRequestID sets the requestID parameter
func (*VideoGenerationService) SetUserID ¶
func (s *VideoGenerationService) SetUserID(userID string) *VideoGenerationService
SetUserID sets the userID parameter