Documentation
¶
Index ¶
- func GetItemStatus(block *schema.ContentBlock) (string, bool)
- func GetUserInputVideoFPS(block *schema.UserInputVideo) (float64, bool)
- func InvalidateMessageCaches(messages []*schema.AgenticMessage) error
- func SetUserInputVideoFPS(block *schema.UserInputVideo, fps float64)
- func WithContextManagement(cm *contextmanagement.ContextManagement) model.Option
- func WithCustomHeaders(headers map[string]string) model.Option
- func WithExpireAtSec(expireAtSec int64) model.Option
- func WithHeadPreviousResponseID(id string) model.Option
- func WithMCPTools(tools []*responses.ToolMcp) model.Option
- func WithMaxToolCalls(maxToolCalls int64) model.Option
- func WithParallelToolCalls(parallelToolCalls bool) model.Option
- func WithReasoning(reasoning *responses.ResponsesReasoning) model.Option
- func WithServerTools(tools []*ServerToolConfig) model.Option
- func WithText(text *responses.ResponsesText) model.Option
- func WithThinking(thinking *responses.ResponsesThinking) model.Option
- type AssistantGenTextExtension
- type CacheInfo
- type Config
- type ContentFilter
- type CoverImage
- type DocCitation
- type DoubaoAppArguments
- type DoubaoAppBlock
- type DoubaoAppBlockType
- type DoubaoAppFeature
- type DoubaoAppOutputText
- type DoubaoAppReasoningSearch
- type DoubaoAppReasoningText
- type DoubaoAppResult
- type DoubaoAppSearch
- type DoubaoAppSearchResult
- type ImageProcessAction
- type ImageProcessArguments
- type ImageProcessGrounding
- type ImageProcessPoint
- type ImageProcessResult
- type ImageProcessResultAction
- type ImageProcessResultError
- type ImageProcessRotate
- type ImageProcessZoom
- type IncompleteDetails
- type KnowledgeSearchArguments
- type Model
- func (m *Model) CreatePrefixCache(ctx context.Context, prefix []*schema.AgenticMessage, opts ...model.Option) (info *CacheInfo, err error)
- func (m *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outMsg *schema.AgenticMessage, err error)
- func (m *Model) GetType() string
- func (m *Model) IsCallbacksEnabled() bool
- func (m *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outStream *schema.StreamReader[*schema.AgenticMessage], err error)
- func (m *Model) WithTools(functionTools []*schema.ToolInfo) (model.AgenticModel, error)
- type ResponseError
- type ResponseMetaExtension
- type ResponseStatus
- type ResponseThinking
- type ServerToolCallArguments
- type ServerToolConfig
- type ServerToolName
- type ServerToolResult
- type ServiceTier
- type StreamingResponseError
- type TextAnnotation
- type TextAnnotationType
- type ThinkingType
- type URLCitation
- type WebSearchAction
- type WebSearchArguments
- type WebSearchQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetItemStatus ¶
func GetItemStatus(block *schema.ContentBlock) (string, bool)
func GetUserInputVideoFPS ¶
func GetUserInputVideoFPS(block *schema.UserInputVideo) (float64, bool)
func InvalidateMessageCaches ¶
func InvalidateMessageCaches(messages []*schema.AgenticMessage) error
InvalidateMessageCaches temporarily disables caching for the specified messages. When a message is modified or model is switched, Ark invalidates caches for that message and all subsequent ones. Call this to mark those message caches as invalid temporarily.
func SetUserInputVideoFPS ¶
func SetUserInputVideoFPS(block *schema.UserInputVideo, fps float64)
func WithContextManagement ¶
func WithContextManagement(cm *contextmanagement.ContextManagement) model.Option
func WithExpireAtSec ¶
WithExpireAtSec sets the expiration Unix timestamp (in seconds) for auto caching or prefix cache. This option overrides the ExpireAtSec field in Config.
func WithHeadPreviousResponseID ¶
WithHeadPreviousResponseID sets a response ID from a previous ResponsesAPI call. This ID links the current request to a previous conversation context, enabling features like conversation continuation and prefix caching. In populateCache, an auto-discovered response ID from input messages takes priority over this option. The referenced response must be cached before use.
func WithMaxToolCalls ¶
func WithParallelToolCalls ¶
func WithReasoning ¶
func WithReasoning(reasoning *responses.ResponsesReasoning) model.Option
func WithServerTools ¶
func WithServerTools(tools []*ServerToolConfig) model.Option
func WithThinking ¶
func WithThinking(thinking *responses.ResponsesThinking) model.Option
Types ¶
type AssistantGenTextExtension ¶
type AssistantGenTextExtension struct {
Annotations []*TextAnnotation `json:"annotations,omitempty" mapstructure:"annotations,omitempty"`
}
type CacheInfo ¶
type CacheInfo struct {
// ResponseID return by ResponsesAPI, it's specifies the id of prefix that can be used with [WithHeadPreviousResponseID] option.
ResponseID string
// Usage specifies the token usage of prefix
Usage schema.TokenUsage
}
type Config ¶
type Config struct {
// Timeout specifies the maximum duration to wait for API responses.
// If HTTPClient is set, Timeout will not be used.
// Optional.
Timeout *time.Duration
// HTTPClient specifies the HTTP client used to send requests.
// If HTTPClient is set, Timeout will not be used.
// Optional. Default: &http.Client{Timeout: Timeout}
HTTPClient *http.Client
// RetryTimes specifies the number of retry attempts for failed API calls.
// Optional.
RetryTimes *int
// BaseURL specifies the base URL for the Ark service endpoint.
// Optional.
BaseURL string
// Region specifies the geographic region where the Ark service is located.
// Optional.
Region string
// APIKey specifies the API key for authentication.
// Either APIKey or both AccessKey and SecretKey must be provided.
// APIKey takes precedence if both authentication methods are provided.
// For details, see: https://www.volcengine.com/docs/82379/1298459
APIKey string
// AccessKey specifies the access key for authentication.
// Must be used together with SecretKey.
AccessKey string
// SecretKey specifies the secret key for authentication.
// Must be used together with AccessKey.
SecretKey string
// Model specifies the identifier of the model endpoint on the Ark platform.
// For details, see: https://www.volcengine.com/docs/82379/1298454
// Required.
Model string
// MaxTokens specifies the maximum number of tokens to generate in the response.
// Optional.
MaxTokens *int
// Temperature controls the randomness of the model's output.
// Lower values (e.g., 0.2) make the output more focused and deterministic.
// Higher values (e.g., 1.0) make the output more creative and varied.
// Range: 0.0 to 2.0.
// Optional.
Temperature *float32
// TopP controls diversity via nucleus sampling, an alternative to Temperature.
// TopP specifies the cumulative probability threshold for token selection.
// For example, 0.1 means only tokens comprising the top 10% probability mass are considered.
// We recommend using either Temperature or TopP, but not both.
// Range: 0.0 to 1.0.
// Optional.
TopP *float32
// ServiceTier specifies the service tier to use for the request.
// Optional.
ServiceTier *responses.ResponsesServiceTier_Enum
// Text specifies text generation configuration options.
// Optional.
Text *responses.ResponsesText
// Thinking controls whether the model uses deep thinking mode.
// Optional.
Thinking *responses.ResponsesThinking
// Reasoning specifies the effort level for the model's reasoning process.
// Optional.
Reasoning *responses.ResponsesReasoning
// EnablePassBackReasoning controls whether the model passes back reasoning items in the next request.
// Note that doubao 1.6 does not support pass back reasoning.
// Optional. Default: true
EnablePassBackReasoning *bool
// MaxToolCalls specifies the maximum number of tool calls the model can make in a single response.
// Optional.
MaxToolCalls *int64
// ParallelToolCalls determines whether the model can invoke multiple tools simultaneously.
// Optional.
ParallelToolCalls *bool
// EnableAutoCache controls whether auto-caching for multi-turn conversations is active for the model.
// When enabled, conversation turns are stored, and the model automatically maintains context
// by locating the most recent cached message in the input (via Response ID in ResponseMeta).
// This cached message and all preceding inputs are excluded from the request.
// If the cached message becomes invalid, you can call [InvalidateMessageCaches] to temporarily invalidate the cache.
// Optional.
EnableAutoCache bool
// ExpireAtSec specifies the expiration Unix timestamp (in seconds) for auto caching or prefix cache.
// Optional.
ExpireAtSec *int64
// ContextManagement specifies context management strategies to help the model utilize the context window effectively.
// Supports clearing thinking blocks and tool call content.
// Optional.
ContextManagement *contextmanagement.ContextManagement
// CustomHeaders specifies custom HTTP headers to include in API requests.
// CustomHeaders allows passing additional metadata or authentication information.
// Optional.
CustomHeaders map[string]string
}
type ContentFilter ¶
type CoverImage ¶
type DocCitation ¶
type DocCitation struct {
DocID string `json:"doc_id,omitempty" mapstructure:"doc_id,omitempty"`
DocName string `json:"doc_name,omitempty" mapstructure:"doc_name,omitempty"`
ChunkID *int32 `json:"chunk_id,omitempty" mapstructure:"chunk_id,omitempty"`
ChunkAttachment []map[string]any `json:"chunk_attachment,omitempty" mapstructure:"chunk_attachment,omitempty"`
}
type DoubaoAppArguments ¶
type DoubaoAppArguments struct {
Feature DoubaoAppFeature `json:"feature,omitempty" mapstructure:"feature,omitempty"`
}
type DoubaoAppBlock ¶
type DoubaoAppBlock struct {
// Index is the index of this block within DoubaoApp result.
// Only available in streaming response.
Index *int `json:"index,omitempty" mapstructure:"index,omitempty"`
Type DoubaoAppBlockType `json:"type,omitempty" mapstructure:"type,omitempty"`
OutputText *DoubaoAppOutputText `json:"output_text,omitempty" mapstructure:"output_text,omitempty"`
ReasoningText *DoubaoAppReasoningText `json:"reasoning_text,omitempty" mapstructure:"reasoning_text,omitempty"`
Search *DoubaoAppSearch `json:"search,omitempty" mapstructure:"search,omitempty"`
ReasoningSearch *DoubaoAppReasoningSearch `json:"reasoning_search,omitempty" mapstructure:"reasoning_search,omitempty"`
}
type DoubaoAppBlockType ¶
type DoubaoAppBlockType string
const ( DoubaoAppBlockTypeOutputText DoubaoAppBlockType = "output_text" DoubaoAppBlockTypeReasoningText DoubaoAppBlockType = "reasoning_text" DoubaoAppBlockTypeSearch DoubaoAppBlockType = "search" DoubaoAppBlockTypeReasoningSearch DoubaoAppBlockType = "reasoning_search" )
type DoubaoAppFeature ¶
type DoubaoAppFeature string
const ( DoubaoAppFeatureChat DoubaoAppFeature = "chat" DoubaoAppFeatureDeepChat DoubaoAppFeature = "deep_chat" DoubaoAppFeatureAISearch DoubaoAppFeature = "ai_search" DoubaoAppFeatureReasoningSearch DoubaoAppFeature = "reasoning_search" )
type DoubaoAppOutputText ¶
type DoubaoAppOutputText struct {
ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
ParentID string `json:"parent_id,omitempty" mapstructure:"parent_id,omitempty"`
Text string `json:"text,omitempty" mapstructure:"text,omitempty"`
// Status represents the status of the output text.
// Only available in non-streaming response.
Status string `json:"status,omitempty" mapstructure:"status,omitempty"`
}
type DoubaoAppReasoningSearch ¶
type DoubaoAppReasoningSearch struct {
ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
ParentID string `json:"parent_id,omitempty" mapstructure:"parent_id,omitempty"`
Summary string `json:"summary,omitempty" mapstructure:"summary,omitempty"`
Queries []string `json:"queries,omitempty" mapstructure:"queries,omitempty"`
Results []*DoubaoAppSearchResult `json:"results,omitempty" mapstructure:"results,omitempty"`
// SearchingState represents the state of reasoning search.
// It is only available in streaming response.
SearchingState string `json:"searching_state,omitempty" mapstructure:"searching_state,omitempty"`
// Status represents the status of the reasoning search.
// It is only available in non-streaming response.
Status string `json:"status,omitempty" mapstructure:"status,omitempty"`
}
type DoubaoAppReasoningText ¶
type DoubaoAppReasoningText struct {
ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
ParentID string `json:"parent_id,omitempty" mapstructure:"parent_id,omitempty"`
ReasoningText string `json:"reasoning_text,omitempty" mapstructure:"reasoning_text,omitempty"`
// Status represents the status of the reasoning text.
// Only available in non-streaming response.
Status string `json:"status,omitempty" mapstructure:"status,omitempty"`
}
type DoubaoAppResult ¶
type DoubaoAppResult struct {
Blocks []*DoubaoAppBlock `json:"blocks,omitempty" mapstructure:"blocks,omitempty"`
}
type DoubaoAppSearch ¶
type DoubaoAppSearch struct {
ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
ParentID string `json:"parent_id,omitempty" mapstructure:"parent_id,omitempty"`
Summary string `json:"summary,omitempty" mapstructure:"summary,omitempty"`
Queries []string `json:"queries,omitempty" mapstructure:"queries,omitempty"`
Results []*DoubaoAppSearchResult `json:"results,omitempty" mapstructure:"results,omitempty"`
// SearchingState represents the state of searching.
// Only available in streaming response.
SearchingState string `json:"searching_state,omitempty" mapstructure:"searching_state,omitempty"`
// Status represents the status of the search.
// Only available in non-streaming response.
Status string `json:"status,omitempty" mapstructure:"status,omitempty"`
}
type DoubaoAppSearchResult ¶
type ImageProcessAction ¶
type ImageProcessAction string
const ( ImageProcessActionPoint ImageProcessAction = "point" ImageProcessActionGrounding ImageProcessAction = "grounding" ImageProcessActionRotate ImageProcessAction = "rotate" ImageProcessActionZoom ImageProcessAction = "zoom" )
type ImageProcessArguments ¶
type ImageProcessArguments struct {
ActionType ImageProcessAction `json:"action_type,omitempty" mapstructure:"action_type,omitempty"`
Point *ImageProcessPoint `json:"point,omitempty" mapstructure:"point,omitempty"`
Grounding *ImageProcessGrounding `json:"grounding,omitempty" mapstructure:"grounding,omitempty"`
Rotate *ImageProcessRotate `json:"rotate,omitempty" mapstructure:"rotate,omitempty"`
Zoom *ImageProcessZoom `json:"zoom,omitempty" mapstructure:"zoom,omitempty"`
}
type ImageProcessGrounding ¶
type ImageProcessPoint ¶
type ImageProcessResult ¶
type ImageProcessResult struct {
Action *ImageProcessResultAction `json:"action,omitempty" mapstructure:"action,omitempty"`
Error *ImageProcessResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type ImageProcessResultAction ¶
type ImageProcessResultAction struct {
Type ImageProcessAction `json:"type,omitempty" mapstructure:"type,omitempty"`
ResultImageURL string `json:"result_image_url,omitempty" mapstructure:"result_image_url,omitempty"`
}
type ImageProcessResultError ¶
type ImageProcessResultError struct {
Message string `json:"message,omitempty" mapstructure:"message,omitempty"`
}
type ImageProcessRotate ¶
type ImageProcessZoom ¶
type IncompleteDetails ¶
type IncompleteDetails struct {
Reason string `json:"reason,omitempty" mapstructure:"reason,omitempty"`
ContentFilter *ContentFilter `json:"content_filter,omitempty" mapstructure:"content_filter,omitempty"`
}
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) CreatePrefixCache ¶
func (m *Model) CreatePrefixCache(ctx context.Context, prefix []*schema.AgenticMessage, opts ...model.Option) (info *CacheInfo, err error)
CreatePrefixCache creates a prefix context on the server side. The server will input the prefix cached context and this turn of input into the model for processing. This improves efficiency by reducing token usage and request size.
Parameters:
- ctx: The context for the request
- prefix: Initial messages to be cached as prefix context
The expiration Unix timestamp (in seconds) for the cached prefix can be set via WithExpireAtSec option or the ExpireAtSec field in Config. Defaults to 3 days from now if not specified.
Returns:
- info: Information about the created prefix cache, including the context ID and token usage
- err: Any error encountered during the operation
Note:
- It is unavailable for doubao models of version 1.6 and above.
func (*Model) Generate ¶
func (m *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) ( outMsg *schema.AgenticMessage, err error)
func (*Model) IsCallbacksEnabled ¶
func (*Model) Stream ¶
func (m *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) ( outStream *schema.StreamReader[*schema.AgenticMessage], err error)
type ResponseError ¶
type ResponseMetaExtension ¶
type ResponseMetaExtension struct {
ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
Status ResponseStatus `json:"status,omitempty" mapstructure:"status,omitempty"`
IncompleteDetails *IncompleteDetails `json:"incomplete_details" mapstructure:"incomplete_details,omitempty"`
Error *ResponseError `json:"error" mapstructure:"error,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty" mapstructure:"previous_response_id,omitempty"`
Thinking *ResponseThinking `json:"thinking,omitempty" mapstructure:"thinking,omitempty"`
ExpireAt *int64 `json:"expire_at,omitempty" mapstructure:"expire_at,omitempty"`
ServiceTier ServiceTier `json:"service_tier,omitempty" mapstructure:"service_tier,omitempty"`
StreamingError *StreamingResponseError `json:"streaming_error,omitempty" mapstructure:"streaming_error,omitempty"`
}
type ResponseStatus ¶
type ResponseStatus string
const ( ResponseStatusInProgress ResponseStatus = "in_progress" ResponseStatusCompleted ResponseStatus = "completed" ResponseStatusIncomplete ResponseStatus = "incomplete" ResponseStatusFailed ResponseStatus = "failed" )
type ResponseThinking ¶
type ResponseThinking struct {
Type ThinkingType `json:"type,omitempty" mapstructure:"type,omitempty"`
}
type ServerToolCallArguments ¶
type ServerToolCallArguments struct {
WebSearch *WebSearchArguments `json:"web_search,omitempty" mapstructure:"web_search,omitempty"`
ImageProcess *ImageProcessArguments `json:"image_process,omitempty" mapstructure:"image_process,omitempty"`
DoubaoApp *DoubaoAppArguments `json:"doubao_app,omitempty" mapstructure:"doubao_app,omitempty"`
KnowledgeSearch *KnowledgeSearchArguments `json:"knowledge_search,omitempty" mapstructure:"knowledge_search,omitempty"`
}
type ServerToolConfig ¶
type ServerToolConfig struct {
WebSearch *responses.ToolWebSearch
ImageProcess *responses.ToolImageProcess
DoubaoApp *responses.ToolDoubaoApp
KnowledgeSearch *responses.ToolKnowledgeSearch
}
type ServerToolName ¶
type ServerToolName string
const ( ServerToolNameWebSearch ServerToolName = "web_search" ServerToolNameImageProcess ServerToolName = "image_process" ServerToolNameDoubaoApp ServerToolName = "doubao_app" ServerToolNameKnowledgeSearch ServerToolName = "knowledge_search" )
type ServerToolResult ¶
type ServerToolResult struct {
ImageProcess *ImageProcessResult `json:"image_process,omitempty" mapstructure:"image_process,omitempty"`
DoubaoApp *DoubaoAppResult `json:"doubao_app,omitempty" mapstructure:"doubao_app,omitempty"`
}
type ServiceTier ¶
type ServiceTier string
const ( ServiceTierAuto ServiceTier = "auto" ServiceTierDefault ServiceTier = "default" )
type StreamingResponseError ¶
type TextAnnotation ¶
type TextAnnotation struct {
Index int `json:"index,omitempty" mapstructure:"index,omitempty"`
Type TextAnnotationType `json:"type,omitempty" mapstructure:"type,omitempty"`
URLCitation *URLCitation `json:"url_citation,omitempty" mapstructure:"url_citation,omitempty"`
DocCitation *DocCitation `json:"doc_citation,omitempty" mapstructure:"doc_citation,omitempty"`
}
type TextAnnotationType ¶
type TextAnnotationType string
const ( TextAnnotationTypeURLCitation TextAnnotationType = "url_citation" TextAnnotationTypeDocCitation TextAnnotationType = "doc_citation" )
type ThinkingType ¶
type ThinkingType string
const ( ThinkingTypeAuto ThinkingType = "auto" ThinkingTypeEnabled ThinkingType = "enabled" ThinkingTypeDisabled ThinkingType = "disabled" )
type URLCitation ¶
type URLCitation struct {
Title string `json:"title,omitempty" mapstructure:"title,omitempty"`
URL string `json:"url,omitempty" mapstructure:"url,omitempty"`
LogoURL string `json:"logo_url,omitempty" mapstructure:"logo_url,omitempty"`
MobileURL string `json:"mobile_url,omitempty" mapstructure:"mobile_url,omitempty"`
SiteName string `json:"site_name,omitempty" mapstructure:"site_name,omitempty"`
PublishTime string `json:"publish_time,omitempty" mapstructure:"publish_time,omitempty"`
CoverImage *CoverImage `json:"cover_image,omitempty" mapstructure:"cover_image,omitempty"`
Summary string `json:"summary,omitempty" mapstructure:"summary,omitempty"`
FreshnessInfo string `json:"freshness_info,omitempty" mapstructure:"freshness_info,omitempty"`
}
type WebSearchAction ¶
type WebSearchAction string
const (
WebSearchActionSearch WebSearchAction = "search"
)
type WebSearchArguments ¶
type WebSearchArguments struct {
ActionType WebSearchAction `json:"action_type,omitempty" mapstructure:"action_type,omitempty"`
Search *WebSearchQuery `json:"search,omitempty" mapstructure:"search,omitempty"`
}
type WebSearchQuery ¶
type WebSearchQuery struct {
Query string `json:"query,omitempty" mapstructure:"query,omitempty"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
generate
command
|
|
|
prefix_cache
command
|
|
|
session_cache
command
|
|
|
stream_with_function_tool
command
* Copyright 2026 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2026 CloudWeGo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
|
stream_with_mcp_tool
command
|
|
|
stream_with_sever_tool
command
|