coze

package module
v0.0.0-...-e9ba6ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 29 Imported by: 0

README

Coze Go API SDK

codecov

Introduction

The Coze API SDK for Go is a powerful tool designed to seamlessly integrate Coze's open APIs into your Go projects.

Key Features:

  • Full support for Coze open APIs and authentication APIs
  • Both synchronous and streaming API calls
  • Optimized streaming APIs with io.Reader interface
  • Optimized list APIs with Iterator interface
  • Simple and idiomatic Go API design

Installation

go get github.com/Zhyus/coze-go

Usage

Examples
Example File
pat auth pat_example.go
oauth by web code web_oauth_example.go
oauth by jwt flow jwt_oauth_example.go
oauth by pkce flow pkce_oauth_example.go
oauth by device flow device_oauth_example.go
handle auth exception handle_auth_exception_example.go
bot create, publish and chat publish_bot_example.go
get bot and bot list retrieve_bot_example.go
non-stream chat non_stream_chat_example.go
stream chat stream_chat_example.go
chat with local plugin submit_tool_output_example.go
chat with image chat_with_image_example.go
audio live retrieve audio_live_retrieve_example.go
non-stream workflow chat non_stream_workflow_run_example.go
stream workflow chat stream_workflow_run_example.go
async workflow run async_workflow_run_example.go
conversation conversation_example.go
list conversation list_conversation_example.go
workspace list_workspace_example.go
create update delete message create_update_delete_message_example.go
list message list_message_example.go
create update delete document create_update_delete_document_example.go
list documents list_documents_example.go
initial client init_client_example.go
how to handle error handle_error_example.go
get response log id log_example.go
Initialize the Coze Client

To get started, visit https://www.coze.com/open/oauth/pats (or https://www.coze.cn/open/oauth/pats for the CN environment).

Create a new token by clicking "Add Token". Configure the token name, expiration time, and required permissions. Click OK to generate your personal access token.

Important: Store your personal access token securely to prevent unauthorized access.

func main() {
    // Get an access_token through personal access token or oauth.
    token := os.Getenv("COZE_API_TOKEN")
    authCli := coze.NewTokenAuth(token)
    
    /*
     * The default access is api.coze.com, but if you need to access api.coze.cn
     * please use baseUrl to configure the API endpoint to access
     */
    baseURL := os.Getenv("COZE_API_BASE")
    cozeCli := coze.NewCozeAPI(authCli, coze.WithBaseURL(baseURL))
}
Chat

First, create a bot instance in Coze. The bot ID is the last number in the web link URL.

Non-Stream Chat

The SDK provides a convenient wrapper function for non-streaming chat operations. It handles polling and message retrieval automatically:

func main() {
    token := os.Getenv("COZE_API_TOKEN")
    botID := os.Getenv("PUBLISHED_BOT_ID")
    uid := os.Getenv("USER_ID")
    
    authCli := coze.NewTokenAuth(token)
    cozeCli := coze.NewCozeAPI(authCli, coze.WithBaseURL(os.Getenv("COZE_API_BASE")))
    
    ctx := context.Background()
    req := &coze.CreateChatReq{
        BotID:  botID,
        UserID: uid,
        Messages: []coze.Message{
            coze.BuildUserQuestionText("What can you do?", nil),
        },
    }
    
    chat, err := cozeCli.Chat.CreateAndPoll(ctx, req, nil)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    
    if chat.Status == coze.ChatStatusCompleted {
        fmt.Printf("Token usage: %d\n", chat.Usage.TokenCount)
    }
}
Stream Chat

Use cozeCli.Chat.Stream() to create a streaming chat session:

func main() {
    // ... initialize client as above ...
    
    ctx := context.Background()
    req := &coze.CreateChatReq{
        BotID:  botID,
        UserID: userID,
        Messages: []coze.Message{
            coze.BuildUserQuestionObjects([]coze.MessageObjectString{
                coze.NewTextMessageObject("Describe this picture"),
                coze.NewImageMessageObjectByID(imageInfo.FileInfo.ID),
            }, nil),
        },
    }
    
    resp, err := cozeCli.Chat.Stream(ctx, req)
    if err != nil {
        fmt.Println("Error starting stream:", err)
        return
    }
    defer resp.Close()
    
    for {
        event, err := resp.Recv()
        if errors.Is(err, io.EOF) {
            fmt.Println("Stream finished")
            break
        }
        if err != nil {
            fmt.Println(err)
            break
        }
        
        if event.Event == coze.ChatEventConversationMessageDelta {
            fmt.Print(event.Message.Content)
        } else if event.Event == coze.ChatEventConversationChatCompleted {
            fmt.Printf("Token usage:%d\n", event.Chat.Usage.TokenCount)
        }
    }
}
Files
func main() {
    // ... initialize client as above ...
    
    ctx := context.Background()
    filePath := os.Getenv("FILE_PATH")
    
    // Upload file
    uploadResp, err := cozeCli.Files.Upload(ctx, coze.NewUploadFilesReqWithPath(filePath))
    if err != nil {
        fmt.Println("Error uploading file:", err)
        return
    }
    fileInfo := uploadResp.FileInfo
    
    // Wait for file processing
    time.Sleep(time.Second)
    
    // Retrieve file
    retrievedResp, err := cozeCli.Files.Retrieve(ctx, &coze.RetrieveFilesReq{
        FileID: fileInfo.ID,
    })
    if err != nil {
        fmt.Println("Error retrieving file:", err)
        return
    }
    fmt.Println(retrievedResp.FileInfo)
}
Pagination

The SDK provides an iterator interface for handling paginated results:

func main() {
    // ... initialize client as above ...
    
    ctx := context.Background()
    datasetID, _ := strconv.ParseInt(os.Getenv("DATASET_ID"), 10, 64)
    
    // Use iterator to automatically retrieve next page
    documents, err := cozeCli.Datasets.Documents.List(ctx, &coze.ListDatasetsDocumentsReq{
        Size: 1,
        DatasetID: datasetID,
    })
    if err != nil {
        fmt.Println("Error fetching documents:", err)
        return
    }
    
    for documents.Next() {
        fmt.Println(documents.Current())
    }
    
    fmt.Println("has_more:", documents.HasMore())
}
Error Handling

The SDK uses Go's standard error handling patterns. All API calls return an error value that should be checked:

resp, err := cozeCli.Chat.Create(ctx, req)
if err != nil {
    if cozeErr, ok := coze.AsCozeError(err); ok {
    // Handle Coze API error
    fmt.Printf("Coze API error: %s (code: %s)\n", cozeErr.ErrorMessage, cozeErr.ErrorCode)
    return
    }
}

Documentation

Index

Constants

View Source
const (
	ComBaseURL = "https://api.coze.com"
	CnBaseURL  = "https://api.coze.cn"
)

Variables

This section is empty.

Functions

func LoadOAuthAppFromConfig

func LoadOAuthAppFromConfig(config *OAuthConfig) (interface{}, error)

LoadOAuthAppFromConfig creates an OAuth client based on the provided JSON configuration bytes

Types

type AudioCodec

type AudioCodec string

AudioCodec represents the audio codec

const (
	AudioCodecAACLC AudioCodec = "AACLC"
	AudioCodecG711A AudioCodec = "G711A"
	AudioCodecOPUS  AudioCodec = "OPUS"
	AudioCodecG722  AudioCodec = "G722"
)

func (AudioCodec) Ptr

func (r AudioCodec) Ptr() *AudioCodec

func (AudioCodec) String

func (r AudioCodec) String() string

type AudioFormat

type AudioFormat string

AudioFormat represents the audio format type

const (
	AudioFormatWAV     AudioFormat = "wav"
	AudioFormatPCM     AudioFormat = "pcm"
	AudioFormatOGGOPUS AudioFormat = "ogg_opus"
	AudioFormatM4A     AudioFormat = "m4a"
	AudioFormatAAC     AudioFormat = "aac"
	AudioFormatMP3     AudioFormat = "mp3"
)

func (AudioFormat) Ptr

func (f AudioFormat) Ptr() *AudioFormat

func (AudioFormat) String

func (f AudioFormat) String() string

type AudioSpeechTranscriptionsReq

type AudioSpeechTranscriptionsReq struct {
	Filename string    `json:"filename"`
	Audio    io.Reader `json:"file"`
}

type AudioTranscriptionsData

type AudioTranscriptionsData struct {
	Text string `json:"text"`
}

type Auth

type Auth interface {
	Token(ctx context.Context) (string, error)
}

func NewJWTAuth

func NewJWTAuth(client *JWTOAuthClient, opt *GetJWTAccessTokenReq) Auth

func NewTokenAuth

func NewTokenAuth(accessToken string) Auth

NewTokenAuth creates a new token authentication instance.

type AuthError

type AuthError struct {
	HttpCode     int
	Code         AuthErrorCode
	ErrorMessage string
	Param        string
	LogID        string
	// contains filtered or unexported fields
}

func AsAuthError

func AsAuthError(err error) (*AuthError, bool)

AsAuthError 判断错误是否为 CozeAuthError 类型

func NewAuthError

func NewAuthError(error *authErrorFormat, statusCode int, logID string) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

Error implements the error interface

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

Unwrap returns the parent error

type AuthErrorCode

type AuthErrorCode string

AuthErrorCode represents authentication error codes

const (
	/*
	 * The user has not completed authorization yet, please try again later
	 */
	AuthorizationPending AuthErrorCode = "authorization_pending"
	/*
	 * The request is too frequent, please try again later
	 */
	SlowDown AuthErrorCode = "slow_down"
	/*
	 * The user has denied the authorization
	 */
	AccessDenied AuthErrorCode = "access_denied"
	/*
	 * The token is expired
	 */
	ExpiredToken AuthErrorCode = "expired_token"
)

func (AuthErrorCode) String

func (c AuthErrorCode) String() string

String implements the Stringer interface

type BasePaged

type BasePaged[T any] interface {
	Response() HTTPResponse
	Err() error
	Items() []*T
	Current() *T
	Next() bool
	HasMore() bool
}

type BaseWebSocketAudioSpeechHandler

type BaseWebSocketAudioSpeechHandler struct{}

func (BaseWebSocketAudioSpeechHandler) OnClientError

func (BaseWebSocketAudioSpeechHandler) OnClosed

func (BaseWebSocketAudioSpeechHandler) OnError

func (BaseWebSocketAudioSpeechHandler) OnInputTextBufferCompleted

func (BaseWebSocketAudioSpeechHandler) OnSpeechAudioCompleted

func (BaseWebSocketAudioSpeechHandler) OnSpeechAudioUpdate

func (BaseWebSocketAudioSpeechHandler) OnSpeechCreated

func (BaseWebSocketAudioSpeechHandler) OnSpeechUpdated

type BaseWebSocketAudioTranscriptionHandler

type BaseWebSocketAudioTranscriptionHandler struct{}

func (BaseWebSocketAudioTranscriptionHandler) OnClientError

func (BaseWebSocketAudioTranscriptionHandler) OnClosed

func (BaseWebSocketAudioTranscriptionHandler) OnError

func (BaseWebSocketAudioTranscriptionHandler) OnInputAudioBufferCleared

func (BaseWebSocketAudioTranscriptionHandler) OnInputAudioBufferCompleted

func (BaseWebSocketAudioTranscriptionHandler) OnTranscriptionsCreated

func (BaseWebSocketAudioTranscriptionHandler) OnTranscriptionsMessageCompleted

func (BaseWebSocketAudioTranscriptionHandler) OnTranscriptionsMessageUpdate

func (BaseWebSocketAudioTranscriptionHandler) OnTranscriptionsUpdated

type BaseWebSocketChatHandler

type BaseWebSocketChatHandler struct{}

func (BaseWebSocketChatHandler) OnChatCreated

func (BaseWebSocketChatHandler) OnChatUpdated

func (BaseWebSocketChatHandler) OnClientError

func (BaseWebSocketChatHandler) OnClosed

func (BaseWebSocketChatHandler) OnConversationAudioCompleted

func (BaseWebSocketChatHandler) OnConversationAudioDelta

func (BaseWebSocketChatHandler) OnConversationAudioSentenceStart

func (BaseWebSocketChatHandler) OnConversationAudioTranscriptCompleted

func (BaseWebSocketChatHandler) OnConversationAudioTranscriptCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptCompletedEvent) error

func (BaseWebSocketChatHandler) OnConversationAudioTranscriptUpdate

func (BaseWebSocketChatHandler) OnConversationAudioTranscriptUpdate(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptUpdateEvent) error

func (BaseWebSocketChatHandler) OnConversationChatCanceled

func (BaseWebSocketChatHandler) OnConversationChatCompleted

func (BaseWebSocketChatHandler) OnConversationChatCreated

func (BaseWebSocketChatHandler) OnConversationChatFailed

func (BaseWebSocketChatHandler) OnConversationChatInProgress

func (BaseWebSocketChatHandler) OnConversationChatRequiresAction

func (BaseWebSocketChatHandler) OnConversationCleared

func (BaseWebSocketChatHandler) OnConversationMessageCompleted

func (BaseWebSocketChatHandler) OnConversationMessageDelta

func (BaseWebSocketChatHandler) OnError

func (BaseWebSocketChatHandler) OnInputAudioBufferCleared

func (BaseWebSocketChatHandler) OnInputAudioBufferCompleted

func (BaseWebSocketChatHandler) OnInputAudioBufferSpeechStarted

func (BaseWebSocketChatHandler) OnInputAudioBufferSpeechStopped

type Bot

type Bot struct {
	BotID          string             `json:"bot_id"`
	Name           string             `json:"name"`
	Description    string             `json:"description,omitempty"`
	IconURL        string             `json:"icon_url,omitempty"`
	CreateTime     int64              `json:"create_time"`
	UpdateTime     int64              `json:"update_time"`
	Version        string             `json:"version,omitempty"`
	PromptInfo     *BotPromptInfo     `json:"prompt_info,omitempty"`
	OnboardingInfo *BotOnboardingInfo `json:"onboarding_info,omitempty"`
	BotMode        BotMode            `json:"bot_mode"`
	PluginInfoList []*BotPluginInfo   `json:"plugin_info_list,omitempty"`
	ModelInfo      *BotModelInfo      `json:"model_info,omitempty"`
	FolderID       *string            `json:"folder_id,omitempty"`
	OwnerUserID    *string            `json:"owner_user_id,omitempty"`
}

Bot represents complete bot information

type BotKnowledge

type BotKnowledge struct {
	DatasetIDs     []string `json:"dataset_ids"`
	AutoCall       bool     `json:"auto_call"`
	SearchStrategy int      `json:"search_strategy"`
}

BotKnowledge represents bot knowledge base configuration

type BotMode

type BotMode int

BotMode represents the bot mode

const (
	BotModeMultiAgent          BotMode = 1
	BotModeSingleAgentWorkflow BotMode = 0
)

type BotModelInfo

type BotModelInfo struct {
	ModelID    string            `json:"model_id"`
	ModelName  string            `json:"model_name"`
	Parameters map[string]string `json:"parameters,omitempty"`
}

BotModelInfo represents bot model information

type BotModelInfoConfig

type BotModelInfoConfig struct {
	TopK             int               `json:"top_k,omitempty"`
	TopP             float64           `json:"top_p,omitempty"`
	ModelID          string            `json:"model_id"`
	MaxTokens        int               `json:"max_tokens,omitempty"`
	Temperature      float64           `json:"temperature,omitempty"`
	ContextRound     int               `json:"context_round,omitempty"`
	ResponseFormat   string            `json:"response_format,omitempty"` // text,markdown,json
	PresencePenalty  float64           `json:"presence_penalty,omitempty"`
	FrequencyPenalty float64           `json:"frequency_penalty,omitempty"`
	Parameters       map[string]string `json:"parameters,omitempty"`
}

type BotOnboardingInfo

type BotOnboardingInfo struct {
	Prologue           string   `json:"prologue,omitempty"`
	SuggestedQuestions []string `json:"suggested_questions,omitempty"`
}

BotOnboardingInfo represents bot onboarding information

type BotPluginAPIInfo

type BotPluginAPIInfo struct {
	APIID       string `json:"api_id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

BotPluginAPIInfo represents bot plugin API information

type BotPluginInfo

type BotPluginInfo struct {
	PluginID    string              `json:"plugin_id"`
	Name        string              `json:"name"`
	Description string              `json:"description,omitempty"`
	IconURL     string              `json:"icon_url,omitempty"`
	APIInfoList []*BotPluginAPIInfo `json:"api_info_list,omitempty"`
}

BotPluginInfo represents bot plugin information

type BotPromptInfo

type BotPromptInfo struct {
	Prompt string `json:"prompt"`
}

BotPromptInfo represents bot prompt information

type CancelChatsReq

type CancelChatsReq struct {
	// The Conversation ID can be viewed in the 'conversation_id' field of the Response when
	// initiating a conversation through the Chat API.
	ConversationID string `json:"conversation_id"`

	// The Chat ID can be viewed in the 'id' field of the Response when initiating a chat through the
	// Chat API. If it is a streaming response, check the 'id' field in the chat event of the Response.
	ChatID string `json:"chat_id"`
}

CancelChatsReq represents the request to cancel a chat

type CancelChatsResp

type CancelChatsResp struct {
	Chat
	// contains filtered or unexported fields
}

func (*CancelChatsResp) LogID

func (r *CancelChatsResp) LogID() string

func (*CancelChatsResp) Response

func (r *CancelChatsResp) Response() HTTPResponse

type Chat

type Chat struct {
	// The ID of the chat.
	ID string `json:"id"`
	// The ID of the conversation.
	ConversationID string `json:"conversation_id"`
	// The ID of the bot.
	BotID string `json:"bot_id"`
	// Indicates the create time of the chat. The value format is Unix timestamp in seconds.
	CreatedAt int `json:"created_at"`
	// Indicates the end time of the chat. The value format is Unix timestamp in seconds.
	CompletedAt int `json:"completed_at,omitempty"`
	// Indicates the failure time of the chat. The value format is Unix timestamp in seconds.
	FailedAt int `json:"failed_at,omitempty"`
	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages.
	MetaData map[string]string `json:"meta_data,omitempty"`
	// When the chat encounters an auth_error, this field returns detailed error information.
	LastError *ChatError `json:"last_error,omitempty"`
	// The running status of the session.
	Status ChatStatus `json:"status"`
	// Details of the information needed for execution.
	RequiredAction *ChatRequiredAction `json:"required_action,omitempty"`
	// Detailed information about Token consumption.
	Usage                      *ChatUsage                   `json:"usage,omitempty"`
	InsertedAdditionalMessages []*InsertedAdditionalMessage `json:"inserted_additional_messages,omitempty"`
}

Chat represents chat information

type ChatError

type ChatError struct {
	// The error code. An integer type. 0 indicates success, other values indicate failure.
	Code int `json:"code"`
	// The error message. A string type.
	Msg string `json:"msg"`
}

ChatError represents error information

type ChatEvent

type ChatEvent struct {
	Event         ChatEventType  `json:"event"`
	Chat          *Chat          `json:"chat,omitempty"`
	Message       *Message       `json:"message,omitempty"`
	WorkflowDebug *WorkflowDebug `json:"workflow_debug,omitempty"`
}

ChatEvent represents a chat event in the streaming response

func (*ChatEvent) IsDone

func (c *ChatEvent) IsDone() bool

type ChatEventType

type ChatEventType string

ChatEventType Event types for chat.

const (
	// ChatEventConversationChatCreated Event for creating a conversation, indicating the start of the conversation.
	ChatEventConversationChatCreated ChatEventType = "conversation.chat.created"
	// ChatEventConversationChatInProgress The server is processing the conversation.
	ChatEventConversationChatInProgress ChatEventType = "conversation.chat.in_progress"
	// ChatEventConversationMessageDelta Incremental message, usually an incremental message when type=answer.
	ChatEventConversationMessageDelta ChatEventType = "conversation.message.delta"
	// ChatEventConversationMessageCompleted The message has been completely replied to.
	ChatEventConversationMessageCompleted ChatEventType = "conversation.message.completed"
	// ChatEventConversationChatCompleted The conversation is completed.
	ChatEventConversationChatCompleted ChatEventType = "conversation.chat.completed"
	// ChatEventConversationChatFailed This event is used to mark a failed conversation.
	ChatEventConversationChatFailed ChatEventType = "conversation.chat.failed"
	// ChatEventConversationChatRequiresAction The conversation is interrupted and requires the user to report the execution results of the tool.
	ChatEventConversationChatRequiresAction ChatEventType = "conversation.chat.requires_action"
	// ChatEventConversationAudioDelta Audio delta event
	ChatEventConversationAudioDelta ChatEventType = "conversation.audio.delta"
	// ChatEventError Error events during the streaming response process.
	ChatEventError ChatEventType = "error"
	// ChatEventDone The streaming response for this session ended normally.
	ChatEventDone ChatEventType = "done"
)

type ChatPoll

type ChatPoll struct {
	Chat     *Chat      `json:"chat"`
	Messages []*Message `json:"messages"`
}

ChatPoll represents polling information for a chat

type ChatRequiredAction

type ChatRequiredAction struct {
	// The type of additional operation, with the enum value of submit_tool_outputs.
	Type string `json:"type"`
	// Details of the results that need to be submitted, uploaded through the submission API, and the
	// chat can continue afterward.
	SubmitToolOutputs *ChatSubmitToolOutputs `json:"submit_tool_outputs,omitempty"`
}

ChatRequiredAction represents required action information

type ChatStatus

type ChatStatus string

ChatStatus The running status of the session.

const (
	// ChatStatusCreated The session has been created.
	ChatStatusCreated ChatStatus = "created"
	// ChatStatusInProgress The Bot is processing.
	ChatStatusInProgress ChatStatus = "in_progress"
	// ChatStatusCompleted The Bot has finished processing, and the session has ended.
	ChatStatusCompleted ChatStatus = "completed"
	// ChatStatusFailed The session has failed.
	ChatStatusFailed ChatStatus = "failed"
	// ChatStatusRequiresAction The session is interrupted and requires further processing.
	ChatStatusRequiresAction ChatStatus = "requires_action"
	// ChatStatusCancelled The session is user cancelled chat.
	ChatStatusCancelled ChatStatus = "canceled"
)

type ChatSubmitToolOutputs

type ChatSubmitToolOutputs struct {
	// Details of the specific reported information.
	ToolCalls []*ChatToolCall `json:"tool_calls"`
}

ChatSubmitToolOutputs represents tool outputs that need to be submitted

type ChatToolCall

type ChatToolCall struct {
	// The ID for reporting the running results.
	ID string `json:"id"`
	// The type of tool, with the enum value of function.
	Type string `json:"type"`
	// The definition of the execution method function.
	Function *ChatToolCallFunction `json:"function"`
}

ChatToolCall represents a tool call

type ChatToolCallFunction

type ChatToolCallFunction struct {
	// The name of the method.
	Name string `json:"name"`
	// The parameters of the method.
	Arguments string `json:"arguments"`
}

ChatToolCallFunction represents a function call in a tool

type ChatUsage

type ChatUsage struct {
	// The total number of Tokens consumed in this chat, including the consumption for both the input
	// and output parts.
	TokenCount int `json:"token_count"`
	// The total number of Tokens consumed for the output part.
	OutputCount int `json:"output_count"`
	// The total number of Tokens consumed for the input part.
	InputCount int `json:"input_count"`
}

ChatUsage represents token usage information

type ClearConversationsReq

type ClearConversationsReq struct {
	// The ID of the conversation.
	ConversationID string `path:"conversation_id" json:"-"`
}

ClearConversationsReq represents request for clearing conversation

type ClearConversationsResp

type ClearConversationsResp struct {
	ID             string `json:"id"`
	ConversationID string `json:"conversation_id"`
	// contains filtered or unexported fields
}

func (*ClearConversationsResp) LogID

func (r *ClearConversationsResp) LogID() string

func (*ClearConversationsResp) Response

func (r *ClearConversationsResp) Response() HTTPResponse

type CloneAudioVoicesReq

type CloneAudioVoicesReq struct {
	VoiceName   string        `json:"voice_name"`
	File        io.Reader     `json:"file"`
	AudioFormat AudioFormat   `json:"audio_format"`
	Language    *LanguageCode `json:"language"`
	VoiceID     *string       `json:"voice_id"`
	PreviewText *string       `json:"preview_text"`
	Text        *string       `json:"text"`
	SpaceID     *string       `json:"space_id"`
	Description *string       `json:"description"`
}

CloneAudioVoicesReq represents the request for cloning a voice

type CloneAudioVoicesResp

type CloneAudioVoicesResp struct {
	VoiceID string `json:"voice_id"`
	// contains filtered or unexported fields
}

CloneAudioVoicesResp represents the response for cloning a voice

func (*CloneAudioVoicesResp) LogID

func (r *CloneAudioVoicesResp) LogID() string

func (*CloneAudioVoicesResp) Response

func (r *CloneAudioVoicesResp) Response() HTTPResponse

type CodeChallengeMethod

type CodeChallengeMethod string

CodeChallengeMethod represents the code challenge method

const (
	CodeChallengeMethodPlain CodeChallengeMethod = "plain"
	CodeChallengeMethodS256  CodeChallengeMethod = "S256"
)

func (CodeChallengeMethod) Ptr

func (CodeChallengeMethod) String

func (m CodeChallengeMethod) String() string

type Conversation

type Conversation struct {
	// The ID of the conversation
	ID string `json:"id"`

	// Indicates the create time of the conversation. The value format is Unix timestamp in seconds.
	CreatedAt int `json:"created_at"`

	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages.
	MetaData map[string]string `json:"meta_data,omitempty"`

	// section_id is used to distinguish the context sections of the session history.
	// The same section is one context.
	LastSectionID string `json:"last_section_id"`
}

Conversation represents conversation information

type CozeAPI

type CozeAPI struct {
	Audio         *audio
	Bots          *bots
	Chat          *chat
	Conversations *conversations
	Workflows     *workflows
	Workspaces    *workspace
	Datasets      *datasets
	Files         *files
	Folders       *folders
	Templates     *templates
	Users         *users
	Variables     *variables
	Enterprises   *enterprises
	Apps          *apps
	WebSockets    *websockets
	Stores        *stores
	// contains filtered or unexported fields
}

func NewCozeAPI

func NewCozeAPI(auth Auth, opts ...CozeAPIOption) CozeAPI

type CozeAPIOption

type CozeAPIOption func(*clientOption)

func WithBaseURL

func WithBaseURL(baseURL string) CozeAPIOption

WithBaseURL adds the base URL for the API

func WithEnableLogID

func WithEnableLogID(enableLogID bool) CozeAPIOption

func WithHeaders

func WithHeaders(headers http.Header) CozeAPIOption

func WithHttpClient

func WithHttpClient(client HTTPClient) CozeAPIOption

WithHttpClient sets a custom HTTP core

func WithLogLevel

func WithLogLevel(level LogLevel) CozeAPIOption

WithLogLevel sets the logging level

func WithLogger

func WithLogger(logger Logger) CozeAPIOption

type CreateAudioRoomsReq

type CreateAudioRoomsReq struct {
	BotID          string      `json:"bot_id"`
	ConversationID string      `json:"conversation_id,omitempty"`
	VoiceID        string      `json:"voice_id,omitempty"`
	UID            string      `json:"uid,omitempty"`
	WorkflowID     string      `json:"workflow_id,omitempty"`
	Config         *RoomConfig `json:"config,omitempty"`
}

CreateAudioRoomsReq represents the request for creating an audio room

type CreateAudioRoomsResp

type CreateAudioRoomsResp struct {
	RoomID string `json:"room_id"`
	AppID  string `json:"app_id"`
	Token  string `json:"token"`
	UID    string `json:"uid"`
	// contains filtered or unexported fields
}

CreateAudioRoomsResp represents the response for creating an audio room

func (*CreateAudioRoomsResp) LogID

func (r *CreateAudioRoomsResp) LogID() string

func (*CreateAudioRoomsResp) Response

func (r *CreateAudioRoomsResp) Response() HTTPResponse

type CreateAudioSpeechReq

type CreateAudioSpeechReq struct {
	Input          string       `json:"input"`
	VoiceID        string       `json:"voice_id"`
	ResponseFormat *AudioFormat `json:"response_format"`
	Speed          *float32     `json:"speed"`
	SampleRate     *int         `json:"sample_rate"`
	LoudnessRate   *int         `json:"loudness_rate"`
	Emotion        *string      `json:"emotion"`
	EmotionScale   *float32     `json:"emotion_scale"`
}

CreateAudioSpeechReq represents the request for creating speech

type CreateAudioSpeechResp

type CreateAudioSpeechResp struct {
	Data io.ReadCloser
	// contains filtered or unexported fields
}

CreateAudioSpeechResp represents the response for creating speech

func (*CreateAudioSpeechResp) LogID

func (r *CreateAudioSpeechResp) LogID() string

func (*CreateAudioSpeechResp) Response

func (r *CreateAudioSpeechResp) Response() HTTPResponse

func (*CreateAudioSpeechResp) WriteToFile

func (c *CreateAudioSpeechResp) WriteToFile(path string) error

type CreateAudioTranscriptionsResp

type CreateAudioTranscriptionsResp struct {
	Data AudioTranscriptionsData `json:"data"`
	// contains filtered or unexported fields
}

func (*CreateAudioTranscriptionsResp) LogID

func (r *CreateAudioTranscriptionsResp) LogID() string

func (*CreateAudioTranscriptionsResp) Response

func (r *CreateAudioTranscriptionsResp) Response() HTTPResponse

type CreateBotsReq

type CreateBotsReq struct {
	SpaceID         string              `json:"space_id"`          // Space ID
	Name            string              `json:"name"`              // Name
	Description     string              `json:"description"`       // Description
	IconFileID      string              `json:"icon_file_id"`      // Icon file ID
	PromptInfo      *BotPromptInfo      `json:"prompt_info"`       // Prompt information
	OnboardingInfo  *BotOnboardingInfo  `json:"onboarding_info"`   // Onboarding information
	ModelInfoConfig *BotModelInfoConfig `json:"model_info_config"` // ModelInfoConfig information
	WorkflowIDList  *WorkflowIDList     `json:"workflow_id_list"`  // WorkflowIDList information
}

type CreateBotsResp

type CreateBotsResp struct {
	BotID string `json:"bot_id"`
	// contains filtered or unexported fields
}

func (*CreateBotsResp) LogID

func (r *CreateBotsResp) LogID() string

func (*CreateBotsResp) Response

func (r *CreateBotsResp) Response() HTTPResponse

type CreateChatsReq

type CreateChatsReq struct {
	// Indicate which conversation the chat is taking place in.
	ConversationID string `query:"conversation_id" json:"-"`

	// The ID of the bot that the API interacts with.
	BotID string `json:"bot_id"`

	// The user who calls the API to chat with the bot.
	UserID string `json:"user_id"`

	// Additional information for the conversation. You can pass the user's query for this
	// conversation through this field. The array length is limited to 100, meaning up to 100 messages can be input.
	Messages []*Message `json:"additional_messages,omitempty"`

	// developer can ignore this param
	Stream *bool `json:"stream,omitempty"`

	// The customized variable in a key-value pair.
	CustomVariables map[string]string `json:"custom_variables,omitempty"`

	// Whether to automatically save the history of conversation records.
	AutoSaveHistory *bool `json:"auto_save_history,omitempty"`

	// Additional information, typically used to encapsulate some business-related fields.
	MetaData map[string]string `json:"meta_data,omitempty"`

	// Optional: Specify a connector ID. Supports passing in 999 (Chat SDK) and 1024 (API). If not provided, the default is 1024 (API).
	ConnectorID string `json:"connector_id"`

	// Optional:Assign values to custom parameters and pass them to the workflow
	Parameters map[string]any `json:"parameters,omitempty"`

	// Optional: Support card response for question node
	EnableCard *bool `json:"enable_card,omitempty"`
}

CreateChatsReq represents the request to create a chat

type CreateChatsResp

type CreateChatsResp struct {
	Chat
	// contains filtered or unexported fields
}

func (*CreateChatsResp) LogID

func (r *CreateChatsResp) LogID() string

func (*CreateChatsResp) Response

func (r *CreateChatsResp) Response() HTTPResponse

type CreateConversationMessageFeedbackReq

type CreateConversationMessageFeedbackReq struct {
	// The ID of the conversation.
	ConversationID string `path:"conversation_id" json:"-"`
	// The ID of the message.
	MessageID string `path:"message_id" json:"-"`
	// The type of feedback.
	FeedbackType FeedbackType `json:"feedback_type"`
	// Optional reasons for the feedback.
	ReasonTypes []string `json:"reason_types,omitempty"`
	// Optional comment for the feedback.
	Comment *string `json:"comment,omitempty"`
}

CreateConversationMessageFeedbackReq represents request for creating message feedback

type CreateConversationMessageFeedbackResp

type CreateConversationMessageFeedbackResp struct {
	// contains filtered or unexported fields
}

CreateConversationMessageFeedbackResp represents response for creating message feedback

func (*CreateConversationMessageFeedbackResp) LogID

func (r *CreateConversationMessageFeedbackResp) LogID() string

func (*CreateConversationMessageFeedbackResp) Response

func (r *CreateConversationMessageFeedbackResp) Response() HTTPResponse

type CreateConversationsReq

type CreateConversationsReq struct {
	// Messages in the conversation. For more information, see EnterMessage object.
	Messages []*Message `json:"messages,omitempty"`

	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages.
	MetaData map[string]string `json:"meta_data,omitempty"`

	// Bind and isolate conversation on different bots.
	BotID string `json:"bot_id,omitempty"`

	// Optional: Specify a connector ID. Supports passing in 999 (Chat SDK) and 1024 (API). If not provided, the default is 1024 (API).
	ConnectorID string `json:"connector_id"`
}

CreateConversationsReq represents request for creating conversation

type CreateConversationsResp

type CreateConversationsResp struct {
	Conversation
	// contains filtered or unexported fields
}

func (*CreateConversationsResp) LogID

func (r *CreateConversationsResp) LogID() string

func (*CreateConversationsResp) Response

func (r *CreateConversationsResp) Response() HTTPResponse

type CreateDatasetResp

type CreateDatasetResp struct {
	DatasetID string `json:"dataset_id"`
	// contains filtered or unexported fields
}

func (*CreateDatasetResp) LogID

func (r *CreateDatasetResp) LogID() string

func (*CreateDatasetResp) Response

func (r *CreateDatasetResp) Response() HTTPResponse

type CreateDatasetsDocumentsReq

type CreateDatasetsDocumentsReq struct {
	// The ID of the knowledge base.
	DatasetID int64 `json:"dataset_id"`

	// The metadata information of the files awaiting upload. The array has a maximum length of 10,
	// meaning up to 10 files can be uploaded at a time. For detailed instructions, refer to the
	// DocumentBase object.
	DocumentBases []*DocumentBase `json:"document_bases"`

	// Chunk strategy. These rules must be set only when uploading a file to new knowledge for the
	// first time. For subsequent file uploads to this knowledge, it is not necessary to pass these
	// rules; the default is to continue using the initial settings, and modifications are not
	// supported. For detailed instructions, refer to the ChunkStrategy object.
	ChunkStrategy *DocumentChunkStrategy `json:"chunk_strategy,omitempty"`

	// The type of file format. Values include:
	// 0: Document type, such as txt, pdf, online web pages, etc.
	// 2: Images type, such as png images, etc.
	FormatType DocumentFormatType `json:"format_type"`
}

CreateDatasetsDocumentsReq represents request for creating document

type CreateDatasetsDocumentsResp

type CreateDatasetsDocumentsResp struct {
	DocumentInfos []*Document `json:"document_infos"`
	// contains filtered or unexported fields
}

CreateDatasetsDocumentsResp represents response for creating document

func (*CreateDatasetsDocumentsResp) LogID

func (r *CreateDatasetsDocumentsResp) LogID() string

func (*CreateDatasetsDocumentsResp) Response

func (r *CreateDatasetsDocumentsResp) Response() HTTPResponse

type CreateDatasetsReq

type CreateDatasetsReq struct {
	Name        string             `json:"name"`
	SpaceID     string             `json:"space_id"`
	FormatType  DocumentFormatType `json:"format_type"`
	Description string             `json:"description,omitempty"`
	IconFileID  string             `json:"file_id,omitempty"`
}

CreateDatasetsReq 表示创建数据集的请求

type CreateEnterpriseMemberReq

type CreateEnterpriseMemberReq struct {
	EnterpriseID string              `path:"enterprise_id" json:"-"`
	Users        []*EnterpriseMember `json:"users"`
}

CreateEnterpriseMemberReq represents the request to create enterprise members

type CreateEnterpriseMemberResp

type CreateEnterpriseMemberResp struct {
	// contains filtered or unexported fields
}

CreateEnterpriseMemberResp represents the response from creating enterprise members

func (*CreateEnterpriseMemberResp) LogID

func (r *CreateEnterpriseMemberResp) LogID() string

func (*CreateEnterpriseMemberResp) Response

func (r *CreateEnterpriseMemberResp) Response() HTTPResponse

type CreateMessageReq

type CreateMessageReq struct {
	// The ID of the conversation.
	ConversationID string `query:"conversation_id" json:"-"`

	// The entity that sent this message.
	Role MessageRole `json:"role"`

	// The content of the message, supporting pure text, multimodal (mixed input of text, images, files),
	// cards, and various types of content.
	Content string `json:"content"`

	// The type of message content.
	ContentType MessageContentType `json:"content_type"`

	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages.
	MetaData map[string]string `json:"meta_data,omitempty"`
}

CreateMessageReq represents request for creating message

func (*CreateMessageReq) SetObjectContext

func (c *CreateMessageReq) SetObjectContext(objs []*MessageObjectString)

type CreateMessageResp

type CreateMessageResp struct {
	Message
	// contains filtered or unexported fields
}

CreateMessageResp represents response for creating message

func (*CreateMessageResp) LogID

func (r *CreateMessageResp) LogID() string

func (*CreateMessageResp) Response

func (r *CreateMessageResp) Response() HTTPResponse

type CreateVoicePrintGroupFeatureReq

type CreateVoicePrintGroupFeatureReq struct {
	GroupID    string    `path:"group_id" json:"-"`
	Name       string    `json:"name,omitempty"`
	File       FileTypes `json:"file,omitempty"`
	Desc       *string   `json:"desc,omitempty"`
	SampleRate *int      `json:"sample_rate,omitempty"`
	Channel    *int      `json:"channel,omitempty"`
}

type CreateVoicePrintGroupFeatureResp

type CreateVoicePrintGroupFeatureResp struct {
	ID string `json:"id"`
	// contains filtered or unexported fields
}

func (*CreateVoicePrintGroupFeatureResp) LogID

func (r *CreateVoicePrintGroupFeatureResp) LogID() string

func (*CreateVoicePrintGroupFeatureResp) Response

func (r *CreateVoicePrintGroupFeatureResp) Response() HTTPResponse

type CreateVoicePrintGroupReq

type CreateVoicePrintGroupReq struct {
	Name string `json:"name"`
	Desc string `json:"desc"`
}

type CreateVoicePrintGroupResp

type CreateVoicePrintGroupResp struct {
	ID string `json:"id"`
	// contains filtered or unexported fields
}

func (*CreateVoicePrintGroupResp) LogID

func (r *CreateVoicePrintGroupResp) LogID() string

func (*CreateVoicePrintGroupResp) Response

func (r *CreateVoicePrintGroupResp) Response() HTTPResponse

type CreateWebsocketAudioSpeechReq

type CreateWebsocketAudioSpeechReq struct {
	WebSocketClientOption *WebSocketClientOption
}

type CreateWebsocketAudioTranscriptionReq

type CreateWebsocketAudioTranscriptionReq struct {
	WebSocketClientOption *WebSocketClientOption
}

type CreateWebsocketChatReq

type CreateWebsocketChatReq struct {
	WebSocketClientOption *WebSocketClientOption

	// BotID is the ID of the bot.
	BotID *string `json:"bot_id"`
	// WorkflowID is the ID of the workflow.
	WorkflowID *string `json:"workflow_id"`
	// DeviceID is the ID of the device.
	DeviceID *int64 `json:"device_id"`
}

type CreateWorkspaceMemberReq

type CreateWorkspaceMemberReq struct {
	WorkspaceID string             `path:"workspace_id" json:"-"`
	Users       []*WorkspaceMember `json:"users"`
}

type CreateWorkspaceMemberResp

type CreateWorkspaceMemberResp struct {
	AddedSuccessUserIDs   []string `json:"added_success_user_ids"`   // 团队或企业版成功添加的用户 ID 列表。
	InvitedSuccessUserIDs []string `json:"invited_success_user_ids"` // 个人版中,发起邀请且用户同意加入的用户 ID 列表。
	NotExistUserIDs       []string `json:"not_exist_user_ids"`       // 因用户不存在而导致添加失败的用户 ID 列表。
	AlreadyJoinedUserIDs  []string `json:"already_joined_user_ids"`  // 用户在该工作空间中已经存在,不重复添加。
	AlreadyInvitedUserIDs []string `json:"already_invited_user_ids"` // 已经发起邀请但用户还未同意加入的用户 ID 列表。
	// contains filtered or unexported fields
}

func (*CreateWorkspaceMemberResp) LogID

func (r *CreateWorkspaceMemberResp) LogID() string

func (*CreateWorkspaceMemberResp) Response

func (r *CreateWorkspaceMemberResp) Response() HTTPResponse

type Dataset

type Dataset struct {
	ID                   string                 `json:"dataset_id"`
	Name                 string                 `json:"name"`
	Description          string                 `json:"description"`
	SpaceID              string                 `json:"space_id"`
	Status               DatasetStatus          `json:"status"`
	FormatType           DocumentFormatType     `json:"format_type"`
	CanEdit              bool                   `json:"can_edit"`
	IconURL              string                 `json:"icon_url"`
	DocCount             int                    `json:"doc_count"`
	FileList             []string               `json:"file_list"`
	HitCount             int                    `json:"hit_count"`
	BotUsedCount         int                    `json:"bot_used_count"`
	SliceCount           int                    `json:"slice_count"`
	AllFileSize          string                 `json:"all_file_size"`
	ChunkStrategy        *DocumentChunkStrategy `json:"chunk_strategy,omitempty"`
	FailedFileList       []string               `json:"failed_file_list"`
	ProcessingFileList   []string               `json:"processing_file_list"`
	ProcessingFileIDList []string               `json:"processing_file_id_list"`
	AvatarURL            string                 `json:"avatar_url"`
	CreatorID            string                 `json:"creator_id"`
	CreatorName          string                 `json:"creator_name"`
	CreateTime           int                    `json:"create_time"`
	UpdateTime           int                    `json:"update_time"`
}

Dataset 表示数据集信息

type DatasetStatus

type DatasetStatus int

DatasetStatus 表示数据集状态

const (
	DatasetStatusEnabled  DatasetStatus = 1
	DatasetStatusDisabled DatasetStatus = 3
)

type DeleteConversationMessageFeedbackReq

type DeleteConversationMessageFeedbackReq struct {
	// The ID of the conversation.
	ConversationID string `path:"conversation_id" json:"-"`
	// The ID of the message.
	MessageID string `path:"message_id" json:"-"`
}

DeleteConversationMessageFeedbackReq represents request for deleting message feedback

type DeleteConversationMessageFeedbackResp

type DeleteConversationMessageFeedbackResp struct {
	// contains filtered or unexported fields
}

DeleteConversationMessageFeedbackResp represents response for deleting message feedback

func (*DeleteConversationMessageFeedbackResp) LogID

func (r *DeleteConversationMessageFeedbackResp) LogID() string

func (*DeleteConversationMessageFeedbackResp) Response

func (r *DeleteConversationMessageFeedbackResp) Response() HTTPResponse

type DeleteConversationsMessagesReq

type DeleteConversationsMessagesReq struct {
	// The ID of the conversation.
	ConversationID string `query:"conversation_id" json:"-"`

	// message id
	MessageID string `query:"message_id" json:"-"`
}

DeleteConversationsMessagesReq represents request for deleting message

type DeleteConversationsMessagesResp

type DeleteConversationsMessagesResp struct {
	Message
	// contains filtered or unexported fields
}

DeleteConversationsMessagesResp represents response for creating message

func (*DeleteConversationsMessagesResp) LogID

func (r *DeleteConversationsMessagesResp) LogID() string

func (*DeleteConversationsMessagesResp) Response

func (r *DeleteConversationsMessagesResp) Response() HTTPResponse

type DeleteDatasetsDocumentsReq

type DeleteDatasetsDocumentsReq struct {
	DocumentIDs []int64 `json:"document_ids"`
}

DeleteDatasetsDocumentsReq represents request for deleting datasetsDocuments

type DeleteDatasetsDocumentsResp

type DeleteDatasetsDocumentsResp struct {
	// contains filtered or unexported fields
}

DeleteDatasetsDocumentsResp represents response for deleting datasetsDocuments

func (*DeleteDatasetsDocumentsResp) LogID

func (r *DeleteDatasetsDocumentsResp) LogID() string

func (*DeleteDatasetsDocumentsResp) Response

func (r *DeleteDatasetsDocumentsResp) Response() HTTPResponse

type DeleteDatasetsReq

type DeleteDatasetsReq struct {
	DatasetID string `path:"dataset_id" json:"-"`
}

DeleteDatasetsReq 表示删除数据集的请求

type DeleteDatasetsResp

type DeleteDatasetsResp struct {
	// contains filtered or unexported fields
}

func (*DeleteDatasetsResp) LogID

func (r *DeleteDatasetsResp) LogID() string

func (*DeleteDatasetsResp) Response

func (r *DeleteDatasetsResp) Response() HTTPResponse

type DeleteEnterpriseMemberReq

type DeleteEnterpriseMemberReq struct {
	EnterpriseID   string `path:"enterprise_id" json:"-"`
	UserID         string `path:"user_id" json:"-"`
	ReceiverUserID string `json:"receiver_user_id"`
}

DeleteEnterpriseMemberReq represents the request to delete an enterprise member

type DeleteEnterpriseMemberResp

type DeleteEnterpriseMemberResp struct {
	// contains filtered or unexported fields
}

DeleteEnterpriseMemberResp represents the response from deleting an enterprise member

func (*DeleteEnterpriseMemberResp) LogID

func (r *DeleteEnterpriseMemberResp) LogID() string

func (*DeleteEnterpriseMemberResp) Response

func (r *DeleteEnterpriseMemberResp) Response() HTTPResponse

type DeleteVoicePrintGroupFeatureReq

type DeleteVoicePrintGroupFeatureReq struct {
	GroupID   string `path:"group_id" json:"-"`
	FeatureID string `path:"feature_id" json:"-"`
}

type DeleteVoicePrintGroupFeatureResp

type DeleteVoicePrintGroupFeatureResp struct {
	// contains filtered or unexported fields
}

func (*DeleteVoicePrintGroupFeatureResp) LogID

func (r *DeleteVoicePrintGroupFeatureResp) LogID() string

func (*DeleteVoicePrintGroupFeatureResp) Response

func (r *DeleteVoicePrintGroupFeatureResp) Response() HTTPResponse

type DeleteVoicePrintGroupReq

type DeleteVoicePrintGroupReq struct {
	GroupID string `path:"group_id" json:"-"`
}

type DeleteVoicePrintGroupResp

type DeleteVoicePrintGroupResp struct {
	// contains filtered or unexported fields
}

func (*DeleteVoicePrintGroupResp) LogID

func (r *DeleteVoicePrintGroupResp) LogID() string

func (*DeleteVoicePrintGroupResp) Response

func (r *DeleteVoicePrintGroupResp) Response() HTTPResponse

type DeleteWorkspaceMemberReq

type DeleteWorkspaceMemberReq struct {
	WorkspaceID string   `path:"workspace_id" json:"-"`
	UserIDs     []string `json:"user_ids" sep:","`
}

type DeleteWorkspaceMemberResp

type DeleteWorkspaceMemberResp struct {
	RemovedSuccessUserIDs        []string `json:"removed_success_user_ids"`          // 成功移除的成员列表。
	NotInWorkspaceUserIDs        []string `json:"not_in_workspace_user_ids"`         // 不在当前空间中的用户 ID 列表,这些用户不会被处理。
	OwnerNotSupportRemoveUserIDs []string `json:"owner_not_support_remove_user_ids"` // 移除失败,该用户为空间所有者。
	// contains filtered or unexported fields
}

func (*DeleteWorkspaceMemberResp) LogID

func (r *DeleteWorkspaceMemberResp) LogID() string

func (*DeleteWorkspaceMemberResp) Response

func (r *DeleteWorkspaceMemberResp) Response() HTTPResponse

type DeviceAuthReq

type DeviceAuthReq struct {
	ClientID string `json:"client_id"`
}

DeviceAuthReq represents the device authorization request

type DeviceInfo

type DeviceInfo struct {
	DeviceID       *string `json:"device_id,omitempty"`
	CustomConsumer *string `json:"custom_consumer,omitempty"`
}

type DeviceOAuthClient

type DeviceOAuthClient struct {
	*OAuthClient
}

DeviceOAuthClient represents the device OAuth core

func NewDeviceOAuthClient

func NewDeviceOAuthClient(clientID string, opts ...OAuthClientOption) (*DeviceOAuthClient, error)

NewDeviceOAuthClient creates a new device OAuth core

func (*DeviceOAuthClient) GetAccessToken

func (*DeviceOAuthClient) GetDeviceCode

GetDeviceCode gets the device code

func (*DeviceOAuthClient) RefreshToken

func (c *DeviceOAuthClient) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error)

RefreshToken refreshes the access token

type Document

type Document struct {
	// The ID of the file.
	DocumentID string `json:"document_id"`

	// The total character count of the file content.
	CharCount int `json:"char_count"`

	// The chunking rules. For detailed instructions, refer to the ChunkStrategy object.
	ChunkStrategy *DocumentChunkStrategy `json:"chunk_strategy"`

	// The upload time of the file, in the format of a 10-digit Unix timestamp.
	CreateTime int `json:"create_time"`

	// The last modified time of the file, in the format of a 10-digit Unix timestamp.
	UpdateTime int `json:"update_time"`

	// The type of file format. Values include:
	// 0: Document type, such as txt, pdf, online web pages, etc.
	// 1: Spreadsheet type, such as xls spreadsheets, etc.
	// 2: Images type, such as png images, etc.
	FormatType DocumentFormatType `json:"format_type"`

	// The number of times the file has been hit in conversations.
	HitCount int `json:"hit_count"`

	// The name of the file.
	Name string `json:"name"`

	// The size of the file in bytes.
	Size int `json:"size"`

	// The number of slices the file has been divided into.
	SliceCount int `json:"slice_count"`

	// The method of uploading the file. Values include:
	// 0: Upload local files.
	// 1: Upload online web pages.
	SourceType DocumentSourceType `json:"source_type"`

	// The processing status of the file. Values include:
	// 0: Processing
	// 1: Completed
	// 9: Processing failed, it is recommended to re-upload
	Status DocumentStatus `json:"status"`

	// The format of the local file, i.e., the file extension, such as "txt".
	// Supported formats include PDF, TXT, DOC, DOCX.
	Type string `json:"type"`

	// The frequency of automatic updates for online web pages, in hours.
	UpdateInterval int `json:"update_interval"`

	// Whether the online web page is automatically updated. Values include:
	// 0: Do not automatically update
	// 1: Automatically update
	UpdateType DocumentUpdateType `json:"update_type"`
}

Document represents a document in the datasets

type DocumentBase

type DocumentBase struct {
	// The name of the file.
	Name string `json:"name"`

	// The metadata information of the file.
	SourceInfo *DocumentSourceInfo `json:"source_info"`

	// The update strategy for online web pages. Defaults to no automatic update.
	UpdateRule *DocumentUpdateRule `json:"update_rule,omitempty"`
}

DocumentBase represents base information for creating a document

func DocumentBaseBuildImage

func DocumentBaseBuildImage(name string, fileID int64) *DocumentBase

DocumentBaseBuildImage creates basic document information for image type

func DocumentBaseBuildLocalFile

func DocumentBaseBuildLocalFile(name string, content string, fileType string) *DocumentBase

DocumentBaseBuildLocalFile creates basic document information for local file type

func DocumentBaseBuildWebPage

func DocumentBaseBuildWebPage(name string, url string, interval *int) *DocumentBase

DocumentBaseBuildWebPage creates basic document information for webpage type

type DocumentChunkStrategy

type DocumentChunkStrategy struct {
	// The chunking settings. Values include:
	// 0: Automatic chunking and cleaning. Uses preset rules for data chunking and processing.
	// 1: Custom. In this case, details need to be specified through separator, max_tokens,
	// remove_extra_spaces, and remove_urls_emails.
	ChunkType int `json:"chunk_type"`

	// Maximum chunk length, ranging from 100 to 2000.
	// Required when chunk_type=1.
	MaxTokens int `json:"max_tokens,omitempty"`

	// Whether to automatically filter consecutive spaces, line breaks, and tabs.
	// Values include:
	// true: Automatically filter
	// false: (Default) Do not automatically filter
	// Takes effect when chunk_type=1.
	RemoveExtraSpaces bool `json:"remove_extra_spaces,omitempty"`

	// Whether to automatically filter all URLs and email addresses.
	// Values include:
	// true: Automatically filter
	// false: (Default) Do not automatically filter
	// Takes effect when chunk_type=1.
	RemoveUrlsEmails bool `json:"remove_urls_emails,omitempty"`

	// The chunk identifier.
	// Required when chunk_type=1.
	Separator string `json:"separator,omitempty"`
}

DocumentChunkStrategy represents chunking strategy for datasetsDocuments

type DocumentFormatType

type DocumentFormatType int

DocumentFormatType represents the format type of a document

const (
	// Document type, such as txt, pdf, online web pages, etc.
	DocumentFormatTypeDocument DocumentFormatType = 0
	// Spreadsheet type, such as xls spreadsheets, etc.
	DocumentFormatTypeSpreadsheet DocumentFormatType = 1
	// Images type, such as png images, etc.
	DocumentFormatTypeImage DocumentFormatType = 2
)

type DocumentProgress

type DocumentProgress struct {
	DocumentID     string             `json:"document_id"`
	URL            string             `json:"url"`
	Size           int                `json:"size"`
	Type           string             `json:"type"`
	Status         DocumentStatus     `json:"status"`
	Progress       int                `json:"progress"`
	UpdateType     DocumentUpdateType `json:"update_type"`
	DocumentName   string             `json:"document_name"`
	RemainingTime  int                `json:"remaining_time"`
	StatusDescript string             `json:"status_descript"`
	UpdateInterval int                `json:"update_interval"`
}

DocumentProgress 表示文档处理进度

type DocumentSourceInfo

type DocumentSourceInfo struct {
	// Base64 encoding of the local file.
	// Required when uploading local files.
	FileBase64 *string `json:"file_base64,omitempty"`

	// The format of the local file, i.e., the file extension, such as "txt".
	// Supported formats include PDF, TXT, DOC, DOCX.
	// The uploaded file type should match the knowledge base type.
	// Required when uploading local files.
	FileType *string `json:"file_type,omitempty"`

	// The URL of the webpage.
	// Required when uploading webpages.
	WebUrl *string `json:"web_url,omitempty"`

	// The upload method of the file.
	// 1 to indicate uploading online webpages.
	// 5 to indicate uploading fileID.
	// Required when uploading online webpages.
	DocumentSource *int `json:"document_source,omitempty"`

	SourceFileID *int64 `json:"source_file_id,omitempty"`
}

DocumentSourceInfo represents source information for a document

func DocumentSourceInfoBuildImage

func DocumentSourceInfoBuildImage(fileID int64) *DocumentSourceInfo

DocumentSourceInfoBuildImage creates document source information for image type

func DocumentSourceInfoBuildLocalFile

func DocumentSourceInfoBuildLocalFile(content string, fileType string) *DocumentSourceInfo

DocumentSourceInfoBuildLocalFile creates document source information for local file type

func DocumentSourceInfoBuildWebPage

func DocumentSourceInfoBuildWebPage(url string) *DocumentSourceInfo

DocumentSourceInfoBuildWebPage creates document source information for webpage type

type DocumentSourceType

type DocumentSourceType int

DocumentSourceType represents the source type of a document

const (
	// Upload local files.
	DocumentSourceTypeLocalFile DocumentSourceType = 0
	// Upload online web pages.
	DocumentSourceTypeOnlineWeb DocumentSourceType = 1
)

type DocumentStatus

type DocumentStatus int

DocumentStatus represents the status of a document

const (
	// Processing
	DocumentStatusProcessing DocumentStatus = 0
	// Completed
	DocumentStatusCompleted DocumentStatus = 1
	// Processing failed, it is recommended to re-upload
	DocumentStatusFailed DocumentStatus = 9
)

type DocumentUpdateRule

type DocumentUpdateRule struct {
	// Whether the online webpage is automatically updated.
	// Values include:
	// 0: Do not automatically update
	// 1: Automatically update
	UpdateType DocumentUpdateType `json:"update_type"`

	// The frequency of automatic updates for online webpages, in hours.
	// Minimum value is 24.
	UpdateInterval int `json:"update_interval"`
}

DocumentUpdateRule represents update rules for datasetsDocuments

func DocumentUpdateRuleBuildAutoUpdate

func DocumentUpdateRuleBuildAutoUpdate(interval int) *DocumentUpdateRule

DocumentUpdateRuleBuildAutoUpdate creates a rule for automatic updates with specified interval

func DocumentUpdateRuleBuildNoAuto

func DocumentUpdateRuleBuildNoAuto() *DocumentUpdateRule

DocumentUpdateRuleBuildNoAuto creates a rule for no automatic updates

type DocumentUpdateType

type DocumentUpdateType int

DocumentUpdateType represents the update type of a document

const (
	// Do not automatically update
	DocumentUpdateTypeNoAutoUpdate DocumentUpdateType = 0
	// Automatically update
	DocumentUpdateTypeAutoUpdate DocumentUpdateType = 1
)

type DuplicateTemplateReq

type DuplicateTemplateReq struct {
	TemplateID  string  `path:"template_id" json:"-"`
	WorkspaceID string  `json:"workspace_id,omitempty"`
	Name        *string `json:"name,omitempty"`
}

DuplicateTemplateReq represents the request to duplicate a template

type EnterpriseMember

type EnterpriseMember struct {
	UserID string               `json:"user_id"` // 用户ID
	Role   EnterpriseMemberRole `json:"role"`    // 当前用户角色
}

EnterpriseMember represents an enterprise member

type EnterpriseMemberRole

type EnterpriseMemberRole string

EnterpriseMemberRole represents the role of an enterprise member

const (
	// EnterpriseMemberRoleAdmin represents an enterprise administrator
	EnterpriseMemberRoleAdmin EnterpriseMemberRole = "enterprise_admin"
	// EnterpriseMemberRoleMember represents an enterprise member
	EnterpriseMemberRoleMember EnterpriseMemberRole = "enterprise_member"
)

type Error

type Error struct {
	Code    int
	Message string
	LogID   string
}

func AsCozeError

func AsCozeError(err error) (*Error, bool)

AsCozeError checks if the error is of type Error

func NewError

func NewError(code int, msg, logID string) *Error

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

type EventDetail

type EventDetail struct {
	LogID         string `json:"logid,omitempty"`
	RespondAt     string `json:"respond_at,omitempty"`
	OriginMessage string `json:"origin_message,omitempty"`
}

EventDetail contains additional event details

type EventHandler

type EventHandler func(event IWebSocketEvent) error

EventHandler represents a WebSocket event handler

type FeatureScore

type FeatureScore struct {
	FeatureID   string  `json:"feature_id"`
	FeatureName string  `json:"feature_name"`
	FeatureDesc string  `json:"feature_desc"`
	Score       float64 `json:"score"`
}

type FeedbackType

type FeedbackType string

FeedbackType represents the type of feedback

const (
	// FeedbackTypeLike represents a like feedback
	FeedbackTypeLike FeedbackType = "like"
	// FeedbackTypeUnlike represents an unlike feedback
	FeedbackTypeUnlike FeedbackType = "unlike"
)

type FileInfo

type FileInfo struct {
	// The ID of the uploaded file.
	ID string `json:"id"`

	// The total byte size of the file.
	Bytes int `json:"bytes"`

	// The upload time of the file, in the format of a 10-digit Unix timestamp in seconds (s).
	CreatedAt int `json:"created_at"`

	// The name of the file.
	FileName string `json:"file_name"`
}

FileInfo represents information about a file

type FileTypes

type FileTypes interface {
	io.Reader
	Name() string
}

func NewUploadFile

func NewUploadFile(reader io.Reader, fileName string) FileTypes

type FolderType

type FolderType string
const (
	FolderTypeDevelopment FolderType = "development" // 项目开发
	FolderTypeLibrary     FolderType = "library"     // 资源库
)

type GenerateJWTReq

type GenerateJWTReq struct {
	TTL            int             `json:"ttl,omitempty"`             // Token validity period (in seconds)
	SessionName    *string         `json:"session_name,omitempty"`    // Session name
	SessionContext *SessionContext `json:"session_context,omitempty"` // SessionContext
}

GenerateJWTReq represents options for generate JWT

type GetDeviceAuthResp

type GetDeviceAuthResp struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri"`
	VerificationURL string `json:"verification_url"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
	// contains filtered or unexported fields
}

GetDeviceAuthResp represents the device authorization response

func (*GetDeviceAuthResp) GetCode

func (r *GetDeviceAuthResp) GetCode() int

func (*GetDeviceAuthResp) GetMsg

func (r *GetDeviceAuthResp) GetMsg() string

func (*GetDeviceAuthResp) LogID

func (r *GetDeviceAuthResp) LogID() string

func (*GetDeviceAuthResp) SetCode

func (r *GetDeviceAuthResp) SetCode(code int)

func (*GetDeviceAuthResp) SetHTTPResponse

func (r *GetDeviceAuthResp) SetHTTPResponse(httpResponse *httpResponse)

func (*GetDeviceAuthResp) SetMsg

func (r *GetDeviceAuthResp) SetMsg(msg string)

type GetDeviceOAuthAccessTokenReq

type GetDeviceOAuthAccessTokenReq struct {
	DeviceCode string
	Poll       bool
}

type GetDeviceOAuthCodeReq

type GetDeviceOAuthCodeReq struct {
	WorkspaceID *string
}

type GetJWTAccessTokenReq

type GetJWTAccessTokenReq struct {
	TTL            int             `json:"ttl,omitempty"`             // Token validity period (in seconds)
	Scope          *Scope          `json:"scope,omitempty"`           // Permission scope
	SessionName    *string         `json:"session_name,omitempty"`    // Session name
	AccountID      *int64          `json:"account_id,omitempty"`      // Account ID
	EnterpriseID   *string         `json:"enterprise_id,omitempty"`   // Enterprise ID
	SessionContext *SessionContext `json:"session_context,omitempty"` // SessionContext
}

GetJWTAccessTokenReq represents options for getting JWT OAuth token

type GetPKCEAccessTokenReq

type GetPKCEAccessTokenReq struct {
	Code, RedirectURI, CodeVerifier string
}

type GetPKCEOAuthURLReq

type GetPKCEOAuthURLReq struct {
	RedirectURI string
	State       string
	Method      *CodeChallengeMethod
	WorkspaceID *string
}

type GetPKCEOAuthURLResp

type GetPKCEOAuthURLResp struct {
	CodeVerifier     string `json:"code_verifier"`
	AuthorizationURL string `json:"authorization_url"`
}

GetPKCEOAuthURLResp represents the PKCE authorization URL response

type GetUserMeReq

type GetUserMeReq struct{}

type GetWebOAuthAccessTokenReq

type GetWebOAuthAccessTokenReq struct {
	Code, RedirectURI string
}

type GetWebOAuthURLReq

type GetWebOAuthURLReq struct {
	RedirectURI, State string
	WorkspaceID        *string
}

type GrantType

type GrantType string

GrantType represents the OAuth grant type

const (
	GrantTypeAuthorizationCode GrantType = "authorization_code"
	GrantTypeDeviceCode        GrantType = "urn:ietf:params:oauth:grant-type:device_code"
	GrantTypeJWTCode           GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"
	GrantTypeRefreshToken      GrantType = "refresh_token"
)

func (GrantType) String

func (r GrantType) String() string

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient an interface for making HTTP requests

type HTTPResponse

type HTTPResponse interface {
	LogID() string
}

type IWebSocketAudioSpeechHandler

type IWebSocketAudioSpeechHandler interface {
	OnClientError(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketClientErrorEvent) error
	OnClosed(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketClosedEvent) error
	OnError(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketErrorEvent) error
	OnSpeechCreated(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechCreatedEvent) error
	OnSpeechUpdated(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechUpdatedEvent) error
	OnInputTextBufferCompleted(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketInputTextBufferCompletedEvent) error
	OnSpeechAudioUpdate(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechAudioUpdateEvent) error
	OnSpeechAudioCompleted(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechAudioCompletedEvent) error
}

type IWebSocketChatHandler

type IWebSocketChatHandler interface {
	OnClientError(ctx context.Context, cli *WebSocketChat, event *WebSocketClientErrorEvent) error
	OnClosed(ctx context.Context, cli *WebSocketChat, event *WebSocketClosedEvent) error
	OnError(ctx context.Context, cli *WebSocketChat, event *WebSocketErrorEvent) error
	OnChatCreated(ctx context.Context, cli *WebSocketChat, event *WebSocketChatCreatedEvent) error
	OnChatUpdated(ctx context.Context, cli *WebSocketChat, event *WebSocketChatUpdatedEvent) error
	OnConversationChatCreated(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCreatedEvent) error
	OnConversationChatInProgress(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatInProgressEvent) error
	OnConversationMessageDelta(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationMessageDeltaEvent) error
	OnConversationAudioSentenceStart(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioSentenceStartEvent) error
	OnConversationAudioDelta(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioDeltaEvent) error
	OnConversationMessageCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationMessageCompletedEvent) error
	OnConversationAudioCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioCompletedEvent) error
	OnConversationChatCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCompletedEvent) error
	OnConversationChatFailed(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatFailedEvent) error
	OnInputAudioBufferCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferCompletedEvent) error
	OnInputAudioBufferCleared(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferClearedEvent) error
	OnConversationCleared(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationClearedEvent) error
	OnConversationChatCanceled(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCanceledEvent) error
	OnConversationAudioTranscriptUpdate(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptUpdateEvent) error
	OnConversationAudioTranscriptCompleted(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptCompletedEvent) error
	OnConversationChatRequiresAction(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatRequiresActionEvent) error
	OnInputAudioBufferSpeechStarted(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferSpeechStartedEvent) error
	OnInputAudioBufferSpeechStopped(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferSpeechStoppedEvent) error
}

type IWebSocketEvent

type IWebSocketEvent interface {
	GetEventType() WebSocketEventType
	GetID() string
	GetDetail() *EventDetail
}

IWebSocketEvent websocket 事件接口

type Image

type Image struct {
	// The ID of the file.
	DocumentID string `json:"document_id"`

	// The total character count of the file content.
	CharCount int `json:"char_count"`

	// The chunking rules. For detailed instructions, refer to the ChunkStrategy object.
	ChunkStrategy *DocumentChunkStrategy `json:"chunk_strategy"`

	// The upload time of the file, in the format of a 10-digit Unix timestamp.
	CreateTime int `json:"create_time"`

	// The last modified time of the file, in the format of a 10-digit Unix timestamp.
	UpdateTime int `json:"update_time"`

	// The type of file format. Values include:
	// 0: Document type, such as txt, pdf, online web pages, etc.
	// 1: Spreadsheet type, such as xls spreadsheets, etc.
	// 2: Images type, such as png images, etc.
	FormatType DocumentFormatType `json:"format_type"`

	// The number of times the file has been hit in conversations.
	HitCount int `json:"hit_count"`

	// The name of the file.
	Name string `json:"name"`

	// The size of the file in bytes.
	Size int `json:"size"`

	// The number of slices the file has been divided into.
	SliceCount int `json:"slice_count"`

	// The method of uploading the file. Values include:
	// 0: Upload local files.
	// 1: Upload online web pages.
	SourceType DocumentSourceType `json:"source_type"`

	// The processing status of the file. Values include:
	// 0: Processing
	// 1: Completed
	// 9: Processing failed, it is recommended to re-upload
	Status ImageStatus `json:"status"`

	// The caption of the image.
	Caption string `json:"caption"`

	// The ID of the creator.
	CreatorID string `json:"creator_id"`
}

Image 表示图片信息

type ImageStatus

type ImageStatus int

ImageStatus 表示图片状态

const (
	ImageStatusInProcessing     ImageStatus = 0 // 处理中
	ImageStatusCompleted        ImageStatus = 1 // 已完成
	ImageStatusProcessingFailed ImageStatus = 9 // 处理失败
)

type InsertedAdditionalMessage

type InsertedAdditionalMessage struct {
	ID string `json:"id"`
}

type JWTOAuthClient

type JWTOAuthClient struct {
	*OAuthClient
	// contains filtered or unexported fields
}

JWTOAuthClient represents the JWT OAuth core

func NewJWTOAuthClient

func NewJWTOAuthClient(param NewJWTOAuthClientParam, opts ...OAuthClientOption) (*JWTOAuthClient, error)

NewJWTOAuthClient creates a new JWT OAuth core

func (*JWTOAuthClient) GenerateJWT

func (c *JWTOAuthClient) GenerateJWT(ctx context.Context, opts *GenerateJWTReq) (string, error)

func (*JWTOAuthClient) GetAccessToken

func (c *JWTOAuthClient) GetAccessToken(ctx context.Context, opts *GetJWTAccessTokenReq) (*OAuthToken, error)

GetAccessToken gets the access token, using options pattern

type LanguageCode

type LanguageCode string

LanguageCode represents the language code

const (
	LanguageCodeZH LanguageCode = "zh"
	LanguageCodeEN LanguageCode = "en"
	LanguageCodeJA LanguageCode = "ja"
	LanguageCodeES LanguageCode = "es"
	LanguageCodeID LanguageCode = "id"
	LanguageCodePT LanguageCode = "pt"
)

func (LanguageCode) String

func (l LanguageCode) String() string

type LastIDPaged

type LastIDPaged[T any] interface {
	BasePaged[T]
	GetLastID() string
}

func NewLastIDPaged

func NewLastIDPaged[T any](fetcher PageFetcher[T], pageSize int, nextID *string) (LastIDPaged[T], error)

type LevelLogger

type LevelLogger interface {
	Logger
	SetLevel(level LogLevel)
}

func NewLevelLogger

func NewLevelLogger(logger Logger, level LogLevel) LevelLogger

NewLevelLogger ...

type ListAppReq

type ListAppReq struct {
	WorkspaceID   string         `query:"workspace_id" json:"-"`
	PublishStatus *PublishStatus `query:"publish_status" json:"-"`
	ConnectorID   *string        `query:"connector_id" json:"-"`
	PageNum       int            `query:"page_num" json:"-"`
	PageSize      int            `query:"page_size" json:"-"`
}

type ListAppResp

type ListAppResp struct {
	Total int          `json:"total"`
	Items []*SimpleApp `json:"items"`
}

type ListAudioVoicesReq

type ListAudioVoicesReq struct {
	FilterSystemVoice bool            `query:"filter_system_voice" json:"-"`
	PageNum           int             `query:"page_num" json:"-"`
	PageSize          int             `query:"page_size" json:"-"`
	ModelType         *VoiceModelType `query:"model_type" json:"-"`
	VoiceState        *VoiceState     `query:"voice_state" json:"-"`
}

ListAudioVoicesReq represents the request for listing voices

type ListAudioVoicesResp

type ListAudioVoicesResp struct {
	Data struct {
		VoiceList []*Voice `json:"voice_list"`
	} `json:"data"`
	// contains filtered or unexported fields
}

ListAudioVoicesResp represents the response for listing voices

func (*ListAudioVoicesResp) GetCode

func (r *ListAudioVoicesResp) GetCode() int

func (*ListAudioVoicesResp) GetMsg

func (r *ListAudioVoicesResp) GetMsg() string

func (*ListAudioVoicesResp) LogID

func (r *ListAudioVoicesResp) LogID() string

func (*ListAudioVoicesResp) SetCode

func (r *ListAudioVoicesResp) SetCode(code int)

func (*ListAudioVoicesResp) SetHTTPResponse

func (r *ListAudioVoicesResp) SetHTTPResponse(httpResponse *httpResponse)

func (*ListAudioVoicesResp) SetMsg

func (r *ListAudioVoicesResp) SetMsg(msg string)

type ListBotsReq

type ListBotsReq struct {
	SpaceID  string `query:"space_id" json:"-"`   // Space ID
	PageNum  int    `query:"page_index" json:"-"` // Page number
	PageSize int    `query:"page_size" json:"-"`  // Page size
}

ListBotsReq represents the request structure for listing bots

type ListChatsMessagesReq

type ListChatsMessagesReq struct {
	// The Conversation ID can be viewed in the 'conversation_id' field of the Response when
	// initiating a conversation through the Chat API.
	ConversationID string `query:"conversation_id" json:"-"`

	// The Chat ID can be viewed in the 'id' field of the Response when initiating a chat through the
	// Chat API. If it is a streaming response, check the 'id' field in the chat event of the Response.
	ChatID string `query:"chat_id" json:"-"`
}

ListChatsMessagesReq represents the request to list messages

type ListChatsMessagesResp

type ListChatsMessagesResp struct {
	Messages []*Message `json:"data"`
	// contains filtered or unexported fields
}

func (*ListChatsMessagesResp) LogID

func (r *ListChatsMessagesResp) LogID() string

func (*ListChatsMessagesResp) Response

func (r *ListChatsMessagesResp) Response() HTTPResponse

type ListConversationsMessagesReq

type ListConversationsMessagesReq struct {
	// The ID of the conversation.
	ConversationID string `query:"conversation_id" json:"-"`

	// The sorting method for the message list.
	Order *string `json:"order,omitempty"`

	// The ID of the Chat.
	ChatID *string `json:"chat_id,omitempty"`

	// Get messages before the specified position.
	BeforeID *string `json:"before_id,omitempty"`

	// Get messages after the specified position.
	AfterID *string `json:"after_id,omitempty"`

	// The amount of data returned per query. Default is 50, with a range of 1 to 50.
	Limit int `json:"limit,omitempty"`

	BotID *string `json:"bot_id,omitempty"`
}

ListConversationsMessagesReq represents request for listing messages

type ListConversationsMessagesResp

type ListConversationsMessagesResp struct {
	HasMore  bool       `json:"has_more"`
	FirstID  string     `json:"first_id"`
	LastID   string     `json:"last_id"`
	Messages []*Message `json:"data"`
	// contains filtered or unexported fields
}

func (*ListConversationsMessagesResp) LogID

func (r *ListConversationsMessagesResp) LogID() string

func (*ListConversationsMessagesResp) Response

func (r *ListConversationsMessagesResp) Response() HTTPResponse

type ListConversationsReq

type ListConversationsReq struct {
	// The ID of the bot.
	BotID string `query:"bot_id" json:"-"`

	// The page number.
	PageNum int `query:"page_num" json:"-"`

	// The page size.
	PageSize int `query:"page_size" json:"-"`
}

ListConversationsReq represents request for listing conversations

type ListConversationsResp

type ListConversationsResp struct {
	HasMore       bool            `json:"has_more"`
	Conversations []*Conversation `json:"conversations"`
	// contains filtered or unexported fields
}

ListConversationsResp represents response for listing conversations

func (*ListConversationsResp) LogID

func (r *ListConversationsResp) LogID() string

func (*ListConversationsResp) Response

func (r *ListConversationsResp) Response() HTTPResponse

type ListDatasetsDocumentsReq

type ListDatasetsDocumentsReq struct {
	// The ID of the knowledge base.
	DatasetID int64 `json:"dataset_id"`

	// The page number for paginated queries. Default is 1, meaning the data return starts from the
	// first page.
	Page int `json:"page,omitempty"`

	// The size of pagination. Default is 10, meaning that 10 data entries are returned per page.
	Size int `json:"size,omitempty"`
}

ListDatasetsDocumentsReq represents request for listing datasetsDocuments

type ListDatasetsDocumentsResp

type ListDatasetsDocumentsResp struct {
	Total         int64       `json:"total"`
	DocumentInfos []*Document `json:"document_infos"`
	// contains filtered or unexported fields
}

ListDatasetsDocumentsResp represents response for listing datasetsDocuments

func (*ListDatasetsDocumentsResp) LogID

func (r *ListDatasetsDocumentsResp) LogID() string

func (*ListDatasetsDocumentsResp) Response

func (r *ListDatasetsDocumentsResp) Response() HTTPResponse

type ListDatasetsImagesReq

type ListDatasetsImagesReq struct {
	DatasetID  string  `path:"dataset_id" json:"-"`
	Keyword    *string `query:"keyword" json:"-"`
	HasCaption *bool   `query:"has_caption" json:"-"`
	PageNum    int     `query:"page_num" json:"-"`
	PageSize   int     `query:"page_size" json:"-"`
}

ListDatasetsImagesReq 表示列出图片的请求

type ListDatasetsReq

type ListDatasetsReq struct {
	SpaceID    string             `query:"space_id" json:"-"`
	Name       string             `query:"name,omitempty" json:"-"`
	FormatType DocumentFormatType `query:"format_type,omitempty" json:"-"`
	PageNum    int                `query:"page_num" json:"-"`
	PageSize   int                `query:"page_size" json:"-"`
}

ListDatasetsReq 表示列出数据集的请求

func NewListDatasetsReq

func NewListDatasetsReq(spaceID string) *ListDatasetsReq

type ListDatasetsResp

type ListDatasetsResp struct {
	TotalCount  int        `json:"total_count"`
	DatasetList []*Dataset `json:"dataset_list"`
	// contains filtered or unexported fields
}

func (*ListDatasetsResp) LogID

func (r *ListDatasetsResp) LogID() string

func (*ListDatasetsResp) Response

func (r *ListDatasetsResp) Response() HTTPResponse

type ListFoldersReq

type ListFoldersReq struct {
	WorkspaceID    string     `query:"workspace_id" json:"-"`
	FolderType     FolderType `query:"folder_type" json:"-"`
	ParentFolderID *string    `query:"parent_folder_id" json:"-"`
	PageNum        int        `query:"page_num" json:"-"`
	PageSize       int        `query:"page_size" json:"-"`
}

type ListFoldersResp

type ListFoldersResp struct {
	Items      []*SimpleFolder `json:"items"`
	TotalCount int             `json:"total_count"`
}

type ListImagesResp

type ListImagesResp struct {
	ImagesInfos []*Image `json:"photo_infos"`
	TotalCount  int      `json:"total_count"`
	// contains filtered or unexported fields
}

func (*ListImagesResp) LogID

func (r *ListImagesResp) LogID() string

func (*ListImagesResp) Response

func (r *ListImagesResp) Response() HTTPResponse

type ListStoresPluginsReq

type ListStoresPluginsReq struct {
	Keyword     *string  `query:"keyword" json:"-"`      // 插件搜索的关键词,支持模糊匹配。
	IsOfficial  *bool    `query:"is_official" json:"-"`  // 是否为扣子官方插件。默认返回官方插件和三方插件。
	CategoryIDs []string `query:"category_ids" json:"-"` // 插件分类 ID 列表,用于筛选指定多个分类下的插件。默认为空,即返回所有分类下的插件。可以通过查询插件分类API 获取对应的插件分类 ID。
	SortType    *string  `query:"sort_type" json:"-"`    // 排序类型,用于指定返回插件的排序方式。支持的排序方式如下所示:
	PageNum     int      `query:"page_num" json:"-"`
	PageSize    int      `query:"page_size" json:"-"`
}

type ListStoresPluginsResp

type ListStoresPluginsResp struct {
	Items   []*ProductPlugin `json:"items"`
	HasMore bool             `json:"has_more"`
}

type ListVoicePrintGroupFeatureReq

type ListVoicePrintGroupFeatureReq struct {
	GroupID  string `path:"group_id" json:"-"`
	PageSize int    `query:"page_size" json:"-"`
	PageNum  int    `query:"page_num" json:"-"`
}

type ListVoicePrintGroupReq

type ListVoicePrintGroupReq struct {
	Name     *string `query:"name" json:"-"`
	GroupID  *string `query:"group_id" json:"-"`
	UserID   *string `query:"user_id" json:"-"`
	PageSize int     `query:"page_size" json:"-"`
	PageNum  int     `query:"page_num" json:"-"`
}

type ListVoicePrintGroupResp

type ListVoicePrintGroupResp struct {
	Total int                `json:"total"`
	Items []*VoicePrintGroup `json:"items"`
}

type ListWorkflowReq

type ListWorkflowReq struct {
	WorkspaceID   *string        `query:"workspace_id" json:"-"`
	WorkflowMode  *WorkflowMode  `query:"workflow_mode" json:"-"`
	AppID         *string        `query:"app_id" json:"-"`
	PublishStatus *PublishStatus `query:"publish_status" json:"-"`
	PageNum       int            `query:"page_num" json:"-"`
	PageSize      int            `query:"page_size" json:"-"`
}

type ListWorkflowResp

type ListWorkflowResp struct {
	HasMore bool            `json:"has_more"`
	Items   []*WorkflowInfo `json:"items"`
}

type ListWorkspaceMemberReq

type ListWorkspaceMemberReq struct {
	WorkspaceID string `path:"workspace_id" json:"-"`
	PageNum     int    `query:"page_num" json:"-"`
	PageSize    int    `query:"page_size" json:"-"`
}

ListWorkspaceMemberReq ...

type ListWorkspaceMemberResp

type ListWorkspaceMemberResp struct {
	TotalCount int                `json:"total_count"`
	Items      []*WorkspaceMember `json:"items"`
	// contains filtered or unexported fields
}

ListWorkspaceMemberResp ...

func (*ListWorkspaceMemberResp) LogID

func (r *ListWorkspaceMemberResp) LogID() string

func (*ListWorkspaceMemberResp) Response

func (r *ListWorkspaceMemberResp) Response() HTTPResponse

type ListWorkspaceReq

type ListWorkspaceReq struct {
	PageNum       int     `query:"page_num" json:"-"`
	PageSize      int     `query:"page_size" json:"-"`
	EnterpriseID  *string `query:"enterprise_id" json:"-"`
	UserID        *string `query:"user_id" json:"-"`
	CozeAccountID *string `query:"coze_account_id" json:"-"`
}

ListWorkspaceReq represents the request parameters for listing workspaces

func NewListWorkspaceReq

func NewListWorkspaceReq() *ListWorkspaceReq

type ListWorkspaceResp

type ListWorkspaceResp struct {
	TotalCount int          `json:"total_count"`
	Workspaces []*Workspace `json:"workspaces"`
	// contains filtered or unexported fields
}

ListWorkspaceResp represents the response for listing workspaces

func (*ListWorkspaceResp) LogID

func (r *ListWorkspaceResp) LogID() string

func (*ListWorkspaceResp) Response

func (r *ListWorkspaceResp) Response() HTTPResponse

type LiveInfo

type LiveInfo struct {
	AppID       string        `json:"app_id"`
	StreamInfos []*StreamInfo `json:"stream_infos"`
	// contains filtered or unexported fields
}

LiveInfo represents information about a live session

func (*LiveInfo) LogID

func (r *LiveInfo) LogID() string

func (*LiveInfo) Response

func (r *LiveInfo) Response() HTTPResponse

type LiveType

type LiveType string

LiveType represents the type of live stream

const (
	LiveTypeOrigin      LiveType = "origin"
	LiveTypeTranslation LiveType = "translation"
)

func (LiveType) Ptr

func (l LiveType) Ptr() *LiveType

func (LiveType) String

func (l LiveType) String() string

type LogLevel

type LogLevel int
const (
	LogLevelTrace LogLevel = iota + 1
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
)

LogLevelTrace ...

func (LogLevel) String

func (r LogLevel) String() string

String ...

type Logger

type Logger interface {
	Log(ctx context.Context, level LogLevel, message string, args ...interface{})
}

Logger ...

type Message

type Message struct {
	// The entity that sent this message.
	Role MessageRole `json:"role"`

	// The type of message.
	Type MessageType `json:"type"`

	// The content of the message. It supports various types of content, including plain text,
	// multimodal (a mix of text, images, and files), message cards, and more.
	Content string `json:"content"`

	// The reasoning_content of the thought process message
	ReasoningContent string `json:"reasoning_content"`

	// The type of message content.
	ContentType MessageContentType `json:"content_type"`

	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages. Custom key-value pairs should be specified in Map object
	// format, with a length of 16 key-value pairs. The length of the key should be between 1 and 64
	// characters, and the length of the value should be between 1 and 512 characters.
	MetaData map[string]string `json:"meta_data,omitempty"`

	ID             string `json:"id"`
	ConversationID string `json:"conversation_id"`

	// section_id is used to distinguish the context sections of the session history. The same section
	// is one context.
	SectionID string `json:"section_id"`
	BotID     string `json:"bot_id"`
	ChatID    string `json:"chat_id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
}

Message represents a message in conversation

func BuildAssistantAnswer

func BuildAssistantAnswer(content string, metaData map[string]string) *Message

BuildAssistantAnswer builds an answer message from assistant

func BuildUserQuestionObjects

func BuildUserQuestionObjects(objects []*MessageObjectString, metaData map[string]string) *Message

BuildUserQuestionObjects builds an object message for user question

func BuildUserQuestionText

func BuildUserQuestionText(content string, metaData map[string]string) *Message

BuildUserQuestionText builds a text message for user question

type MessageContentType

type MessageContentType string

MessageContentType represents the type of message content

const (
	// MessageContentTypeText Text.
	MessageContentTypeText MessageContentType = "text"

	// MessageContentTypeObjectString Multimodal content, that is, a combination of text and files,
	// or a combination of text and images.
	MessageContentTypeObjectString MessageContentType = "object_string"

	// MessageContentTypeCard This enum value only appears in the interface response and is not supported as an
	// input parameter.
	MessageContentTypeCard MessageContentType = "card"

	// MessageContentTypeAudio If there is a audioVoices message in the input message,
	// the conversation.audio.delta event will be returned in the streaming response event.
	MessageContentTypeAudio MessageContentType = "audio"
)

type MessageObjectString

type MessageObjectString struct {
	// The content type of the multimodal message.
	Type MessageObjectStringType `json:"type"`

	// Text content. Required when type is text.
	Text string `json:"text,omitempty"`

	// The ID of the file or image content.
	FileID string `json:"file_id,omitempty"`

	// The online address of the file or image content. Must be a valid address that is publicly
	// accessible. file_id or file_url must be specified when type is file or image.
	FileURL string `json:"file_url,omitempty"`
}

MessageObjectString represents a multimodal message object

func NewAudioMessageObjectByID

func NewAudioMessageObjectByID(fileID string) *MessageObjectString

func NewAudioMessageObjectByURL

func NewAudioMessageObjectByURL(fileURL string) *MessageObjectString

func NewFileMessageObjectByID

func NewFileMessageObjectByID(fileID string) *MessageObjectString

func NewFileMessageObjectByURL

func NewFileMessageObjectByURL(fileURL string) *MessageObjectString

func NewImageMessageObjectByID

func NewImageMessageObjectByID(fileID string) *MessageObjectString

func NewImageMessageObjectByURL

func NewImageMessageObjectByURL(fileURL string) *MessageObjectString

func NewTextMessageObject

func NewTextMessageObject(text string) *MessageObjectString

NewTextMessageObject Helper functions for creating MessageObjectString

type MessageObjectStringType

type MessageObjectStringType string

MessageObjectStringType represents the type of multimodal message content

const (
	MessageObjectStringTypeText  MessageObjectStringType = "text"
	MessageObjectStringTypeFile  MessageObjectStringType = "file"
	MessageObjectStringTypeImage MessageObjectStringType = "image"
	MessageObjectStringTypeAudio MessageObjectStringType = "audio"
)

type MessageRole

type MessageRole string

MessageRole represents the role of message sender

const (
	MessageRoleUnknown MessageRole = "unknown"
	// MessageRoleUser Indicates that the content of the message is sent by the user.
	MessageRoleUser MessageRole = "user"
	// MessageRoleAssistant Indicates that the content of the message is sent by the bot.
	MessageRoleAssistant MessageRole = "assistant"
)

func (MessageRole) String

func (m MessageRole) String() string

type MessageType

type MessageType string

MessageType represents the type of message

const (
	// MessageTypeQuestion User input content.
	MessageTypeQuestion MessageType = "question"

	// MessageTypeAnswer The message content returned by the Bot to the user, supporting incremental return.
	MessageTypeAnswer MessageType = "answer"

	// MessageTypeFunctionCall Intermediate results of the function (function call) called during the
	// Bot conversation process.
	MessageTypeFunctionCall MessageType = "function_call"

	// MessageTypeToolOutput Results returned after calling the tool (function call).
	MessageTypeToolOutput MessageType = "tool_output"

	// MessageTypeToolResponse Results returned after calling the tool (function call).
	MessageTypeToolResponse MessageType = "tool_response"

	// MessageTypeFollowUp If the user question suggestion switch is turned on in the Bot configuration,
	// the reply content related to the recommended questions will be returned.
	MessageTypeFollowUp MessageType = "follow_up"

	MessageTypeUnknown MessageType = ""
)

type NewJWTOAuthClientParam

type NewJWTOAuthClientParam struct {
	ClientID      string
	PublicKey     string
	PrivateKeyPEM string
	TTL           *int
}

type NopEvent

type NopEvent struct{}

type NumberPaged

type NumberPaged[T any] interface {
	BasePaged[T]
	Total() int
}

func NewNumberPaged

func NewNumberPaged[T any](fetcher PageFetcher[T], pageSize, pageNum int) (NumberPaged[T], error)

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

OAuthClient represents the base OAuth core structure

type OAuthClientOption

type OAuthClientOption func(*oauthOption)

func WithAuthBaseURL

func WithAuthBaseURL(baseURL string) OAuthClientOption

WithAuthBaseURL adds base URL

func WithAuthHttpClient

func WithAuthHttpClient(client HTTPClient) OAuthClientOption

func WithAuthWWWURL

func WithAuthWWWURL(wwwURL string) OAuthClientOption

WithAuthWWWURL adds base URL

type OAuthConfig

type OAuthConfig struct {
	ClientID     string `json:"client_id"`
	ClientType   string `json:"client_type"`
	ClientSecret string `json:"client_secret,omitempty"`
	PrivateKey   string `json:"private_key,omitempty"`
	PublicKeyID  string `json:"public_key_id,omitempty"`
	CozeAPIBase  string `json:"coze_api_base,omitempty"`
	CozeWWWBase  string `json:"coze_www_base,omitempty"`
}

OAuthConfig represents the configuration for OAuth clients

type OAuthToken

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token,omitempty"`
	// contains filtered or unexported fields
}

OAuthToken represents the OAuth token response

func (*OAuthToken) LogID

func (r *OAuthToken) LogID() string

func (*OAuthToken) Response

func (r *OAuthToken) Response() HTTPResponse

type PKCEOAuthClient

type PKCEOAuthClient struct {
	*OAuthClient
}

PKCEOAuthClient PKCE OAuth core

func NewPKCEOAuthClient

func NewPKCEOAuthClient(clientID string, opts ...OAuthClientOption) (*PKCEOAuthClient, error)

NewPKCEOAuthClient creates a new PKCE OAuth core

func (*PKCEOAuthClient) GetAccessToken

func (c *PKCEOAuthClient) GetAccessToken(ctx context.Context, req *GetPKCEAccessTokenReq) (*OAuthToken, error)

func (*PKCEOAuthClient) GetOAuthURL

GetOAuthURL generates OAuth URL

func (*PKCEOAuthClient) RefreshToken

func (c *PKCEOAuthClient) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error)

RefreshToken refreshes the access token

type PageFetcher

type PageFetcher[T any] func(request *pageRequest) (*pageResponse[T], error)

PageFetcher interface

type ProcessDocumentsReq

type ProcessDocumentsReq struct {
	DatasetID   string   `path:"dataset_id" json:"-"`
	DocumentIDs []string `json:"document_ids"`
}

ProcessDocumentsReq 表示处理文档的请求

type ProcessDocumentsResp

type ProcessDocumentsResp struct {
	Data []*DocumentProgress `json:"data"`
	// contains filtered or unexported fields
}

func (*ProcessDocumentsResp) LogID

func (r *ProcessDocumentsResp) LogID() string

func (*ProcessDocumentsResp) Response

func (r *ProcessDocumentsResp) Response() HTTPResponse

type ProductCategory

type ProductCategory struct {
	ID   string `json:"id,omitempty"`   // 插件分类 ID。
	Name string `json:"name,omitempty"` // 插件分类名称。
}

type ProductMetaInfo

type ProductMetaInfo struct {
	Name        string           `json:"name,omitempty"`        // 插件的名称。
	Description string           `json:"description,omitempty"` // 插件的描述信息,用于说明插件的功能、用途和特点。
	Category    *ProductCategory `json:"category,omitempty"`    // 插件所属的分类信息,包含分类 ID 和分类名称。
	IconURL     string           `json:"icon_url,omitempty"`    // 插件的图标 URL。
	EntityType  string           `json:"entity_type,omitempty"` // 实体类型,当前仅支持 plugin,表示插件。
	EntityID    string           `json:"entity_id,omitempty"`   // 插件 ID。
	ListedAt    int64            `json:"listed_at,omitempty"`   // 插件上架时间,以 Unix 时间戳格式表示,单位为秒。
	PaidType    string           `json:"paid_type,omitempty"`   // 插件的付费类型,固定为 paid,即付费插件。
	ProductID   string           `json:"product_id,omitempty"`  // 商品的 ID,用于在插件商店中唯一标识该插件商品。
	IsOfficial  bool             `json:"is_official,omitempty"` // 标识插件是否为官方发布。
}

type ProductPlugin

type ProductPlugin struct {
	Metainfo   *ProductMetaInfo   `json:"metainfo,omitempty"`
	PluginInfo *ProductPluginInfo `json:"plugin_info,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductPlugin) LogID

func (r *ProductPlugin) LogID() string

func (*ProductPlugin) Response

func (r *ProductPlugin) Response() HTTPResponse

type ProductPluginInfo

type ProductPluginInfo struct {
	Heat                   int64   `json:"heat,omitempty"`                      // 插件的热度值,用于表示该插件的受欢迎程度或使用频率。数值越大表示热度越高。
	CallCount              int64   `json:"call_count,omitempty"`                // 插件的调用量,表示该插件的累计调用次数。
	Description            string  `json:"description,omitempty"`               // 插件的描述信息,用于说明插件的功能、用途和特点。
	SuccessRate            float64 `json:"success_rate,omitempty"`              // 插件的调用成功率,以小数形式表示,数值范围为 0 到 1。
	BotsUseCount           int64   `json:"bots_use_count,omitempty"`            // 该插件在智能体或工作流中的累计关联次数。
	FavoriteCount          int64   `json:"favorite_count,omitempty"`            // 插件的收藏量,表示该插件被用户收藏的总次数。
	IsCallAvailable        bool    `json:"is_call_available,omitempty"`         // 标识该插件当前是否可被调用。
	TotalToolsCount        int64   `json:"total_tools_count,omitempty"`         // 插件包含的工具总数。
	AvgExecDurationMs      float64 `json:"avg_exec_duration_ms,omitempty"`      // 插件执行的平均耗时,单位为毫秒。
	AssociatedBotsUseCount int64   `json:"associated_bots_use_count,omitempty"` // 当前扣子商店中关联了该插件的智能体数量。
}

type PublishBotsReq

type PublishBotsReq struct {
	BotID        string   `json:"bot_id"`        // Bot ID
	ConnectorIDs []string `json:"connector_ids"` // Connector ID list
}

PublishBotsReq represents the request structure for publishing a bot

type PublishBotsResp

type PublishBotsResp struct {
	BotID      string `json:"bot_id"`
	BotVersion string `json:"version"`
	// contains filtered or unexported fields
}

func (*PublishBotsResp) LogID

func (r *PublishBotsResp) LogID() string

func (*PublishBotsResp) Response

func (r *PublishBotsResp) Response() HTTPResponse

type PublishStatus

type PublishStatus string
const (
	// PublishStatusALL 所有智能体,且数据为最新草稿版本
	PublishStatusALL PublishStatus = "all"
	// PublishStatusPublishedOnline 已发布智能体的最新线上版本
	PublishStatusPublishedOnline PublishStatus = "published_online"
	// PublishStatusPublishedDraft 已发布的最新草稿版本
	PublishStatusPublishedDraft PublishStatus = "published_draft"
	// PublishStatusUnpublishedDraft 未发布的最新草稿版本
	PublishStatusUnpublishedDraft PublishStatus = "unpublished_draft"
)

type RawRequestReq

type RawRequestReq struct {
	Method      string      // http request method, such as GET, POST
	URL         string      // http request url
	Body        interface{} // http request body, query, path and other parameter information
	IsFile      bool        // send body data as a file
	NoNeedToken bool
	Headers     map[string]string
	// contains filtered or unexported fields
}

RawRequestReq ...

type Responser

type Responser interface {
	Response() HTTPResponse
}

type ResumeRunWorkflowsReq

type ResumeRunWorkflowsReq struct {
	// The ID of the workflow, which should have been published.
	WorkflowID string `json:"workflow_id"`

	// Event ID
	EventID string `json:"event_id"`

	// Resume data
	ResumeData string `json:"resume_data"`

	// Interrupt type
	InterruptType int `json:"interrupt_type"`
}

ResumeRunWorkflowsReq represents request for resuming workflow runs

type RetrieveAudioLiveReq

type RetrieveAudioLiveReq struct {
	LiveID string `path:"live_id" json:"-"`
}

RetrieveAudioLiveReq represents the request for retrieving live information

type RetrieveBotsReq

type RetrieveBotsReq struct {
	BotID         string `query:"bot_id" json:"-"` // Bot ID
	IsPublished   *bool  `json:"is_published,omitempty"`
	UseAPIVersion int    `json:"-"`
}

RetrieveBotsReq represents the request structure for retrieving a bot

type RetrieveBotsResp

type RetrieveBotsResp struct {
	Bot
	// contains filtered or unexported fields
}

func (*RetrieveBotsResp) LogID

func (r *RetrieveBotsResp) LogID() string

func (*RetrieveBotsResp) Response

func (r *RetrieveBotsResp) Response() HTTPResponse

type RetrieveChatsReq

type RetrieveChatsReq struct {
	// The Conversation ID can be viewed in the 'conversation_id' field of the Response when
	// initiating a conversation through the Chat API.
	ConversationID string `query:"conversation_id" json:"-"`

	// The Chat ID can be viewed in the 'id' field of the Response when initiating a chat through the
	// Chat API. If it is a streaming response, check the 'id' field in the chat event of the Response.
	ChatID string `query:"chat_id" json:"-"`
}

RetrieveChatsReq represents the request to retrieve a chat

type RetrieveChatsResp

type RetrieveChatsResp struct {
	Chat
	// contains filtered or unexported fields
}

func (*RetrieveChatsResp) LogID

func (r *RetrieveChatsResp) LogID() string

func (*RetrieveChatsResp) Response

func (r *RetrieveChatsResp) Response() HTTPResponse

type RetrieveConversationsMessagesReq

type RetrieveConversationsMessagesReq struct {
	ConversationID string `query:"conversation_id" json:"-"`
	MessageID      string `query:"message_id" json:"-"`
}

RetrieveConversationsMessagesReq represents request for retrieving message

type RetrieveConversationsMessagesResp

type RetrieveConversationsMessagesResp struct {
	Message
	// contains filtered or unexported fields
}

RetrieveConversationsMessagesResp represents response for creating message

func (*RetrieveConversationsMessagesResp) LogID

func (r *RetrieveConversationsMessagesResp) LogID() string

func (*RetrieveConversationsMessagesResp) Response

func (r *RetrieveConversationsMessagesResp) Response() HTTPResponse

type RetrieveConversationsReq

type RetrieveConversationsReq struct {
	// The ID of the conversation.
	ConversationID string `query:"conversation_id" json:"-"`
}

RetrieveConversationsReq represents request for retrieving conversation

type RetrieveConversationsResp

type RetrieveConversationsResp struct {
	Conversation
	// contains filtered or unexported fields
}

func (*RetrieveConversationsResp) LogID

func (r *RetrieveConversationsResp) LogID() string

func (*RetrieveConversationsResp) Response

func (r *RetrieveConversationsResp) Response() HTTPResponse

type RetrieveFilesReq

type RetrieveFilesReq struct {
	FileID string `query:"file_id" json:"-"`
}

RetrieveFilesReq represents request for retrieving file

type RetrieveFilesResp

type RetrieveFilesResp struct {
	FileInfo
	// contains filtered or unexported fields
}

RetrieveFilesResp represents response for retrieving file

func (*RetrieveFilesResp) LogID

func (r *RetrieveFilesResp) LogID() string

func (*RetrieveFilesResp) Response

func (r *RetrieveFilesResp) Response() HTTPResponse

type RetrieveFolderReq

type RetrieveFolderReq struct {
	FolderID string `path:"folder_id" json:"-"`
}

type RetrieveVariablesReq

type RetrieveVariablesReq struct {
	ConnectorUID string   `query:"connector_uid" json:"-"`    // Required: Unique identifier for the connector
	Keywords     []string `query:"keywords" sep:"," json:"-"` // Required: List of variable keywords to retrieve
	AppID        *string  `query:"app_id" json:"-"`           // Optional: Application ID filter
	BotID        *string  `query:"bot_id" json:"-"`           // Optional: Bot ID filter
	ConnectorID  *string  `query:"connector_id" json:"-"`     // Optional: Connector ID filter
}

RetrieveVariablesReq represents the parameters for retrieving variables.

type RetrieveVariablesResp

type RetrieveVariablesResp struct {
	Items []*VariableValue `json:"items"`
	// contains filtered or unexported fields
}

func (*RetrieveVariablesResp) LogID

func (r *RetrieveVariablesResp) LogID() string

func (*RetrieveVariablesResp) Response

func (r *RetrieveVariablesResp) Response() HTTPResponse

type RetrieveWorkflowRunsHistoriesExecuteNodesResp

type RetrieveWorkflowRunsHistoriesExecuteNodesResp struct {

	// The node is finished.
	IsFinish bool `json:"is_finish"`
	// The node output.
	NodeOutput string `json:"node_output"`
	// contains filtered or unexported fields
}

RetrieveWorkflowRunsHistoriesExecuteNodesResp allows you to retrieve the output of a node execution

func (*RetrieveWorkflowRunsHistoriesExecuteNodesResp) LogID

func (r *RetrieveWorkflowRunsHistoriesExecuteNodesResp) LogID() string

func (*RetrieveWorkflowRunsHistoriesExecuteNodesResp) Response

func (r *RetrieveWorkflowRunsHistoriesExecuteNodesResp) Response() HTTPResponse

type RetrieveWorkflowRunsHistoriesResp

type RetrieveWorkflowRunsHistoriesResp struct {
	Histories []*WorkflowRunHistory `json:"data"`
	// contains filtered or unexported fields
}

RetrieveWorkflowRunsHistoriesResp represents response for retrieving workflow runs history

func (*RetrieveWorkflowRunsHistoriesResp) LogID

func (r *RetrieveWorkflowRunsHistoriesResp) LogID() string

func (*RetrieveWorkflowRunsHistoriesResp) Response

func (r *RetrieveWorkflowRunsHistoriesResp) Response() HTTPResponse

type RetrieveWorkflowsRunsHistoriesExecuteNodesReq

type RetrieveWorkflowsRunsHistoriesExecuteNodesReq struct {
	// The ID of the workflow async execute.
	WorkflowID string `path:"workflow_id" json:"-"`

	// The ID of the workflow.
	ExecuteID string `path:"execute_id" json:"-"`

	// The ID of the node execute.
	NodeExecuteUUID string `path:"node_execute_uuid" json:"-"`
}

RetrieveWorkflowsRunsHistoriesExecuteNodesReq query output node execution result

type RetrieveWorkflowsRunsHistoriesReq

type RetrieveWorkflowsRunsHistoriesReq struct {
	// The ID of the workflow.
	ExecuteID string `path:"execute_id" json:"-"`

	// The ID of the workflow async execute.
	WorkflowID string `path:"workflow_id" json:"-"`
}

RetrieveWorkflowsRunsHistoriesReq represents request for retrieving workflow runs history

type RoomAudioConfig

type RoomAudioConfig struct {
	Codec AudioCodec `json:"codec"`
}

RoomAudioConfig represents the room audio configuration

type RoomConfig

type RoomConfig struct {
	AudioConfig     *RoomAudioConfig `json:"audio_config,omitempty"`
	VideoConfig     *RoomVideoConfig `json:"video_config,omitempty"`
	PrologueContent string           `json:"prologue_content,omitempty"`
	// 在进房后等待多长时间播放开场白,默认是500ms,[0, 5000]
	PrologueDelayDurationMs *int `json:"prologue_delay_duration_ms,omitempty"`
}

RoomConfig represents the room configuration

type RoomVideoConfig

type RoomVideoConfig struct {
	// 房间视频编码格式
	Codec VideoCodec `json:"codec,omitempty"`
	// 房间视频流类型
	StreamVideoType StreamVideoType `json:"stream_video_type,omitempty"`
	// 视频抽帧速率
	VideoFrameRate *int `json:"video_frame_rate,omitempty"`
	// 视频帧过期时间, 单位为 s
	VideoFrameExpireDuration *int `json:"video_frame_expire_duration,omitempty"`
}

RoomVideoConfig represents the room video configuration

type RunWorkflowsReq

type RunWorkflowsReq struct {
	// The ID of the workflow, which should have been published.
	WorkflowID string `json:"workflow_id"`

	// Input parameters and their values for the starting node of the workflow.
	Parameters map[string]any `json:"parameters,omitempty"`

	// The associated Bot ID required for some workflow executions.
	BotID string `json:"bot_id,omitempty"`

	// Used to specify some additional fields.
	Ext map[string]string `json:"ext,omitempty"`

	// Whether to runs asynchronously.
	IsAsync bool `json:"is_async,omitempty"`

	AppID string `json:"app_id,omitempty"`
}

RunWorkflowsReq represents request for running workflow

type RunWorkflowsResp

type RunWorkflowsResp struct {

	// Execution ID of asynchronous execution.
	ExecuteID string `json:"execute_id,omitempty"`

	// Workflow execution result.
	Data string `json:"data,omitempty"`

	DebugURL string `json:"debug_url,omitempty"`
	Token    int    `json:"token,omitempty"`
	Cost     string `json:"cost,omitempty"`

	// Detailed information about Token consumption.
	Usage *ChatUsage `json:"usage,omitempty"`
	// contains filtered or unexported fields
}

RunWorkflowsResp represents response for running workflow

func (*RunWorkflowsResp) LogID

func (r *RunWorkflowsResp) LogID() string

func (*RunWorkflowsResp) Response

func (r *RunWorkflowsResp) Response() HTTPResponse

type Scope

type Scope struct {
	AccountPermission   *ScopeAccountPermission   `json:"account_permission"`
	AttributeConstraint *ScopeAttributeConstraint `json:"attribute_constraint,omitempty"`
	WorkspacePermission *ScopeWorkspacePermission `json:"workspace_permission,omitempty"`
	WorkflowPermission  *ScopeWorkflowPermission  `json:"workflow_permission,omitempty"`
}

Scope represents the OAuth scope

func BuildBotChat

func BuildBotChat(botIDList []string, permissionList []string) *Scope

type ScopeAccountPermission

type ScopeAccountPermission struct {
	PermissionList []string `json:"permission_list"`
}

ScopeAccountPermission represents the account permissions in the scope

type ScopeAttributeConstraint

type ScopeAttributeConstraint struct {
	ConnectorBotChatAttribute *ScopeAttributeConstraintConnectorBotChatAttribute `json:"connector_bot_chat_attribute"`
}

ScopeAttributeConstraint represents the attribute constraints in the scope

type ScopeAttributeConstraintConnectorBotChatAttribute

type ScopeAttributeConstraintConnectorBotChatAttribute struct {
	BotIDList []string `json:"bot_id_list"`
}

ScopeAttributeConstraintConnectorBotChatAttribute represents the bot chat attributes

type ScopeWorkflowPermission

type ScopeWorkflowPermission struct {
	WorkflowIdList []string `json:"workflow_id_list"`
	PermissionList []string `json:"permission_list"`
}

ScopeWorkflowPermission represents the workflow permissions in the scope

type ScopeWorkspacePermission

type ScopeWorkspacePermission struct {
	WorkspaceIdList []string `json:"workspace_id_list"`
	PermissionList  []string `json:"permission_list"`
}

ScopeWorkspacePermission represents the workspace permissions in the scope

type SessionContext

type SessionContext struct {
	DeviceInfo *DeviceInfo `json:"device_info,omitempty"`
}

type SimpleApp

type SimpleApp struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	IconURL     string `json:"icon_url,omitempty"`
	IsPublished bool   `json:"is_published,omitempty"`
	OwnerUserID string `json:"owner_user_id,omitempty"`
	UpdatedAt   int    `json:"updated_at,omitempty"`
	PublishedAt *int   `json:"published_at,omitempty"`
}

type SimpleBot

type SimpleBot struct {
	BotID       string  `json:"bot_id"`
	BotName     string  `json:"bot_name"`
	Description string  `json:"description,omitempty"`
	IconURL     string  `json:"icon_url,omitempty"`
	PublishTime string  `json:"publish_time,omitempty"`
	FolderID    *string `json:"folder_id,omitempty"`
}

SimpleBot represents simplified bot information

type SimpleFolder

type SimpleFolder struct {
	ID             string     `json:"id"`
	Name           string     `json:"name"`
	Description    string     `json:"description"`
	WorkspaceID    string     `json:"workspace_id"`
	CreatorUserID  string     `json:"creator_user_id"`
	FolderType     FolderType `json:"folder_type"`
	ParentFolderID *string    `json:"parent_folder_id,omitempty"`
	ChildrenCount  *int64     `json:"children_count,omitempty"`
	// contains filtered or unexported fields
}

func (*SimpleFolder) LogID

func (r *SimpleFolder) LogID() string

func (*SimpleFolder) Response

func (r *SimpleFolder) Response() HTTPResponse

type Stream

type Stream[T streamable] interface {
	Responser
	Close() error
	Recv() (*T, error)
}

type StreamInfo

type StreamInfo struct {
	StreamID string   `json:"stream_id"`
	Name     string   `json:"name"`
	LiveType LiveType `json:"live_type"`
}

StreamInfo represents information about a stream

type StreamVideoType

type StreamVideoType string

StreamVideoType represents the stream video type

const (
	// StreamVideoTypeMain 主流,包括通过摄像头/麦克风的内部采集机制获取的流,以及通过自定义采集方式获取的流。
	StreamVideoTypeMain StreamVideoType = "main"
	// StreamVideoTypeScreen 屏幕流,用于屏幕共享或屏幕录制的视频流。
	StreamVideoTypeScreen StreamVideoType = "screen"
)

func (StreamVideoType) Ptr

func (StreamVideoType) String

func (r StreamVideoType) String() string

type SubmitToolOutputsChatReq

type SubmitToolOutputsChatReq struct {
	// The Conversation ID can be viewed in the 'conversation_id' field of the Response when
	// initiating a conversation through the Chat API.
	ConversationID string `query:"conversation_id" json:"-"`

	// The Chat ID can be viewed in the 'id' field of the Response when initiating a chat through the
	// Chat API. If it is a streaming response, check the 'id' field in the chat event of the Response.
	ChatID string `query:"chat_id" json:"-"`

	// The execution result of the tool. For detailed instructions, refer to the ToolOutput Object
	ToolOutputs []*ToolOutput `json:"tool_outputs"`

	Stream *bool `json:"stream,omitempty"`

	// Optional: Specify a connector ID. Supports passing in 999 (Chat SDK) and 1024 (API). If not provided, the default is 1024 (API).
	ConnectorID string `json:"connector_id"`
}

SubmitToolOutputsChatReq represents the request to submit tool outputs

type SubmitToolOutputsChatResp

type SubmitToolOutputsChatResp struct {
	Chat
	// contains filtered or unexported fields
}

func (*SubmitToolOutputsChatResp) LogID

func (r *SubmitToolOutputsChatResp) LogID() string

func (*SubmitToolOutputsChatResp) Response

func (r *SubmitToolOutputsChatResp) Response() HTTPResponse

type TemplateDuplicateResp

type TemplateDuplicateResp struct {
	EntityID   string             `json:"entity_id"`
	EntityType TemplateEntityType `json:"entity_type"`
	// contains filtered or unexported fields
}

TemplateDuplicateResp represents the response from duplicating a template

func (*TemplateDuplicateResp) LogID

func (r *TemplateDuplicateResp) LogID() string

func (*TemplateDuplicateResp) Response

func (r *TemplateDuplicateResp) Response() HTTPResponse

type TemplateEntityType

type TemplateEntityType string

TemplateEntityType represents the type of template entity

const (
	// TemplateEntityTypeAgent represents an agent template
	TemplateEntityTypeAgent TemplateEntityType = "agent"
)

type ToolOutput

type ToolOutput struct {
	// The ID for reporting the running results. You can get this ID under the tool_calls field in
	// response of the Chat API.
	ToolCallID string `json:"tool_call_id"`
	// The execution result of the tool.
	Output string `json:"output"`
}

ToolOutput represents the output of a tool

type UpdateBotsReq

type UpdateBotsReq struct {
	BotID           string              `json:"bot_id"`            // Bot ID
	Name            string              `json:"name"`              // Name
	Description     string              `json:"description"`       // Description
	IconFileID      string              `json:"icon_file_id"`      // Icon file ID
	PromptInfo      *BotPromptInfo      `json:"prompt_info"`       // Prompt information
	OnboardingInfo  *BotOnboardingInfo  `json:"onboarding_info"`   // Onboarding information
	Knowledge       *BotKnowledge       `json:"knowledge"`         // Knowledge
	ModelInfoConfig *BotModelInfoConfig `json:"model_info_config"` // ModelInfoConfig information
	WorkflowIDList  *WorkflowIDList     `json:"workflow_id_list"`  // WorkflowIDList information
}

UpdateBotsReq represents the request structure for updating a bot

type UpdateBotsResp

type UpdateBotsResp struct {
	// contains filtered or unexported fields
}

func (*UpdateBotsResp) LogID

func (r *UpdateBotsResp) LogID() string

func (*UpdateBotsResp) Response

func (r *UpdateBotsResp) Response() HTTPResponse

type UpdateConversationMessagesReq

type UpdateConversationMessagesReq struct {
	// The ID of the conversation.
	ConversationID string `query:"conversation_id" json:"-"`

	// The ID of the message.
	MessageID string `query:"message_id" json:"-"`

	// The content of the message, supporting pure text, multimodal (mixed input of text, images, files),
	// cards, and various types of content.
	Content string `json:"content,omitempty"`

	MetaData map[string]string `json:"meta_data,omitempty"`

	// The type of message content.
	ContentType MessageContentType `json:"content_type,omitempty"`
}

UpdateConversationMessagesReq represents request for updating message

type UpdateConversationMessagesResp

type UpdateConversationMessagesResp struct {
	Message
	// contains filtered or unexported fields
}

UpdateConversationMessagesResp represents response for creating message

func (*UpdateConversationMessagesResp) LogID

func (r *UpdateConversationMessagesResp) LogID() string

func (*UpdateConversationMessagesResp) Response

func (r *UpdateConversationMessagesResp) Response() HTTPResponse

type UpdateDatasetImageReq

type UpdateDatasetImageReq struct {
	DatasetID  string  `path:"dataset_id" json:"-"`
	DocumentID string  `path:"document_id" json:"-"`
	Caption    *string `json:"caption"` // 图片描述
}

UpdateDatasetImageReq 表示更新图片的请求

type UpdateDatasetImageResp

type UpdateDatasetImageResp struct {
	// contains filtered or unexported fields
}

func (*UpdateDatasetImageResp) LogID

func (r *UpdateDatasetImageResp) LogID() string

func (*UpdateDatasetImageResp) Response

func (r *UpdateDatasetImageResp) Response() HTTPResponse

type UpdateDatasetsDocumentsReq

type UpdateDatasetsDocumentsReq struct {
	// The ID of the knowledge base file.
	DocumentID int64 `json:"document_id"`

	// The new name of the knowledge base file.
	DocumentName string `json:"document_name,omitempty"`

	// The update strategy for online web pages. Defaults to no automatic updates.
	// For detailed information, refer to the UpdateRule object.
	UpdateRule *DocumentUpdateRule `json:"update_rule,omitempty"`
}

UpdateDatasetsDocumentsReq represents request for updating document

type UpdateDatasetsDocumentsResp

type UpdateDatasetsDocumentsResp struct {
	// contains filtered or unexported fields
}

UpdateDatasetsDocumentsResp represents response for updating document

func (*UpdateDatasetsDocumentsResp) LogID

func (r *UpdateDatasetsDocumentsResp) LogID() string

func (*UpdateDatasetsDocumentsResp) Response

func (r *UpdateDatasetsDocumentsResp) Response() HTTPResponse

type UpdateDatasetsReq

type UpdateDatasetsReq struct {
	DatasetID   string `path:"dataset_id" json:"-"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	IconFileID  string `json:"file_id,omitempty"`
}

UpdateDatasetsReq 表示更新数据集的请求

type UpdateDatasetsResp

type UpdateDatasetsResp struct {
	// contains filtered or unexported fields
}

func (*UpdateDatasetsResp) LogID

func (r *UpdateDatasetsResp) LogID() string

func (*UpdateDatasetsResp) Response

func (r *UpdateDatasetsResp) Response() HTTPResponse

type UpdateEnterpriseMemberReq

type UpdateEnterpriseMemberReq struct {
	EnterpriseID string               `path:"enterprise_id" json:"-"`
	UserID       string               `path:"user_id" json:"-"`
	Role         EnterpriseMemberRole `json:"role"`
}

UpdateEnterpriseMemberReq represents the request to update an enterprise member

type UpdateEnterpriseMemberResp

type UpdateEnterpriseMemberResp struct {
	// contains filtered or unexported fields
}

UpdateEnterpriseMemberResp represents the response from updating an enterprise member

func (*UpdateEnterpriseMemberResp) LogID

func (r *UpdateEnterpriseMemberResp) LogID() string

func (*UpdateEnterpriseMemberResp) Response

func (r *UpdateEnterpriseMemberResp) Response() HTTPResponse

type UpdateVariablesReq

type UpdateVariablesReq struct {
	ConnectorUID string          `json:"connector_uid"`          // Required: Unique identifier for the connector
	Data         []VariableValue `json:"data"`                   // Required: List of variable values to update
	AppID        *string         `json:"app_id,omitempty"`       // Optional: Application ID filter
	BotID        *string         `json:"bot_id,omitempty"`       // Optional: Bot ID filter
	ConnectorID  *string         `json:"connector_id,omitempty"` // Optional: Connector ID filter
}

UpdateVariablesReq represents the request body for updating variables.

type UpdateVariablesResp

type UpdateVariablesResp struct {
	// contains filtered or unexported fields
}

func (*UpdateVariablesResp) LogID

func (r *UpdateVariablesResp) LogID() string

func (*UpdateVariablesResp) Response

func (r *UpdateVariablesResp) Response() HTTPResponse

type UpdateVoicePrintGroupFeatureReq

type UpdateVoicePrintGroupFeatureReq struct {
	GroupID    string     `path:"group_id" json:"-"`
	FeatureID  string     `path:"feature_id" json:"-"`
	Name       *string    `json:"name,omitempty"`
	Desc       *string    `json:"desc,omitempty"`
	File       *FileTypes `json:"file,omitempty"`
	SampleRate *int       `json:"sample_rate,omitempty"`
	Channel    *int       `json:"channel,omitempty"`
}

type UpdateVoicePrintGroupFeatureResp

type UpdateVoicePrintGroupFeatureResp struct {
	// contains filtered or unexported fields
}

func (*UpdateVoicePrintGroupFeatureResp) LogID

func (r *UpdateVoicePrintGroupFeatureResp) LogID() string

func (*UpdateVoicePrintGroupFeatureResp) Response

func (r *UpdateVoicePrintGroupFeatureResp) Response() HTTPResponse

type UpdateVoicePrintGroupReq

type UpdateVoicePrintGroupReq struct {
	GroupID string  `path:"group_id" json:"-"`
	Name    *string `json:"name,omitempty"`
	Desc    *string `json:"desc,omitempty"`
}

type UpdateVoicePrintGroupResp

type UpdateVoicePrintGroupResp struct {
	// contains filtered or unexported fields
}

func (*UpdateVoicePrintGroupResp) LogID

func (r *UpdateVoicePrintGroupResp) LogID() string

func (*UpdateVoicePrintGroupResp) Response

func (r *UpdateVoicePrintGroupResp) Response() HTTPResponse

type UploadFilesReq

type UploadFilesReq struct {
	File FileTypes `json:"file"`
}

type UploadFilesResp

type UploadFilesResp struct {
	FileInfo
	// contains filtered or unexported fields
}

UploadFilesResp represents response for uploading file

func (*UploadFilesResp) LogID

func (r *UploadFilesResp) LogID() string

func (*UploadFilesResp) Response

func (r *UploadFilesResp) Response() HTTPResponse

type User

type User struct {
	UserID    string `json:"user_id"`
	UserName  string `json:"user_name"`
	NickName  string `json:"nick_name"`
	AvatarURL string `json:"avatar_url"`
	// contains filtered or unexported fields
}

User represents a Coze user

func (*User) LogID

func (r *User) LogID() string

func (*User) Response

func (r *User) Response() HTTPResponse

type UserInfo

type UserInfo struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Nickname  string `json:"nickname"`
	AvatarURL string `json:"avatar_url"`
}

type VariableValue

type VariableValue struct {
	Keyword    string `json:"keyword"`
	Value      string `json:"value"`
	UpdateTime int64  `json:"update_time,omitempty"`
	CreateTime int64  `json:"create_time,omitempty"`
}

VariableValue represents a single variable with its keyword and value.

type VideoCodec

type VideoCodec string

VideoCodec represents the video codec

const (
	VideoCodecH264    VideoCodec = "H264"
	VideoCodecBYTEVC1 VideoCodec = "BYTEVC1"
)

func (VideoCodec) Ptr

func (r VideoCodec) Ptr() *VideoCodec

func (VideoCodec) String

func (r VideoCodec) String() string

type Voice

type Voice struct {
	VoiceID                string         `json:"voice_id"`
	Name                   string         `json:"name"`
	IsSystemVoice          bool           `json:"is_system_voice"`
	LanguageCode           string         `json:"language_code"`
	LanguageName           string         `json:"language_name"`
	PreviewText            string         `json:"preview_text"`
	PreviewAudio           string         `json:"preview_audio"`
	AvailableTrainingTimes int            `json:"available_training_times"`
	CreateTime             int            `json:"create_time"`
	UpdateTime             int            `json:"update_time"`
	ModelType              VoiceModelType `json:"model_type"`
	State                  VoiceState     `json:"state"`
}

Voice represents the voice model

type VoiceModelType

type VoiceModelType string
const (
	VoiceModelTypeBig   VoiceModelType = "big"   // 大模型音色
	VoiceModelTypeSmall VoiceModelType = "small" // 小模型音色
)

func (VoiceModelType) Ptr

func (r VoiceModelType) Ptr() *VoiceModelType

func (VoiceModelType) String

func (r VoiceModelType) String() string

type VoicePrintGroup

type VoicePrintGroup struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Desc         string    `json:"desc"`
	CreatedAt    int       `json:"created_at"`
	UpdatedAt    int       `json:"updated_at"`
	IconURL      string    `json:"icon_url"`
	FeatureCount int       `json:"feature_count"`
	UserInfo     *UserInfo `json:"user_info"`
}

type VoicePrintGroupFeature

type VoicePrintGroupFeature struct {
	ID        string    `json:"id"`
	GroupID   string    `json:"group_id"`
	Name      string    `json:"name"`
	AudioURL  string    `json:"audio_url"`
	CreatedAt int       `json:"created_at"`
	UpdatedAt int       `json:"updated_at"`
	Desc      string    `json:"desc"`
	IconURL   string    `json:"icon_url"`
	UserInfo  *UserInfo `json:"user_info"`
}

type VoiceState

type VoiceState string
const (
	VoiceStateInit   VoiceState = "init"   // 初始化
	VoiceStateCloned VoiceState = "cloned" // 已克隆
	VoiceStateAll    VoiceState = "all"    // 所有, 只有查询的时候有效
)

func (VoiceState) Ptr

func (r VoiceState) Ptr() *VoiceState

func (VoiceState) String

func (r VoiceState) String() string

type WebOAuthClient

type WebOAuthClient struct {
	*OAuthClient
}

WebOAuthClient Web OAuth core

func NewWebOAuthClient

func NewWebOAuthClient(clientID, clientSecret string, opts ...OAuthClientOption) (*WebOAuthClient, error)

NewWebOAuthClient creates a new Web OAuth core

func (*WebOAuthClient) GetAccessToken

func (c *WebOAuthClient) GetAccessToken(ctx context.Context, req *GetWebOAuthAccessTokenReq) (*OAuthToken, error)

GetAccessToken gets the access token

func (*WebOAuthClient) GetOAuthURL

func (c *WebOAuthClient) GetOAuthURL(ctx context.Context, req *GetWebOAuthURLReq) string

GetOAuthURL Get OAuth URL

func (*WebOAuthClient) RefreshToken

func (c *WebOAuthClient) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error)

RefreshToken refreshes the access token

type WebSocketASRConfig

type WebSocketASRConfig struct {
	// 请输入热词列表,以便提升这些词汇的识别准确率。所有热词加起来最多100个 Tokens,超出部分将自动截断。
	HotWords []string `json:"hot_words,omitempty"`
	// 请输入上下文信息。最多输入 800 个 Tokens,超出部分将自动截断。
	Context *string `json:"context,omitempty"`
	// 用户说话的语种,默认为 common。选项包括:
	UserLanguage *WebSocketASRConfigUserLanguage `json:"user_language,omitempty"`
	// 将语音转为文本时,是否启用语义顺滑。默认为 true。true:系统在进行语音处理时,会去掉识别结果中诸如 “啊”“嗯” 等语气词,使得输出的文本语义更加流畅自然,符合正常的语言表达习惯,尤其适用于对文本质量要求较高的场景,如正式的会议记录、新闻稿件生成等。false:系统不会对识别结果中的语气词进行处理,识别结果会保留原始的语气词。
	EnableDDC *bool `json:"enable_ddc,omitempty"`
	// 将语音转为文本时,是否开启文本规范化(ITN)处理,将识别结果转换为更符合书面表达习惯的格式以提升可读性。默认为 true。开启后,会将口语化数字转换为标准数字格式,示例:将两点十五分转换为 14:15。将一百美元转换为 $100。
	EnableITN *bool `json:"enable_itn,omitempty"`
	// 将语音转为文本时,是否给文本加上标点符号。默认为 true。
	EnablePunc *bool `json:"enable_punc,omitempty"`
}

type WebSocketASRConfigUserLanguage

type WebSocketASRConfigUserLanguage string
const (
	WebSocketASRConfigUserLanguageCommon WebSocketASRConfigUserLanguage = "common" // 大模型语音识别,可自动识别中英粤。
	WebSocketASRConfigUserLanguageZH     WebSocketASRConfigUserLanguage = "zh"     // 小模型语音识别,中文。
	WebSocketASRConfigUserLanguageCANT   WebSocketASRConfigUserLanguage = "cant"   // 小模型语音识别,粤语。
	WebSocketASRConfigUserLanguageSC     WebSocketASRConfigUserLanguage = "sc"     // 小模型语音识别,川渝。
	WebSocketASRConfigUserLanguageEN     WebSocketASRConfigUserLanguage = "en"     // 小模型语音识别,英语。
	WebSocketASRConfigUserLanguageJA     WebSocketASRConfigUserLanguage = "ja"     // 小模型语音识别,日语。
	WebSocketASRConfigUserLanguageKO     WebSocketASRConfigUserLanguage = "ko"     // 小模型语音识别,韩语。
	WebSocketASRConfigUserLanguageFR     WebSocketASRConfigUserLanguage = "fr"     // 小模型语音识别,法语。
	WebSocketASRConfigUserLanguageID     WebSocketASRConfigUserLanguage = "id"     // 小模型语音识别,印尼语。
	WebSocketASRConfigUserLanguageES     WebSocketASRConfigUserLanguage = "es"     // 小模型语音识别,西班牙语。
	WebSocketASRConfigUserLanguagePT     WebSocketASRConfigUserLanguage = "pt"     // 小模型语音识别,葡萄牙语。
	WebSocketASRConfigUserLanguageMS     WebSocketASRConfigUserLanguage = "ms"     // 小模型语音识别,马来语。
	WebSocketASRConfigUserLanguageRU     WebSocketASRConfigUserLanguage = "ru"     // 小模型语音识别,俄语。
)

type WebSocketAudioLimitConfig

type WebSocketAudioLimitConfig struct {
	// 周期的时长,单位为秒。例如设置为 10 秒,则以 10 秒作为一个周期。
	Period *int `json:"period,omitempty"`
	// 周期内,最大返回包数量。
	MaxFrameNum *int `json:"max_frame_num,omitempty"`
}

WebSocketAudioLimitConfig configures audio limits

type WebSocketAudioSpeech

type WebSocketAudioSpeech struct {
	// contains filtered or unexported fields
}

func (*WebSocketAudioSpeech) Close

func (c *WebSocketAudioSpeech) Close() error

Close closes the WebSocket connection

func (*WebSocketAudioSpeech) Connect

func (c *WebSocketAudioSpeech) Connect() error

Connect establishes the WebSocket connection

func (*WebSocketAudioSpeech) InputTextBufferAppend

func (c *WebSocketAudioSpeech) InputTextBufferAppend(data *WebSocketInputTextBufferAppendEventData) error

InputTextBufferAppend appends text to the input text buffer

func (*WebSocketAudioSpeech) InputTextBufferComplete

func (c *WebSocketAudioSpeech) InputTextBufferComplete(data *WebSocketInputTextBufferCompleteEventData) error

InputTextBufferComplete completes the input text buffer

func (*WebSocketAudioSpeech) IsConnected

func (c *WebSocketAudioSpeech) IsConnected() bool

IsConnected returns whether the client is connected

func (*WebSocketAudioSpeech) OnClientError

func (c *WebSocketAudioSpeech) OnClientError(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketClientErrorEvent) error)

func (*WebSocketAudioSpeech) OnClosed

func (c *WebSocketAudioSpeech) OnClosed(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketClosedEvent) error)

func (*WebSocketAudioSpeech) OnError

func (c *WebSocketAudioSpeech) OnError(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketErrorEvent) error)

func (*WebSocketAudioSpeech) OnEvent

func (c *WebSocketAudioSpeech) OnEvent(eventType WebSocketEventType, handler EventHandler)

OnEvent registers an event handler

func (*WebSocketAudioSpeech) OnInputTextBufferCompleted

func (c *WebSocketAudioSpeech) OnInputTextBufferCompleted(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketInputTextBufferCompletedEvent) error)

func (*WebSocketAudioSpeech) OnSpeechAudioCompleted

func (c *WebSocketAudioSpeech) OnSpeechAudioCompleted(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechAudioCompletedEvent) error)

func (*WebSocketAudioSpeech) OnSpeechAudioUpdate

func (c *WebSocketAudioSpeech) OnSpeechAudioUpdate(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechAudioUpdateEvent) error)

func (*WebSocketAudioSpeech) OnSpeechCreated

func (c *WebSocketAudioSpeech) OnSpeechCreated(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechCreatedEvent) error)

func (*WebSocketAudioSpeech) OnSpeechUpdated

func (c *WebSocketAudioSpeech) OnSpeechUpdated(handler func(ctx context.Context, cli *WebSocketAudioSpeech, event *WebSocketSpeechUpdatedEvent) error)

func (*WebSocketAudioSpeech) RegisterHandler

func (c *WebSocketAudioSpeech) RegisterHandler(h IWebSocketAudioSpeechHandler)

func (*WebSocketAudioSpeech) SpeechUpdate

func (*WebSocketAudioSpeech) Wait

func (c *WebSocketAudioSpeech) Wait(eventTypes ...WebSocketEventType) error

Wait waits for speech audio to complete

type WebSocketAudioTranscription

type WebSocketAudioTranscription struct {
	// contains filtered or unexported fields
}

func (*WebSocketAudioTranscription) Close

Close closes the WebSocket connection

func (*WebSocketAudioTranscription) Connect

func (c *WebSocketAudioTranscription) Connect() error

Connect establishes the WebSocket connection

func (*WebSocketAudioTranscription) InputAudioBufferAppend

func (*WebSocketAudioTranscription) InputAudioBufferClear

func (*WebSocketAudioTranscription) InputAudioBufferComplete

func (*WebSocketAudioTranscription) IsConnected

func (c *WebSocketAudioTranscription) IsConnected() bool

IsConnected returns whether the client is connected

func (*WebSocketAudioTranscription) OnClientError

func (*WebSocketAudioTranscription) OnClosed

func (*WebSocketAudioTranscription) OnError

func (*WebSocketAudioTranscription) OnEvent

func (c *WebSocketAudioTranscription) OnEvent(eventType WebSocketEventType, handler EventHandler)

OnEvent registers an event handler

func (*WebSocketAudioTranscription) OnInputAudioBufferCleared

func (c *WebSocketAudioTranscription) OnInputAudioBufferCleared(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketInputAudioBufferClearedEvent) error)

func (*WebSocketAudioTranscription) OnInputAudioBufferCompleted

func (c *WebSocketAudioTranscription) OnInputAudioBufferCompleted(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketInputAudioBufferCompletedEvent) error)

func (*WebSocketAudioTranscription) OnTranscriptionsCreated

func (c *WebSocketAudioTranscription) OnTranscriptionsCreated(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketTranscriptionsCreatedEvent) error)

func (*WebSocketAudioTranscription) OnTranscriptionsMessageCompleted

func (c *WebSocketAudioTranscription) OnTranscriptionsMessageCompleted(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketTranscriptionsMessageCompletedEvent) error)

func (*WebSocketAudioTranscription) OnTranscriptionsMessageUpdate

func (c *WebSocketAudioTranscription) OnTranscriptionsMessageUpdate(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketTranscriptionsMessageUpdateEvent) error)

func (*WebSocketAudioTranscription) OnTranscriptionsUpdated

func (c *WebSocketAudioTranscription) OnTranscriptionsUpdated(handler func(ctx context.Context, cli *WebSocketAudioTranscription, event *WebSocketTranscriptionsUpdatedEvent) error)

func (*WebSocketAudioTranscription) RegisterHandler

func (*WebSocketAudioTranscription) TranscriptionsUpdate

func (*WebSocketAudioTranscription) Wait

func (c *WebSocketAudioTranscription) Wait(eventTypes ...WebSocketEventType) error

Wait waits for transcription to complete

type WebSocketChat

type WebSocketChat struct {
	// contains filtered or unexported fields
}

func (*WebSocketChat) ChatUpdate

func (c *WebSocketChat) ChatUpdate(data *WebSocketChatUpdateEventData) error

func (*WebSocketChat) Close

func (c *WebSocketChat) Close() error

Close closes the WebSocket connection

func (*WebSocketChat) Connect

func (c *WebSocketChat) Connect() error

Connect establishes the WebSocket connection

func (*WebSocketChat) ConversationChatCancel

func (c *WebSocketChat) ConversationChatCancel(data *WebSocketConversationChatCancelEventData) error

func (*WebSocketChat) ConversationChatSubmitToolOutputs

func (c *WebSocketChat) ConversationChatSubmitToolOutputs(data *WebSocketConversationChatSubmitToolOutputsEventData) error

func (*WebSocketChat) ConversationClear

func (c *WebSocketChat) ConversationClear(data *WebSocketConversationClearEventData) error

func (*WebSocketChat) ConversationMessageCreate

func (c *WebSocketChat) ConversationMessageCreate(data *WebSocketConversationMessageCreateEventData) error

func (*WebSocketChat) InputAudioBufferAppend

func (c *WebSocketChat) InputAudioBufferAppend(data *WebSocketInputAudioBufferAppendEventData) error

func (*WebSocketChat) InputAudioBufferClear

func (c *WebSocketChat) InputAudioBufferClear(data *WebSocketInputAudioBufferClearEventData) error

func (*WebSocketChat) InputAudioBufferComplete

func (c *WebSocketChat) InputAudioBufferComplete(data *WebSocketInputAudioBufferCompleteEventData) error

func (*WebSocketChat) InputTextGenerateAudio

func (c *WebSocketChat) InputTextGenerateAudio(data *WebSocketInputTextGenerateAudioEventData) error

func (*WebSocketChat) IsConnected

func (c *WebSocketChat) IsConnected() bool

IsConnected returns whether the client is connected

func (*WebSocketChat) OnChatCreated

func (c *WebSocketChat) OnChatCreated(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketChatCreatedEvent) error)

func (*WebSocketChat) OnChatUpdated

func (c *WebSocketChat) OnChatUpdated(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketChatUpdatedEvent) error)

func (*WebSocketChat) OnClientError

func (c *WebSocketChat) OnClientError(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketClientErrorEvent) error)

func (*WebSocketChat) OnClosed

func (c *WebSocketChat) OnClosed(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketClosedEvent) error)

func (*WebSocketChat) OnConversationAudioCompleted

func (c *WebSocketChat) OnConversationAudioCompleted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioCompletedEvent) error)

func (*WebSocketChat) OnConversationAudioDelta

func (c *WebSocketChat) OnConversationAudioDelta(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioDeltaEvent) error)

func (*WebSocketChat) OnConversationAudioSentenceStart

func (c *WebSocketChat) OnConversationAudioSentenceStart(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioSentenceStartEvent) error)

func (*WebSocketChat) OnConversationAudioTranscriptCompleted

func (c *WebSocketChat) OnConversationAudioTranscriptCompleted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptCompletedEvent) error)

func (*WebSocketChat) OnConversationAudioTranscriptUpdate

func (c *WebSocketChat) OnConversationAudioTranscriptUpdate(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationAudioTranscriptUpdateEvent) error)

func (*WebSocketChat) OnConversationChatCanceled

func (c *WebSocketChat) OnConversationChatCanceled(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCanceledEvent) error)

func (*WebSocketChat) OnConversationChatCompleted

func (c *WebSocketChat) OnConversationChatCompleted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCompletedEvent) error)

func (*WebSocketChat) OnConversationChatCreated

func (c *WebSocketChat) OnConversationChatCreated(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatCreatedEvent) error)

func (*WebSocketChat) OnConversationChatFailed

func (c *WebSocketChat) OnConversationChatFailed(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatFailedEvent) error)

func (*WebSocketChat) OnConversationChatInProgress

func (c *WebSocketChat) OnConversationChatInProgress(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatInProgressEvent) error)

func (*WebSocketChat) OnConversationChatRequiresAction

func (c *WebSocketChat) OnConversationChatRequiresAction(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationChatRequiresActionEvent) error)

func (*WebSocketChat) OnConversationCleared

func (c *WebSocketChat) OnConversationCleared(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationClearedEvent) error)

func (*WebSocketChat) OnConversationMessageCompleted

func (c *WebSocketChat) OnConversationMessageCompleted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationMessageCompletedEvent) error)

func (*WebSocketChat) OnConversationMessageDelta

func (c *WebSocketChat) OnConversationMessageDelta(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketConversationMessageDeltaEvent) error)

func (*WebSocketChat) OnError

func (c *WebSocketChat) OnError(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketErrorEvent) error)

func (*WebSocketChat) OnEvent

func (c *WebSocketChat) OnEvent(eventType WebSocketEventType, handler EventHandler)

OnEvent registers an event handler

func (*WebSocketChat) OnInputAudioBufferCleared

func (c *WebSocketChat) OnInputAudioBufferCleared(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferClearedEvent) error)

func (*WebSocketChat) OnInputAudioBufferCompleted

func (c *WebSocketChat) OnInputAudioBufferCompleted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferCompletedEvent) error)

func (*WebSocketChat) OnInputAudioBufferSpeechStarted

func (c *WebSocketChat) OnInputAudioBufferSpeechStarted(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferSpeechStartedEvent) error)

func (*WebSocketChat) OnInputAudioBufferSpeechStopped

func (c *WebSocketChat) OnInputAudioBufferSpeechStopped(handler func(ctx context.Context, cli *WebSocketChat, event *WebSocketInputAudioBufferSpeechStoppedEvent) error)

func (*WebSocketChat) RegisterHandler

func (c *WebSocketChat) RegisterHandler(h IWebSocketChatHandler)

RegisterHandler registers all handlers with the client

func (*WebSocketChat) Wait

func (c *WebSocketChat) Wait(eventTypes ...WebSocketEventType) error

Wait waits for chat to complete

type WebSocketChatConfig

type WebSocketChatConfig struct {
	// 标识对话发生在哪一次会话中。会话是智能体和用户之间的一段问答交互。一个会话包含一条或多条消息。对话是会话中对智能体的一次调用,智能体会将对话中产生的消息添加到会话中。可以使用已创建的会话,会话中已存在的消息将作为上下文传递给模型。创建会话的方式可参考创建会话。对于一问一答等不需要区分 conversation 的场合可不传该参数,系统会自动生成一个会话。不传的话会默认创建一个新的 conversation。
	ConversationID *string `json:"conversation_id,omitempty"`
	// 标识当前与智能体的用户,由使用方自行定义、生成与维护。user_id 用于标识对话中的不同用户,不同的 user_id,其对话的上下文消息、数据库等对话记忆数据互相隔离。如果不需要用户数据隔离,可将此参数固定为一个任意字符串,例如 123,abc 等。
	UserID *string `json:"user_id,omitempty"`
	// 附加信息,通常用于封装一些业务相关的字段。查看对话消息详情时,系统会透传此附加信息。自定义键值对,应指定为 Map 对象格式。长度为 16 对键值对,其中键(key)的长度范围为 1~64 个字符,值(value)的长度范围为 1~512 个字符。
	MetaData map[string]string `json:"meta_data,omitempty"`
	// 智能体中定义的变量。在智能体 prompt 中设置变量 {{key}} 后,可以通过该参数传入变量值,同时支持 Jinja2 语法。详细说明可参考变量示例。变量名只支持英文字母和下划线。
	CustomVariables map[string]string `json:"custom_variables,omitempty"`
	// 附加参数,通常用于特殊场景下指定一些必要参数供模型判断,例如指定经纬度,并询问智能体此位置的天气。自定义键值对格式,其中键(key)仅支持设置为:latitude(纬度,此时值(Value)为纬度值,例如 39.9800718)。longitude(经度,此时值(Value)为经度值,例如 116.309314)。
	ExtraParams map[string]string `json:"extra_params,omitempty"`
	// 是否保存本次对话记录。true:(默认)会话中保存本次对话记录,包括本次对话的模型回复结果、模型执行中间结果。false:会话中不保存本次对话记录,后续也无法通过任何方式查看本次对话信息、消息详情。在同一个会话中再次发起对话时,本次会话也不会作为上下文传递给模型。
	AutoSaveHistory *bool `json:"auto_save_history,omitempty"`
	// 设置对话流的自定义输入参数的值,具体用法和示例代码可参考[为自定义参数赋值](https://www.coze.cn/open/docs/tutorial/variable)。 对话流的输入参数 USER_INPUT 应在 additional_messages 中传入,在 parameters 中的 USER_INPUT 不生效。 如果 parameters 中未指定 CONVERSATION_NAME 或其他输入参数,则使用参数默认值运行对话流;如果指定了这些参数,则使用指定值。
	Parameters map[string]any `json:"parameters,omitempty"`
}

type WebSocketChatCreatedEvent

type WebSocketChatCreatedEvent struct {
	// contains filtered or unexported fields
}

WebSocketChatCreatedEvent 对话连接成功

流式对话接口成功建立连接后服务端会发送此事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#a061f115 seq:v1/chat:resp:1

func (WebSocketChatCreatedEvent) GetDetail

func (r WebSocketChatCreatedEvent) GetDetail() *EventDetail

func (WebSocketChatCreatedEvent) GetEventType

func (r WebSocketChatCreatedEvent) GetEventType() WebSocketEventType

func (WebSocketChatCreatedEvent) GetID

func (r WebSocketChatCreatedEvent) GetID() string

type WebSocketChatUpdateEvent

type WebSocketChatUpdateEvent struct {
	Data *WebSocketChatUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketChatUpdateEvent 更新对话配置

此事件可以更新当前对话连接的配置项,若更新成功,会收到 chat.updated 的下行事件,否则,会收到 error 下行事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#91642fa8 seq:v1/chat:req:1

func (WebSocketChatUpdateEvent) GetDetail

func (r WebSocketChatUpdateEvent) GetDetail() *EventDetail

func (WebSocketChatUpdateEvent) GetEventType

func (r WebSocketChatUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketChatUpdateEvent) GetID

func (r WebSocketChatUpdateEvent) GetID() string

type WebSocketChatUpdateEventData

type WebSocketChatUpdateEventData struct {
	// 输出音频格式。
	OutputAudio *WebSocketOutputAudio `json:"output_audio,omitempty"`
	// 输入音频格式。
	InputAudio *WebSocketInputAudio `json:"input_audio,omitempty"`
	// 对话配置。
	ChatConfig *WebSocketChatConfig `json:"chat_config,omitempty"`
	// 需要订阅下行事件的事件类型列表。不设置或者设置为空为订阅所有下行事件。
	EventSubscriptions []string `json:"event_subscriptions,omitempty"`
	// 是否需要播放开场白,默认为 false。
	NeedPlayPrologue *bool `json:"need_play_prologue,omitempty"`
	// 自定义开场白,need_play_prologue 设置为 true 时生效。如果不设定自定义开场白则使用智能体上设置的开场白。
	PrologueContent string `json:"prologue_content,omitempty"`
	// 转检测配置。
	TurnDetection *WebSocketTurnDetection `json:"turn_detection,omitempty"`
	// 语音识别配置,包括热词和上下文信息,以便优化语音识别的准确性和相关性。
	AsrConfig *WebSocketASRConfig `json:"asr_config,omitempty"`
}

WebSocketChatUpdateEventData contains chat configuration

type WebSocketChatUpdatedEvent

type WebSocketChatUpdatedEvent struct {
	Data *WebSocketChatUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketChatUpdatedEvent 对话配置成功

对话配置更新成功后,会返回最新的配置。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#39879618 seq:v1/chat:resp:2

func (WebSocketChatUpdatedEvent) GetDetail

func (r WebSocketChatUpdatedEvent) GetDetail() *EventDetail

func (WebSocketChatUpdatedEvent) GetEventType

func (r WebSocketChatUpdatedEvent) GetEventType() WebSocketEventType

func (WebSocketChatUpdatedEvent) GetID

func (r WebSocketChatUpdatedEvent) GetID() string

type WebSocketClient

type WebSocketClient interface {
	Connect() error
	Close() error
	IsConnected() bool
	Wait(eventTypes ...WebSocketEventType) error
	OnEvent(eventType WebSocketEventType, handler EventHandler)
}

type WebSocketClientErrorEvent

type WebSocketClientErrorEvent struct {
	Data error `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketClientErrorEvent represents an client error event seq:common:1

func (WebSocketClientErrorEvent) GetDetail

func (r WebSocketClientErrorEvent) GetDetail() *EventDetail

func (WebSocketClientErrorEvent) GetEventType

func (r WebSocketClientErrorEvent) GetEventType() WebSocketEventType

func (WebSocketClientErrorEvent) GetID

func (r WebSocketClientErrorEvent) GetID() string

type WebSocketClientOption

type WebSocketClientOption struct {
	SendChanCapacity    int           // 默认 1000
	ReceiveChanCapacity int           // 默认 1000
	HandshakeTimeout    time.Duration // 默认 3s
	// contains filtered or unexported fields
}

type WebSocketClosedEvent

type WebSocketClosedEvent struct {
	// contains filtered or unexported fields
}

WebSocketClosedEvent represents an closed event seq:common:2

func (WebSocketClosedEvent) GetDetail

func (r WebSocketClosedEvent) GetDetail() *EventDetail

func (WebSocketClosedEvent) GetEventType

func (r WebSocketClosedEvent) GetEventType() WebSocketEventType

func (WebSocketClosedEvent) GetID

func (r WebSocketClosedEvent) GetID() string

type WebSocketConversationAudioCompletedEvent

type WebSocketConversationAudioCompletedEvent struct {
	Data *Message `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationAudioCompletedEvent 语音回复完成

语音回复完成,表示对话结束。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#b00d6a73 seq:v1/chat:resp:9

func (WebSocketConversationAudioCompletedEvent) GetDetail

func (r WebSocketConversationAudioCompletedEvent) GetDetail() *EventDetail

func (WebSocketConversationAudioCompletedEvent) GetEventType

func (r WebSocketConversationAudioCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationAudioCompletedEvent) GetID

func (r WebSocketConversationAudioCompletedEvent) GetID() string

type WebSocketConversationAudioDeltaEvent

type WebSocketConversationAudioDeltaEvent struct {
	Data *WebSocketConversationAudioDeltaEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationAudioDeltaEvent 增量语音

增量消息,通常是 type=answer 时的增量消息。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#36a38a6b seq:v1/chat:resp:7

func (WebSocketConversationAudioDeltaEvent) GetDetail

func (r WebSocketConversationAudioDeltaEvent) GetDetail() *EventDetail

func (WebSocketConversationAudioDeltaEvent) GetEventType

func (r WebSocketConversationAudioDeltaEvent) GetEventType() WebSocketEventType

func (WebSocketConversationAudioDeltaEvent) GetID

func (r WebSocketConversationAudioDeltaEvent) GetID() string

type WebSocketConversationAudioDeltaEventData

type WebSocketConversationAudioDeltaEventData struct {
	// The entity that sent this message.
	Role MessageRole `json:"role"`

	// The type of message.
	Type MessageType `json:"type"`

	// The content of the message. It supports various types of content, including plain text,
	// multimodal (a mix of text, images, and files), message cards, and more.
	Content []byte `json:"content"`

	// The reasoning_content of the thought process message
	ReasoningContent string `json:"reasoning_content"`

	// The type of message content.
	ContentType MessageContentType `json:"content_type"`

	// Additional information when creating a message, and this additional information will also be
	// returned when retrieving messages. Custom key-value pairs should be specified in Map object
	// format, with a length of 16 key-value pairs. The length of the key should be between 1 and 64
	// characters, and the length of the value should be between 1 and 512 characters.
	MetaData map[string]string `json:"meta_data,omitempty"`

	ID             string `json:"id"`
	ConversationID string `json:"conversation_id"`

	// section_id is used to distinguish the context sections of the session history. The same section
	// is one context.
	SectionID string `json:"section_id"`
	BotID     string `json:"bot_id"`
	ChatID    string `json:"chat_id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
}

type WebSocketConversationAudioSentenceStartEvent

type WebSocketConversationAudioSentenceStartEvent struct {
	Data *WebSocketConversationAudioSentenceStartEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationAudioSentenceStartEvent 增量语音字幕

一条新的字幕句子,后续的 conversation.audio.delta 增量语音均属于当前字幕句子,可能有多个增量语音共同对应此句字幕的文字内容。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#2e67bf44 seq:v1/chat:resp:6

func (WebSocketConversationAudioSentenceStartEvent) GetDetail

func (r WebSocketConversationAudioSentenceStartEvent) GetDetail() *EventDetail

func (WebSocketConversationAudioSentenceStartEvent) GetEventType

func (r WebSocketConversationAudioSentenceStartEvent) GetEventType() WebSocketEventType

func (WebSocketConversationAudioSentenceStartEvent) GetID

func (r WebSocketConversationAudioSentenceStartEvent) GetID() string

type WebSocketConversationAudioSentenceStartEventData

type WebSocketConversationAudioSentenceStartEventData struct {
	// 新字幕句子的文本内容,后续相关 conversation.audio.delta 增量语音均对应此文本。
	Text string `json:"text"`
}

type WebSocketConversationAudioTranscriptCompletedEvent

type WebSocketConversationAudioTranscriptCompletedEvent struct {
	Data *WebSocketConversationAudioTranscriptCompletedEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationAudioTranscriptCompletedEvent 用户语音识别完成

用户语音识别完成,表示用户语音识别完成。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#9d1e6930 seq:v1/chat:resp:15

func (WebSocketConversationAudioTranscriptCompletedEvent) GetDetail

func (r WebSocketConversationAudioTranscriptCompletedEvent) GetDetail() *EventDetail

func (WebSocketConversationAudioTranscriptCompletedEvent) GetEventType

func (r WebSocketConversationAudioTranscriptCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationAudioTranscriptCompletedEvent) GetID

func (r WebSocketConversationAudioTranscriptCompletedEvent) GetID() string

type WebSocketConversationAudioTranscriptCompletedEventData

type WebSocketConversationAudioTranscriptCompletedEventData struct {
	// 语音识别的最终结果。
	Content string `json:"content"`
}

type WebSocketConversationAudioTranscriptUpdateEvent

type WebSocketConversationAudioTranscriptUpdateEvent struct {
	Data *WebSocketConversationAudioTranscriptUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationAudioTranscriptUpdateEvent 用户语音识别字幕

用户语音识别的中间值,每次返回都是全量文本。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#1b59cbf9 seq:v1/chat:resp:14

func (WebSocketConversationAudioTranscriptUpdateEvent) GetDetail

func (r WebSocketConversationAudioTranscriptUpdateEvent) GetDetail() *EventDetail

func (WebSocketConversationAudioTranscriptUpdateEvent) GetEventType

func (r WebSocketConversationAudioTranscriptUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketConversationAudioTranscriptUpdateEvent) GetID

func (r WebSocketConversationAudioTranscriptUpdateEvent) GetID() string

type WebSocketConversationAudioTranscriptUpdateEventData

type WebSocketConversationAudioTranscriptUpdateEventData struct {
	// 语音识别的中间值。
	Content string `json:"content"`
}

type WebSocketConversationChatCancelEvent

type WebSocketConversationChatCancelEvent struct {
	// contains filtered or unexported fields
}

WebSocketConversationChatCancelEvent 打断智能体输出

发送此事件可取消正在进行的对话,中断后,服务端将会返回 conversation.chat.canceled 事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#0554db7d seq:v1/chat:req:4

func (WebSocketConversationChatCancelEvent) GetDetail

func (r WebSocketConversationChatCancelEvent) GetDetail() *EventDetail

func (WebSocketConversationChatCancelEvent) GetEventType

func (r WebSocketConversationChatCancelEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatCancelEvent) GetID

func (r WebSocketConversationChatCancelEvent) GetID() string

type WebSocketConversationChatCancelEventData

type WebSocketConversationChatCancelEventData struct{}

type WebSocketConversationChatCanceledEvent

type WebSocketConversationChatCanceledEvent struct {
	Data *WebSocketConversationChatCanceledEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatCanceledEvent 智能体输出中断

客户端提交 conversation.chat.cancel 事件,服务端完成中断后,将返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#089ed144 seq:v1/chat:resp:13

func (WebSocketConversationChatCanceledEvent) GetDetail

func (r WebSocketConversationChatCanceledEvent) GetDetail() *EventDetail

func (WebSocketConversationChatCanceledEvent) GetEventType

func (r WebSocketConversationChatCanceledEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatCanceledEvent) GetID

func (r WebSocketConversationChatCanceledEvent) GetID() string

type WebSocketConversationChatCanceledEventData

type WebSocketConversationChatCanceledEventData struct {
	// 输出中断类型枚举值,包括 1: 被用户语音说话打断  2: 用户主动 cancel  3: 手动提交对话内容
	Code int `json:"code"`
	// 智能体输出中断的详细说明
	Msg string `json:"msg"`
}

WebSocketConversationChatCanceledEventData contains cancellation information

type WebSocketConversationChatCompletedEvent

type WebSocketConversationChatCompletedEvent struct {
	Data *Chat `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatCompletedEvent 对话完成

对话完成,表示对话结束。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#02fac327 seq:v1/chat:resp:10

func (WebSocketConversationChatCompletedEvent) GetDetail

func (r WebSocketConversationChatCompletedEvent) GetDetail() *EventDetail

func (WebSocketConversationChatCompletedEvent) GetEventType

func (r WebSocketConversationChatCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatCompletedEvent) GetID

func (r WebSocketConversationChatCompletedEvent) GetID() string

type WebSocketConversationChatCreatedEvent

type WebSocketConversationChatCreatedEvent struct {
	Data *Chat `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatCreatedEvent 对话开始

创建对话的事件,表示对话开始。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#a2b10fd2 seq:v1/chat:resp:3

func (WebSocketConversationChatCreatedEvent) GetDetail

func (r WebSocketConversationChatCreatedEvent) GetDetail() *EventDetail

func (WebSocketConversationChatCreatedEvent) GetEventType

func (r WebSocketConversationChatCreatedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatCreatedEvent) GetID

func (r WebSocketConversationChatCreatedEvent) GetID() string

type WebSocketConversationChatFailedEvent

type WebSocketConversationChatFailedEvent struct {
	Data *Chat `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatFailedEvent 对话失败

此事件用于标识对话失败。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#765bb7e5 seq:v1/chat:resp:11

func (WebSocketConversationChatFailedEvent) GetDetail

func (r WebSocketConversationChatFailedEvent) GetDetail() *EventDetail

func (WebSocketConversationChatFailedEvent) GetEventType

func (r WebSocketConversationChatFailedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatFailedEvent) GetID

func (r WebSocketConversationChatFailedEvent) GetID() string

type WebSocketConversationChatInProgressEvent

type WebSocketConversationChatInProgressEvent struct {
	Data *Chat `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatInProgressEvent 对话正在处理

服务端正在处理对话。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#36a38a6b seq:v1/chat:resp:4

func (WebSocketConversationChatInProgressEvent) GetDetail

func (r WebSocketConversationChatInProgressEvent) GetDetail() *EventDetail

func (WebSocketConversationChatInProgressEvent) GetEventType

func (r WebSocketConversationChatInProgressEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatInProgressEvent) GetID

func (r WebSocketConversationChatInProgressEvent) GetID() string

type WebSocketConversationChatRequiresActionEvent

type WebSocketConversationChatRequiresActionEvent struct {
	Data *Chat `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatRequiresActionEvent 端插件请求

对话中断,需要使用方上报工具的执行结果。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#2ef697d8 seq:v1/chat:resp:16

func (WebSocketConversationChatRequiresActionEvent) GetDetail

func (r WebSocketConversationChatRequiresActionEvent) GetDetail() *EventDetail

func (WebSocketConversationChatRequiresActionEvent) GetEventType

func (r WebSocketConversationChatRequiresActionEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatRequiresActionEvent) GetID

func (r WebSocketConversationChatRequiresActionEvent) GetID() string

type WebSocketConversationChatSubmitToolOutputsEvent

type WebSocketConversationChatSubmitToolOutputsEvent struct {
	Data *WebSocketConversationChatSubmitToolOutputsEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationChatSubmitToolOutputsEvent 提交端插件执行结果

你可以将需要客户端执行的操作定义为插件,对话中如果触发这个插件,会收到一个 event_type = "conversation.chat.requires_action" 的下行事件,此时需要执行客户端的操作后,通过此上行事件来提交插件执行后的结果。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#aacdcb41 seq:v1/chat:req:3

func (WebSocketConversationChatSubmitToolOutputsEvent) GetDetail

func (r WebSocketConversationChatSubmitToolOutputsEvent) GetDetail() *EventDetail

func (WebSocketConversationChatSubmitToolOutputsEvent) GetEventType

func (r WebSocketConversationChatSubmitToolOutputsEvent) GetEventType() WebSocketEventType

func (WebSocketConversationChatSubmitToolOutputsEvent) GetID

func (r WebSocketConversationChatSubmitToolOutputsEvent) GetID() string

type WebSocketConversationChatSubmitToolOutputsEventData

type WebSocketConversationChatSubmitToolOutputsEventData struct {
	// 对话的唯一标识。
	ChatID string `json:"chat_id"`
	// 工具执行结果。
	ToolOutputs []*ToolOutput `json:"tool_outputs"`
}

WebSocketConversationChatSubmitToolOutputsEventData contains tool outputs

type WebSocketConversationClearEvent

type WebSocketConversationClearEvent struct {
	// contains filtered or unexported fields
}

WebSocketConversationClearEvent 清除上下文

清除上下文,会在当前 conversation 下新增一个 section,服务端处理完后会返回 conversation.cleared 事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#aa86f213

func (WebSocketConversationClearEvent) GetDetail

func (r WebSocketConversationClearEvent) GetDetail() *EventDetail

func (WebSocketConversationClearEvent) GetEventType

func (r WebSocketConversationClearEvent) GetEventType() WebSocketEventType

func (WebSocketConversationClearEvent) GetID

func (r WebSocketConversationClearEvent) GetID() string

type WebSocketConversationClearEventData

type WebSocketConversationClearEventData struct{}

type WebSocketConversationClearedEvent

type WebSocketConversationClearedEvent struct {
	// contains filtered or unexported fields
}

WebSocketConversationClearedEvent 上下文清除完成

上下文清除完成,表示上下文已清除。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#6a941b8a seq:v1/chat:resp:12

func (WebSocketConversationClearedEvent) GetDetail

func (r WebSocketConversationClearedEvent) GetDetail() *EventDetail

func (WebSocketConversationClearedEvent) GetEventType

func (r WebSocketConversationClearedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationClearedEvent) GetID

func (r WebSocketConversationClearedEvent) GetID() string

type WebSocketConversationMessageCompletedEvent

type WebSocketConversationMessageCompletedEvent struct {
	Data *Message `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationMessageCompletedEvent 消息完成

消息已回复完成。此时事件中带有所有 message.delta 的拼接结果,且每个消息均为 completed 状态。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#4361e8d1 seq:v1/chat:resp:8

func (WebSocketConversationMessageCompletedEvent) GetDetail

func (r WebSocketConversationMessageCompletedEvent) GetDetail() *EventDetail

func (WebSocketConversationMessageCompletedEvent) GetEventType

func (r WebSocketConversationMessageCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketConversationMessageCompletedEvent) GetID

func (r WebSocketConversationMessageCompletedEvent) GetID() string

type WebSocketConversationMessageCreateEvent

type WebSocketConversationMessageCreateEvent struct {
	Data *WebSocketConversationMessageCreateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationMessageCreateEvent 手动提交对话内容

若 role=user,提交事件后就会生成语音回复,适合如下的场景,比如帮我解析 xx 链接,帮我分析这个图片的内容等。若 role=assistant,提交事件后会加入到对话的上下文。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#46f6a7d0 seq:v1/chat:req:2

func (WebSocketConversationMessageCreateEvent) GetDetail

func (r WebSocketConversationMessageCreateEvent) GetDetail() *EventDetail

func (WebSocketConversationMessageCreateEvent) GetEventType

func (r WebSocketConversationMessageCreateEvent) GetEventType() WebSocketEventType

func (WebSocketConversationMessageCreateEvent) GetID

func (r WebSocketConversationMessageCreateEvent) GetID() string

type WebSocketConversationMessageCreateEventData

type WebSocketConversationMessageCreateEventData struct {
	// 发送这条消息的实体。取值:user(代表该条消息内容是用户发送的)、assistant(代表该条消息内容是智能体发送的)。
	Role MessageRole `json:"role,omitempty"`
	// 消息内容的类型,支持设置为:text:文本。object_string:多模态内容,即文本和文件的组合、文本和图片的组合。
	ContentType MessageContentType `json:"content_type,omitempty"`
	// 消息的内容,支持纯文本、多模态(文本、图片、文件混合输入)、卡片等多种类型的内容。当 content_type 为 object_string时,content 的结构和详细参数说明请参见object_string object。
	Content string `json:"content,omitempty"`
}

WebSocketConversationMessageCreateEventData contains message content

type WebSocketConversationMessageDeltaEvent

type WebSocketConversationMessageDeltaEvent struct {
	Data *Message `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketConversationMessageDeltaEvent 增量消息

增量消息,通常是 type=answer 时的增量消息。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#2dfe8dba seq:v1/chat:resp:5

func (WebSocketConversationMessageDeltaEvent) GetDetail

func (r WebSocketConversationMessageDeltaEvent) GetDetail() *EventDetail

func (WebSocketConversationMessageDeltaEvent) GetEventType

func (r WebSocketConversationMessageDeltaEvent) GetEventType() WebSocketEventType

func (WebSocketConversationMessageDeltaEvent) GetID

func (r WebSocketConversationMessageDeltaEvent) GetID() string

type WebSocketErrorEvent

type WebSocketErrorEvent struct {
	Data *Error `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketErrorEvent represents an error event seq:common:3

func (WebSocketErrorEvent) GetDetail

func (r WebSocketErrorEvent) GetDetail() *EventDetail

func (WebSocketErrorEvent) GetEventType

func (r WebSocketErrorEvent) GetEventType() WebSocketEventType

func (WebSocketErrorEvent) GetID

func (r WebSocketErrorEvent) GetID() string

type WebSocketEventType

type WebSocketEventType string

WebSocketEventType websocket 事件类型

const (
	WebSocketEventTypeClientError WebSocketEventType = "client_error" // sdk error
	WebSocketEventTypeClosed      WebSocketEventType = "closed"       // connection closed
	WebSocketEventTypeError       WebSocketEventType = "error"        // 发生错误

	WebSocketEventTypeSpeechUpdate            WebSocketEventType = "speech.update"              // 更新语音合成配置
	WebSocketEventTypeInputTextBufferAppend   WebSocketEventType = "input_text_buffer.append"   // 流式输入文字
	WebSocketEventTypeInputTextBufferComplete WebSocketEventType = "input_text_buffer.complete" // 提交文字

	WebSocketEventTypeSpeechCreated            WebSocketEventType = "speech.created"              // 语音合成连接成功
	WebSocketEventTypeSpeechUpdated            WebSocketEventType = "speech.updated"              // 配置更新完成
	WebSocketEventTypeInputTextBufferCompleted WebSocketEventType = "input_text_buffer.completed" // input_text_buffer 提交完成
	WebSocketEventTypeSpeechAudioUpdate        WebSocketEventType = "speech.audio.update"         // 合成增量语音
	WebSocketEventTypeSpeechAudioCompleted     WebSocketEventType = "speech.audio.completed"      // 合成完成

	WebSocketEventTypeTranscriptionsUpdate     WebSocketEventType = "transcriptions.update"       // 更新语音识别配置
	WebSocketEventTypeInputAudioBufferAppend   WebSocketEventType = "input_audio_buffer.append"   // 流式上传音频片段
	WebSocketEventTypeInputAudioBufferComplete WebSocketEventType = "input_audio_buffer.complete" // 提交音频
	WebSocketEventTypeInputAudioBufferClear    WebSocketEventType = "input_audio_buffer.clear"    // 清除缓冲区音频

	WebSocketEventTypeTranscriptionsCreated          WebSocketEventType = "transcriptions.created"           // 连接成功
	WebSocketEventTypeTranscriptionsUpdated          WebSocketEventType = "transcriptions.updated"           // 配置更新成功
	WebSocketEventTypeInputAudioBufferCompleted      WebSocketEventType = "input_audio_buffer.completed"     // 音频提交完成
	WebSocketEventTypeInputAudioBufferCleared        WebSocketEventType = "input_audio_buffer.cleared"       // 音频清除成功
	WebSocketEventTypeTranscriptionsMessageUpdate    WebSocketEventType = "transcriptions.message.update"    // 识别出文字
	WebSocketEventTypeTranscriptionsMessageCompleted WebSocketEventType = "transcriptions.message.completed" // 识别完成

	WebSocketEventTypeChatUpdate WebSocketEventType = "chat.update" // 更新对话配置
	// WebSocketEventTypeInputAudioBufferAppend            WebSocketEventType = "input_audio_buffer.append"             // 流式上传音频片段
	// WebSocketEventTypeInputAudioBufferComplete          WebSocketEventType = "input_audio_buffer.complete"           // 提交音频
	// WebSocketEventTypeInputAudioBufferClear             WebSocketEventType = "input_audio_buffer.clear"              // 清除缓冲区音频
	WebSocketEventTypeConversationMessageCreate         WebSocketEventType = "conversation.message.create"           // 手动提交对话内容
	WebSocketEventTypeConversationClear                 WebSocketEventType = "conversation.clear"                    // 清除上下文
	WebSocketEventTypeConversationChatSubmitToolOutputs WebSocketEventType = "conversation.chat.submit_tool_outputs" // 提交端插件执行结果
	WebSocketEventTypeConversationChatCancel            WebSocketEventType = "conversation.chat.cancel"              // 打断智能体输出
	WebSocketEventTypeInputTextGenerateAudio            WebSocketEventType = "input_text.generate_audio"             // 文本生成语音

	WebSocketEventTypeChatCreated                    WebSocketEventType = "chat.created"                      // 对话连接成功
	WebSocketEventTypeChatUpdated                    WebSocketEventType = "chat.updated"                      // 对话配置成功
	WebSocketEventTypeConversationChatCreated        WebSocketEventType = "conversation.chat.created"         // 对话开始
	WebSocketEventTypeConversationChatInProgress     WebSocketEventType = "conversation.chat.in_progress"     // 对话正在处理
	WebSocketEventTypeConversationMessageDelta       WebSocketEventType = "conversation.message.delta"        // 增量消息
	WebSocketEventTypeConversationAudioSentenceStart WebSocketEventType = "conversation.audio.sentence_start" // 增量语音字幕
	WebSocketEventTypeConversationAudioDelta         WebSocketEventType = "conversation.audio.delta"          // 增量语音
	WebSocketEventTypeConversationMessageCompleted   WebSocketEventType = "conversation.message.completed"    // 消息完成
	WebSocketEventTypeConversationAudioCompleted     WebSocketEventType = "conversation.audio.completed"      // 语音回复完成
	WebSocketEventTypeConversationChatCompleted      WebSocketEventType = "conversation.chat.completed"       // 对话完成
	WebSocketEventTypeConversationChatFailed         WebSocketEventType = "conversation.chat.failed"          // 对话失败
	// WebSocketEventTypeInputAudioBufferCompleted            WebSocketEventType = "input_audio_buffer.completed"            // 音频提交完成
	// WebSocketEventTypeInputAudioBufferCleared              WebSocketEventType = "input_audio_buffer.cleared"              // 音频清除成功
	WebSocketEventTypeConversationCleared                  WebSocketEventType = "conversation.cleared"                    // 上下文清除完成
	WebSocketEventTypeConversationChatCanceled             WebSocketEventType = "conversation.chat.canceled"              // 智能体输出中断
	WebSocketEventTypeConversationAudioTranscriptUpdate    WebSocketEventType = "conversation.audio_transcript.update"    // 用户语音识别字幕
	WebSocketEventTypeConversationAudioTranscriptCompleted WebSocketEventType = "conversation.audio_transcript.completed" // 用户语音识别完成
	WebSocketEventTypeConversationChatRequiresAction       WebSocketEventType = "conversation.chat.requires_action"       // 端插件请求
	WebSocketEventTypeInputAudioBufferSpeechStarted        WebSocketEventType = "input_audio_buffer.speech_started"       // 用户开始说话
	WebSocketEventTypeInputAudioBufferSpeechStopped        WebSocketEventType = "input_audio_buffer.speech_stopped"       // 用户结束说话
)

type WebSocketInputAudio

type WebSocketInputAudio struct {
	// 输入音频的格式,支持 pcm、wav、ogg。默认为 wav。
	Format *string `json:"format,omitempty"`
	// 输入音频的编码,支持 pcm、opus、g711a、g711u。默认为 pcm。如果音频编码格式为 g711a 或 g711u,format 请设置为 pcm。
	Codec *string `json:"codec,omitempty"`
	// 输入音频的采样率,默认是 24000。支持 8000、16000、22050、24000、32000、44100、48000。如果音频编码格式 codec 为 g711a 或 g711u,音频采样率需设置为 8000。
	SampleRate *int `json:"sample_rate,omitempty"`
	// 输入音频的声道数,支持 1(单声道)、2(双声道)。默认是 1(单声道)。
	Channel *int `json:"channel,omitempty"`
	// 输入音频的位深,默认是 16,支持8、16和24。
	BitDepth *int `json:"bit_depth,omitempty"`
}

WebSocketInputAudio configuration for audio input

type WebSocketInputAudioBufferAppendEvent

type WebSocketInputAudioBufferAppendEvent struct {
	Data *WebSocketInputAudioBufferAppendEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferAppendEvent 流式上传音频片段

流式向服务端提交音频的片段。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#9ef6e6ca seq:v1/audio/transcriptions:req:2

func (WebSocketInputAudioBufferAppendEvent) GetDetail

func (r WebSocketInputAudioBufferAppendEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferAppendEvent) GetEventType

func (r WebSocketInputAudioBufferAppendEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferAppendEvent) GetID

func (r WebSocketInputAudioBufferAppendEvent) GetID() string

type WebSocketInputAudioBufferAppendEventData

type WebSocketInputAudioBufferAppendEventData struct {
	// 音频片段。(API 返回的是base64编码的音频片段, SDK 已经自动解码为 bytes)
	Delta []byte `json:"delta"`
}

WebSocketInputAudioBufferAppendEventData contains audio delta

type WebSocketInputAudioBufferClearEvent

type WebSocketInputAudioBufferClearEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferClearEvent 清除缓冲区音频

客户端发送 input_audio_buffer.clear 事件来告诉服务端清除缓冲区的音频数据。服务端清除完后将返回 input_audio_buffer.cleared 事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#e98db543 seq:v1/audio/transcriptions:req:4

func (WebSocketInputAudioBufferClearEvent) GetDetail

func (r WebSocketInputAudioBufferClearEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferClearEvent) GetEventType

func (r WebSocketInputAudioBufferClearEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferClearEvent) GetID

func (r WebSocketInputAudioBufferClearEvent) GetID() string

type WebSocketInputAudioBufferClearEventData

type WebSocketInputAudioBufferClearEventData struct{}

type WebSocketInputAudioBufferClearedEvent

type WebSocketInputAudioBufferClearedEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferClearedEvent 音频清除成功

客户端发送 input_audio_buffer.clear 事件来告诉服务端清除音频缓冲区的数据。服务端清除完后将返回 input_audio_buffer.cleared 事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#8211875b seq:v1/audio/transcriptions:resp:4

func (WebSocketInputAudioBufferClearedEvent) GetDetail

func (r WebSocketInputAudioBufferClearedEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferClearedEvent) GetEventType

func (r WebSocketInputAudioBufferClearedEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferClearedEvent) GetID

func (r WebSocketInputAudioBufferClearedEvent) GetID() string

type WebSocketInputAudioBufferCompleteEvent

type WebSocketInputAudioBufferCompleteEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferCompleteEvent 提交音频

客户端发送 input_audio_buffer.complete 事件来告诉服务端提交音频缓冲区的数据。服务端提交成功后会返回 input_audio_buffer.completed 事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#f5d76c87 seq:v1/audio/transcriptions:req:3

func (WebSocketInputAudioBufferCompleteEvent) GetDetail

func (r WebSocketInputAudioBufferCompleteEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferCompleteEvent) GetEventType

func (r WebSocketInputAudioBufferCompleteEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferCompleteEvent) GetID

func (r WebSocketInputAudioBufferCompleteEvent) GetID() string

type WebSocketInputAudioBufferCompleteEventData

type WebSocketInputAudioBufferCompleteEventData struct{}

type WebSocketInputAudioBufferCompletedEvent

type WebSocketInputAudioBufferCompletedEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferCompletedEvent 音频提交完成

客户端发送 input_audio_buffer.complete 事件来告诉服务端提交音频缓冲区的数据。服务端提交成功后会返回 input_audio_buffer.completed 事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#8d747148 seq:v1/audio/transcriptions:resp:3

func (WebSocketInputAudioBufferCompletedEvent) GetDetail

func (r WebSocketInputAudioBufferCompletedEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferCompletedEvent) GetEventType

func (r WebSocketInputAudioBufferCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferCompletedEvent) GetID

func (r WebSocketInputAudioBufferCompletedEvent) GetID() string

type WebSocketInputAudioBufferSpeechStartedEvent

type WebSocketInputAudioBufferSpeechStartedEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferSpeechStartedEvent 用户开始说话

此事件表示服务端识别到用户正在说话。只有在 server_vad 模式下,才会返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#95553c68 seq:v1/chat:resp:17

func (WebSocketInputAudioBufferSpeechStartedEvent) GetDetail

func (r WebSocketInputAudioBufferSpeechStartedEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferSpeechStartedEvent) GetEventType

func (r WebSocketInputAudioBufferSpeechStartedEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferSpeechStartedEvent) GetID

func (r WebSocketInputAudioBufferSpeechStartedEvent) GetID() string

type WebSocketInputAudioBufferSpeechStoppedEvent

type WebSocketInputAudioBufferSpeechStoppedEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputAudioBufferSpeechStoppedEvent 用户结束说话

此事件表示服务端识别到用户已停止说话。只有在 server_vad 模式下,才会返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/streaming_chat_event#5084c0aa seq:v1/chat:resp:18

func (WebSocketInputAudioBufferSpeechStoppedEvent) GetDetail

func (r WebSocketInputAudioBufferSpeechStoppedEvent) GetDetail() *EventDetail

func (WebSocketInputAudioBufferSpeechStoppedEvent) GetEventType

func (r WebSocketInputAudioBufferSpeechStoppedEvent) GetEventType() WebSocketEventType

func (WebSocketInputAudioBufferSpeechStoppedEvent) GetID

func (r WebSocketInputAudioBufferSpeechStoppedEvent) GetID() string

type WebSocketInputTextBufferAppendEvent

type WebSocketInputTextBufferAppendEvent struct {
	Data *WebSocketInputTextBufferAppendEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketInputTextBufferAppendEvent 流式输入文字

流式向服务端提交文字的片段。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#0ba93be3 seq:v1/audio/speech:req:2

func (WebSocketInputTextBufferAppendEvent) GetDetail

func (r WebSocketInputTextBufferAppendEvent) GetDetail() *EventDetail

func (WebSocketInputTextBufferAppendEvent) GetEventType

func (r WebSocketInputTextBufferAppendEvent) GetEventType() WebSocketEventType

func (WebSocketInputTextBufferAppendEvent) GetID

func (r WebSocketInputTextBufferAppendEvent) GetID() string

type WebSocketInputTextBufferAppendEventData

type WebSocketInputTextBufferAppendEventData struct {
	// 需要合成语音的文字片段。
	Delta string `json:"delta"`
}

WebSocketInputTextBufferAppendEventData contains the text delta

type WebSocketInputTextBufferCompleteEvent

type WebSocketInputTextBufferCompleteEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputTextBufferCompleteEvent 提交文字

提交 append 的文本,发送后将收到 input_text_buffer.completed 的下行事件。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#ab24ada9 seq:v1/audio/speech:req:3

func (WebSocketInputTextBufferCompleteEvent) GetDetail

func (r WebSocketInputTextBufferCompleteEvent) GetDetail() *EventDetail

func (WebSocketInputTextBufferCompleteEvent) GetEventType

func (r WebSocketInputTextBufferCompleteEvent) GetEventType() WebSocketEventType

func (WebSocketInputTextBufferCompleteEvent) GetID

func (r WebSocketInputTextBufferCompleteEvent) GetID() string

type WebSocketInputTextBufferCompleteEventData

type WebSocketInputTextBufferCompleteEventData struct{}

type WebSocketInputTextBufferCompletedEvent

type WebSocketInputTextBufferCompletedEvent struct {
	// contains filtered or unexported fields
}

WebSocketInputTextBufferCompletedEvent input_text_buffer 提交完成

流式提交的文字完成后,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#cf5e0495

func (WebSocketInputTextBufferCompletedEvent) GetDetail

func (r WebSocketInputTextBufferCompletedEvent) GetDetail() *EventDetail

func (WebSocketInputTextBufferCompletedEvent) GetEventType

func (r WebSocketInputTextBufferCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketInputTextBufferCompletedEvent) GetID

func (r WebSocketInputTextBufferCompletedEvent) GetID() string

type WebSocketInputTextBufferCompletedEventData

type WebSocketInputTextBufferCompletedEventData struct{}

type WebSocketInputTextGenerateAudioEvent

type WebSocketInputTextGenerateAudioEvent struct {
	Data *WebSocketInputTextGenerateAudioEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketInputTextGenerateAudioEvent 文本生成语音

你可以主动提交一段文字用来做语音合成,提交的消息不会触发智能体的回复,只会合成音频内容下发到客户端。 提交事件的时候如果智能体正在输出语音会被中断输出。 适合在和智能体聊天过程中客户端长时间没有响应,智能体可以主动说话暖场的场景。

func (WebSocketInputTextGenerateAudioEvent) GetDetail

func (r WebSocketInputTextGenerateAudioEvent) GetDetail() *EventDetail

func (WebSocketInputTextGenerateAudioEvent) GetEventType

func (r WebSocketInputTextGenerateAudioEvent) GetEventType() WebSocketEventType

func (WebSocketInputTextGenerateAudioEvent) GetID

func (r WebSocketInputTextGenerateAudioEvent) GetID() string

type WebSocketInputTextGenerateAudioEventData

type WebSocketInputTextGenerateAudioEventData struct {
	// 消息内容的类型,支持设置为:text:文本
	Mode WebSocketInputTextGenerateAudioMode `json:"mode,omitempty"`
	// 当 mode == text 时候必填。长度限制 (0, 1024) 字节
	Text string `json:"text,omitempty"`
}

WebSocketInputTextGenerateAudioEventData contains text to audio data

type WebSocketInputTextGenerateAudioMode

type WebSocketInputTextGenerateAudioMode string
const (
	WebSocketInputTextGenerateAudioModeText WebSocketInputTextGenerateAudioMode = "text"
)

type WebSocketOpusConfig

type WebSocketOpusConfig struct {
	// 输出 opus 的码率,默认 48000。
	Bitrate *int `json:"bitrate,omitempty"`
	// 输出 opus 是否使用 CBR 编码,默认为 false。
	UseCBR *bool `json:"use_cbr,omitempty"`
	// 输出 opus 的帧长,默认是 10。可选值:2.5、5、10、20、40、60
	FrameSizeMs *float64 `json:"frame_size_ms,omitempty"`
	// 输出音频限流配置,默认不限制。
	LimitConfig *WebSocketAudioLimitConfig `json:"limit_config,omitempty"`
}

WebSocketOpusConfig configures Opus audio output

type WebSocketOutputAudio

type WebSocketOutputAudio struct {
	// Output audio codec, supports pcm, g711a, g711u, opus. Default is pcm.
	Codec *string `json:"codec,omitempty"`
	// 当 codec 设置为 pcm、g711a 或 g711u 时,用于配置 PCM 音频参数。当 codec 设置为 opus 时,不需要设置此字段
	PCMConfig *WebSocketPCMConfig `json:"pcm_config,omitempty"`
	// 当 codec 设置为 pcm 时,不需要设置此字段。
	OpusConfig *WebSocketOpusConfig `json:"opus_config,omitempty"`
	// 输出音频的语速,取值范围 [-50, 100],默认为 0。-50 表示 0.5 倍速,100 表示 2 倍速。
	SpeechRate *int `json:"speech_rate,omitempty"`
	// 输出音频的音色 ID,默认是柔美女友音色。你可以调用[查看音色列表](https://www.coze.cn/open/docs/developer_guides/list_voices) API 查看当前可用的所有音色 ID。
	VoiceID *string `json:"voice_id,omitempty"`
}

WebSocketOutputAudio configuration for audio output

type WebSocketPCMConfig

type WebSocketPCMConfig struct {
	// 输出 pcm 音频的采样率,默认是 24000。支持 8000、16000、22050、24000、32000、44100、48000。
	SampleRate *int `json:"sample_rate,omitempty"`
	// 输出每个 pcm 包的时长,单位 ms,默认不限制。
	FrameSizeMs *float64 `json:"frame_size_ms,omitempty"`
	// 输出音频限流配置,默认不限制。
	LimitConfig *WebSocketAudioLimitConfig `json:"limit_config,omitempty"`
}

WebSocketPCMConfig configures PCM audio output

type WebSocketSpeechAudioCompletedEvent

type WebSocketSpeechAudioCompletedEvent struct {
	// contains filtered or unexported fields
}

WebSocketSpeechAudioCompletedEvent 合成完成

语音合成完成后,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#f42e9cb7 seq:v1/audio/speech:resp:5

func (WebSocketSpeechAudioCompletedEvent) GetDetail

func (r WebSocketSpeechAudioCompletedEvent) GetDetail() *EventDetail

func (WebSocketSpeechAudioCompletedEvent) GetEventType

func (r WebSocketSpeechAudioCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketSpeechAudioCompletedEvent) GetID

func (r WebSocketSpeechAudioCompletedEvent) GetID() string

type WebSocketSpeechAudioUpdateEvent

type WebSocketSpeechAudioUpdateEvent struct {
	Data *WebSocketSpeechAudioUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketSpeechAudioUpdateEvent 合成增量语音

语音合成产生增量语音时,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#98163c71 seq:v1/audio/speech:resp:4

func (WebSocketSpeechAudioUpdateEvent) GetDetail

func (r WebSocketSpeechAudioUpdateEvent) GetDetail() *EventDetail

func (WebSocketSpeechAudioUpdateEvent) GetEventType

func (r WebSocketSpeechAudioUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketSpeechAudioUpdateEvent) GetID

func (r WebSocketSpeechAudioUpdateEvent) GetID() string

type WebSocketSpeechAudioUpdateEventData

type WebSocketSpeechAudioUpdateEventData struct {
	// 音频片段。(API 返回的是base64编码的音频片段, SDK 已经自动解码为 bytes)
	Delta []byte `json:"delta"`
}

WebSocketSpeechAudioUpdateEventData contains audio delta

type WebSocketSpeechCreatedEvent

type WebSocketSpeechCreatedEvent struct {
	// contains filtered or unexported fields
}

WebSocketSpeechCreatedEvent 语音合成连接成功

语音合成连接成功后,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#23c0993e seq:v1/audio/speech:resp:1

func (WebSocketSpeechCreatedEvent) GetDetail

func (r WebSocketSpeechCreatedEvent) GetDetail() *EventDetail

func (WebSocketSpeechCreatedEvent) GetEventType

func (r WebSocketSpeechCreatedEvent) GetEventType() WebSocketEventType

func (WebSocketSpeechCreatedEvent) GetID

func (r WebSocketSpeechCreatedEvent) GetID() string

type WebSocketSpeechUpdateEvent

type WebSocketSpeechUpdateEvent struct {
	Data *WebSocketSpeechUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketSpeechUpdateEvent 流式输入文字

流式向服务端提交文字的片段。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#0ba93be3 seq:v1/audio/speech:req:1

func (WebSocketSpeechUpdateEvent) GetDetail

func (r WebSocketSpeechUpdateEvent) GetDetail() *EventDetail

func (WebSocketSpeechUpdateEvent) GetEventType

func (r WebSocketSpeechUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketSpeechUpdateEvent) GetID

func (r WebSocketSpeechUpdateEvent) GetID() string

type WebSocketSpeechUpdateEventData

type WebSocketSpeechUpdateEventData struct {
	// 输出音频格式。
	OutputAudio *WebSocketOutputAudio `json:"output_audio,omitempty"`
}

WebSocketSpeechUpdateEventData contains speech update configuration

type WebSocketSpeechUpdatedEvent

type WebSocketSpeechUpdatedEvent struct {
	Data *WebSocketSpeechUpdatedEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketSpeechUpdatedEvent 配置更新完成

配置更新成功后,会返回最新的配置。 docs: https://www.coze.cn/open/docs/developer_guides/tts_event#a3a59fb4 seq:v1/audio/speech:resp:2

func (WebSocketSpeechUpdatedEvent) GetDetail

func (r WebSocketSpeechUpdatedEvent) GetDetail() *EventDetail

func (WebSocketSpeechUpdatedEvent) GetEventType

func (r WebSocketSpeechUpdatedEvent) GetEventType() WebSocketEventType

func (WebSocketSpeechUpdatedEvent) GetID

func (r WebSocketSpeechUpdatedEvent) GetID() string

type WebSocketSpeechUpdatedEventData

type WebSocketSpeechUpdatedEventData struct {
	// 输出音频格式。
	OutputAudio *WebSocketOutputAudio `json:"output_audio,omitempty"`
}

WebSocketSpeechUpdatedEventData contains speech session information

type WebSocketTranscriptionsCreatedEvent

type WebSocketTranscriptionsCreatedEvent struct {
	// contains filtered or unexported fields
}

WebSocketTranscriptionsCreatedEvent 语音识别连接成功

语音识别连接成功后,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#06d772a3 seq:v1/audio/transcriptions:resp:1

func (WebSocketTranscriptionsCreatedEvent) GetDetail

func (r WebSocketTranscriptionsCreatedEvent) GetDetail() *EventDetail

func (WebSocketTranscriptionsCreatedEvent) GetEventType

func (r WebSocketTranscriptionsCreatedEvent) GetEventType() WebSocketEventType

func (WebSocketTranscriptionsCreatedEvent) GetID

func (r WebSocketTranscriptionsCreatedEvent) GetID() string

type WebSocketTranscriptionsMessageCompletedEvent

type WebSocketTranscriptionsMessageCompletedEvent struct {
	// contains filtered or unexported fields
}

WebSocketTranscriptionsMessageCompletedEvent 识别完成

语音识别完成后,返回此事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#0c36158c

func (WebSocketTranscriptionsMessageCompletedEvent) GetDetail

func (r WebSocketTranscriptionsMessageCompletedEvent) GetDetail() *EventDetail

func (WebSocketTranscriptionsMessageCompletedEvent) GetEventType

func (r WebSocketTranscriptionsMessageCompletedEvent) GetEventType() WebSocketEventType

func (WebSocketTranscriptionsMessageCompletedEvent) GetID

func (r WebSocketTranscriptionsMessageCompletedEvent) GetID() string

type WebSocketTranscriptionsMessageUpdateEvent

type WebSocketTranscriptionsMessageUpdateEvent struct {
	Data *WebSocketTranscriptionsMessageUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketTranscriptionsMessageUpdateEvent 识别出文字

语音识别出文字后,返回此事件,每次都返回全量的识别出来的文字。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#772e6d2d seq:v1/audio/transcriptions:resp:5

func (WebSocketTranscriptionsMessageUpdateEvent) GetDetail

func (r WebSocketTranscriptionsMessageUpdateEvent) GetDetail() *EventDetail

func (WebSocketTranscriptionsMessageUpdateEvent) GetEventType

func (r WebSocketTranscriptionsMessageUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketTranscriptionsMessageUpdateEvent) GetID

func (r WebSocketTranscriptionsMessageUpdateEvent) GetID() string

type WebSocketTranscriptionsMessageUpdateEventData

type WebSocketTranscriptionsMessageUpdateEventData struct {
	// 识别出的文字。
	Content string `json:"content"`
}

type WebSocketTranscriptionsUpdateEvent

type WebSocketTranscriptionsUpdateEvent struct {
	Data *WebSocketTranscriptionsUpdateEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketTranscriptionsUpdateEvent 更新语音识别配置

更新语音识别配置。若更新成功,会收到 transcriptions.updated 的下行事件,否则,会收到 error 下行事件。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#a7ca67ab seq:v1/audio/transcriptions:req:1

func (WebSocketTranscriptionsUpdateEvent) GetDetail

func (r WebSocketTranscriptionsUpdateEvent) GetDetail() *EventDetail

func (WebSocketTranscriptionsUpdateEvent) GetEventType

func (r WebSocketTranscriptionsUpdateEvent) GetEventType() WebSocketEventType

func (WebSocketTranscriptionsUpdateEvent) GetID

func (r WebSocketTranscriptionsUpdateEvent) GetID() string

type WebSocketTranscriptionsUpdateEventData

type WebSocketTranscriptionsUpdateEventData struct {
	// 输入音频格式。
	InputAudio *WebSocketInputAudio `json:"input_audio,omitempty"`
}

WebSocketTranscriptionsUpdateEventData contains transcription configuration

type WebSocketTranscriptionsUpdatedEvent

type WebSocketTranscriptionsUpdatedEvent struct {
	Data *WebSocketTranscriptionsUpdatedEventData `json:"data,omitempty"`
	// contains filtered or unexported fields
}

WebSocketTranscriptionsUpdatedEvent 配置更新成功

配置更新成功后,会返回最新的配置。 docs: https://www.coze.cn/open/docs/developer_guides/asr_event#3f842df1 seq:v1/audio/transcriptions:resp:2

func (WebSocketTranscriptionsUpdatedEvent) GetDetail

func (r WebSocketTranscriptionsUpdatedEvent) GetDetail() *EventDetail

func (WebSocketTranscriptionsUpdatedEvent) GetEventType

func (r WebSocketTranscriptionsUpdatedEvent) GetEventType() WebSocketEventType

func (WebSocketTranscriptionsUpdatedEvent) GetID

func (r WebSocketTranscriptionsUpdatedEvent) GetID() string

type WebSocketTranscriptionsUpdatedEventData

type WebSocketTranscriptionsUpdatedEventData struct {
	// 输入音频格式。
	InputAudio *WebSocketInputAudio `json:"input_audio,omitempty"`
}

type WebSocketTurnDetection

type WebSocketTurnDetection struct {
	// 用户演讲检测模式
	Type *WebSocketTurnDetectionType `json:"type,omitempty"`
	// server_vad 模式下,VAD 检测到语音之前要包含的音频量,单位为 ms。默认为 600ms。
	PrefixPaddingMS *int64 `json:"prefix_padding_ms,omitempty"`
	// server_vad 模式下,检测语音停止的静音持续时间,单位为 ms。默认为 500ms。
	SilenceDurationMS *int64 `json:"silence_duration_ms,omitempty"`
	// server_vad 模式下打断策略配置
	InterruptConfig *WebSocketTurnDetectionInterruptConfig `json:"interrupt_config,omitempty"`
}

type WebSocketTurnDetectionInterruptConfig

type WebSocketTurnDetectionInterruptConfig struct {
	// 打断模式
	Mode *WebSocketTurnDetectionInterruptConfigMode `json:"mode,omitempty"`
	// 打断的关键词配置,最多同时限制 5 个关键词,每个关键词限定长度在6-24个字节以内(2-8个汉字以内), 不能有标点符号。
	Keywords []string `json:"keywords,omitempty"`
}

type WebSocketTurnDetectionInterruptConfigMode

type WebSocketTurnDetectionInterruptConfigMode string
const (
	// WebSocketTurnDetectionInterruptConfigModeKeywordContains keyword_contains模式下,说话内容包含关键词才会打断模型回复。例如关键词"扣子",用户正在说“你好呀扣子......” / “扣子你好呀”,模型回复都会被打断。
	WebSocketTurnDetectionInterruptConfigModeKeywordContains WebSocketTurnDetectionInterruptConfigMode = "keyword_contains"
	// WebSocketTurnDetectionInterruptConfigModeKeywordPrefix keyword_prefix模式下,说话内容前缀匹配关键词才会打断模型回复。例如关键词"扣子",用户正在说“扣子你好呀......”,模型回复就会被打断,而用户说“你好呀扣子......”,模型回复不会被打断。
	WebSocketTurnDetectionInterruptConfigModeKeywordPrefix WebSocketTurnDetectionInterruptConfigMode = "keyword_prefix"
)

type WebSocketTurnDetectionType

type WebSocketTurnDetectionType string
const (
	// TurnDetectionTypeServerVAD 自由对话模式,语音数据会传输到服务器端进行实时分析,服务器端的语音活动检测算法会判断用户是否在说话。
	TurnDetectionTypeServerVAD WebSocketTurnDetectionType = "server_vad"
	// TurnDetectionTypeClientInterrupt 按键说话模式,客户端实时分析语音数据,并检测用户是否已停止说话。
	TurnDetectionTypeClientInterrupt WebSocketTurnDetectionType = "client_interrupt"
)

type WorkflowDebug

type WorkflowDebug struct {
	DebugUrl string `json:"debug_url"`
}

type WorkflowEvent

type WorkflowEvent struct {
	// The event ID of this message in the interface response. It starts from 0.
	ID int `json:"id"`

	// The current streaming data packet event.
	Event WorkflowEventType `json:"event"`

	Message   *WorkflowEventMessage   `json:"message,omitempty"`
	Interrupt *WorkflowEventInterrupt `json:"interrupt,omitempty"`
	Error     *WorkflowEventError     `json:"error,omitempty"`
	DebugURL  *WorkflowEventDebugURL  `json:"debug_url,omitempty"`
	Unknown   map[string]string       `json:"unknown,omitempty"`
}

WorkflowEvent represents an event in a workflow

func (*WorkflowEvent) IsDone

func (e *WorkflowEvent) IsDone() bool

type WorkflowEventDebugURL

type WorkflowEventDebugURL struct {
	URL string `json:"debug_url"`
}

type WorkflowEventError

type WorkflowEventError struct {
	// Status code. 0 represents a successful API call. Other values indicate that the call has
	// failed. You can determine the detailed reason for the error through the error_message field.
	ErrorCode int `json:"error_code"`

	// Status message. You can get detailed error information when the API call fails.
	ErrorMessage string `json:"error_message"`
}

WorkflowEventError represents an error event in a workflow

func ParseWorkflowEventError

func ParseWorkflowEventError(data string) (*WorkflowEventError, error)

ParseWorkflowEventError parses JSON string to WorkflowEventError

type WorkflowEventInterrupt

type WorkflowEventInterrupt struct {
	// The content of interruption event.
	InterruptData *WorkflowEventInterruptData `json:"interrupt_data"`

	// The name of the node that outputs the message, such as "Question".
	NodeTitle string `json:"node_title"`
}

WorkflowEventInterrupt represents an interruption event in a workflow

func ParseWorkflowEventInterrupt

func ParseWorkflowEventInterrupt(data string) (*WorkflowEventInterrupt, error)

ParseWorkflowEventInterrupt parses JSON string to WorkflowEventInterrupt

type WorkflowEventInterruptData

type WorkflowEventInterruptData struct {
	// The workflow interruption event ID, which should be passed back when resuming the workflow.
	EventID string `json:"event_id"`

	// The type of workflow interruption, which should be passed back when resuming the workflow.
	Type int `json:"type"`
}

WorkflowEventInterruptData represents the data of an interruption event

type WorkflowEventMessage

type WorkflowEventMessage struct {
	// The content of the streamed output message.
	Content string `json:"content"`

	// The name of the node that outputs the message, such as the message node or end node.
	NodeTitle string `json:"node_title"`

	// The message ID of this message within the node, starting at 0.
	NodeSeqID string `json:"node_seq_id"`

	// Whether the current message is the last data packet for this node.
	NodeIsFinish bool `json:"node_is_finish"`

	// Additional fields.
	Ext map[string]any `json:"ext,omitempty"`

	// Detailed information about Token consumption.
	Usage *ChatUsage `json:"usage,omitempty"`
}

WorkflowEventMessage represents a message event in a workflow

type WorkflowEventType

type WorkflowEventType string

WorkflowEventType represents the type of workflow event

const (
	// WorkflowEventTypeMessage mean the output message from the workflow node, such as the output message
	// from the message node or end node. You can view the specific message content in data.
	WorkflowEventTypeMessage WorkflowEventType = "Message"

	// WorkflowEventTypeError mean An error has occurred. You can view the error_code and error_message
	// in data to troubleshoot the issue.
	WorkflowEventTypeError WorkflowEventType = "Error"

	// WorkflowEventTypeDone mean the end of the workflow execution, where data is empty.
	WorkflowEventTypeDone WorkflowEventType = "Done"

	// WorkflowEventTypeInterrupt mean workflow has been interrupted, where the data field contains
	// specific interruption information.
	WorkflowEventTypeInterrupt WorkflowEventType = "Interrupt"

	// WorkflowEventTypePing mean ping-pong message.
	WorkflowEventTypePing WorkflowEventType = "PING"

	// WorkflowEventTypeUnknown mean unknown event
	WorkflowEventTypeUnknown WorkflowEventType = "unknown"
)

type WorkflowExecuteStatus

type WorkflowExecuteStatus string

WorkflowExecuteStatus represents the execution status of a workflow

const (
	// WorkflowExecuteStatusSuccess Execution succeeded.
	WorkflowExecuteStatusSuccess WorkflowExecuteStatus = "Success"

	// WorkflowExecuteStatusRunning Execution in progress.
	WorkflowExecuteStatusRunning WorkflowExecuteStatus = "Running"

	// WorkflowExecuteStatusFail Execution failed.
	WorkflowExecuteStatusFail WorkflowExecuteStatus = "Fail"
)

type WorkflowIDInfo

type WorkflowIDInfo struct {
	ID string `json:"id"`
}

type WorkflowIDList

type WorkflowIDList struct {
	IDs []WorkflowIDInfo `json:"ids"`
}

WorkflowIDList represents workflow ID information

type WorkflowInfo

type WorkflowInfo struct {
	WorkflowID   string `json:"workflow_id"`
	WorkflowName string `json:"workflow_name"`
	Description  string `json:"description"`
	IconURL      string `json:"icon_url"`
	AppID        string `json:"app_id"`
}

type WorkflowMode

type WorkflowMode string
const (
	WorkflowModeWorkflow WorkflowMode = "workflow"
	WorkflowModeChatflow WorkflowMode = "chatflow"
)

type WorkflowRunHistory

type WorkflowRunHistory struct {
	// The ID of execute.
	ExecuteID string `json:"execute_id"`

	// Execute status: success: Execution succeeded. running: Execution in progress. fail: Execution failed.
	ExecuteStatus WorkflowExecuteStatus `json:"execute_status"`

	// The Bot ID specified when executing the workflow. Returns 0 if no Bot ID was specified.
	BotID string `json:"bot_id"`

	// The release connector ID of the agent. By default, only the Agent as API connector is
	// displayed, and the connector ID is 1024.
	ConnectorID string `json:"connector_id"`

	// User ID, the user_id specified by the ext field when executing the workflow. If not specified,
	// the token applicant's button ID is returned.
	ConnectorUid string `json:"connector_uid"`

	// How the workflow runs: 0: Synchronous operation. 1: Streaming operation. 2: Asynchronous operation.
	RunMode WorkflowRunMode `json:"run_mode"`

	// The Log ID of the asynchronously running workflow. If the workflow is executed abnormally, you
	// can contact the service team to troubleshoot the problem through the Log ID.
	LogID string `json:"logid"`

	// The start time of the workflow, in Unix time timestamp format, in seconds.
	CreateTime int `json:"create_time"`

	// The workflow resume running time, in Unix time timestamp format, in seconds.
	UpdateTime int `json:"update_time"`

	// The output of the workflow is usually a JSON serialized string, but it may also be a non-JSON
	// structured string.
	Output string `json:"output"`

	// The status of each output node execution.
	NodeExecuteStatus map[string]*WorkflowRunHistoryNodeExecuteStatus `json:"node_execute_status"`

	// Status code. 0 represents a successful API call. Other values indicate that the call has
	// failed. You can determine the detailed reason for the error through the error_message field.
	ErrorCode string `json:"error_code"`

	// Status message. You can get detailed error information when the API call fails.
	ErrorMessage string `json:"error_message"`

	// Workflow trial runs debugging page. Visit this page to view the running results, input and
	// output information of each workflow node.
	DebugURL string `json:"debug_url"`

	// Detailed information about Token consumption.
	Usage *ChatUsage `json:"usage,omitempty"`
}

WorkflowRunHistory represents the history of a workflow runs

type WorkflowRunHistoryNodeExecuteStatus

type WorkflowRunHistoryNodeExecuteStatus struct {
	// The ID of the node.
	NodeID string `json:"node_id"`
	// Whether the node is finished.
	IsFinish bool `json:"is_finish"`
	// The loop index of the node.
	LoopIndex *int `json:"loop_index"`
	// The batch index of the node.
	BatchIndex *int `json:"batch_index"`
	// The update time of the node.
	UpdateTime int `json:"update_time"`
	// The ID of the sub-execute.
	SubExecuteID *string `json:"sub_execute_id"`
	// The UUID of the node execution.
	NodeExecuteUUID string `json:"node_execute_uuid"`
}

NodeExecuteStatus represents the status of a node execution

type WorkflowRunMode

type WorkflowRunMode int

WorkflowRunMode represents how the workflow runs

const (
	// WorkflowRunModeSynchronous Synchronous operation.
	WorkflowRunModeSynchronous WorkflowRunMode = 0

	// WorkflowRunModeStreaming Streaming operation.
	WorkflowRunModeStreaming WorkflowRunMode = 1

	// WorkflowRunModeAsynchronous Asynchronous operation.
	WorkflowRunModeAsynchronous WorkflowRunMode = 2
)

type WorkflowsChatStreamReq

type WorkflowsChatStreamReq struct {
	WorkflowID         string            `json:"workflow_id"`               // 工作流ID
	AdditionalMessages []*Message        `json:"additional_messages"`       // 额外的消息信息
	Parameters         map[string]any    `json:"parameters,omitempty"`      // 工作流参数
	AppID              *string           `json:"app_id,omitempty"`          // 应用ID
	BotID              *string           `json:"bot_id,omitempty"`          // 机器人ID
	ConversationID     *string           `json:"conversation_id,omitempty"` // 会话ID
	Ext                map[string]string `json:"ext,omitempty"`             // 扩展信息
}

WorkflowsChatStreamReq 表示工作流聊天流式请求

type Workspace

type Workspace struct {
	ID            string            `json:"id"`
	Name          string            `json:"name"`
	IconUrl       string            `json:"icon_url"`
	RoleType      WorkspaceRoleType `json:"role_type"`
	WorkspaceType WorkspaceType     `json:"workspace_type"`
	EnterpriseID  string            `json:"enterprise_id"`
}

Workspace represents workspace information

type WorkspaceMember

type WorkspaceMember struct {
	UserID         string            `json:"user_id"`                    // 用户ID
	RoleType       WorkspaceRoleType `json:"role_type"`                  // 当前用户角色
	UserNickname   string            `json:"user_nickname,omitempty"`    // 昵称(添加成员时不用传)
	UserUniqueName string            `json:"user_unique_name,omitempty"` // 用户名(添加成员时不用传)
	AvatarUrl      string            `json:"avatar_url,omitempty"`       // 头像 (添加成员时不用传)
}

type WorkspaceRoleType

type WorkspaceRoleType string

WorkspaceRoleType represents the workspace role type

const (
	WorkspaceRoleTypeOwner  WorkspaceRoleType = "owner"
	WorkspaceRoleTypeAdmin  WorkspaceRoleType = "admin"
	WorkspaceRoleTypeMember WorkspaceRoleType = "member"
)

type WorkspaceType

type WorkspaceType string

WorkspaceType represents the workspace type

const (
	WorkspaceTypePersonal WorkspaceType = "personal"
	WorkspaceTypeTeam     WorkspaceType = "team"
)

Directories

Path Synopsis
examples
apps/list command
auth/error command
auth/jwt_oauth command
auth/pkce_oauth command
auth/token command
auth/web_oauth command
bots/publish command
bots/retrieve command
chats/chat command
chats/stream command
client/error command
client/init command
client/log command
datasets/crud command
datasets/list command
files command
folders/list command
workflows/list command
workspaces/list command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL