Documentation
¶
Index ¶
- Constants
- type ModelAudioURL
- type ModelCallOption
- type ModelChoice
- type ModelFileURL
- type ModelImageURL
- type ModelInput
- type ModelMessage
- type ModelMessagePart
- type ModelMessagePartType
- type ModelOutput
- type ModelTool
- type ModelToolCall
- type ModelToolCallFunction
- type ModelToolChoice
- type ModelToolFunction
- type ModelVideoURL
- type PromptArgument
- type PromptArgumentValueType
- type PromptInput
- type PromptOutput
- type RetrieverCallOption
- type RetrieverDocument
- type RetrieverInput
- type RetrieverOutput
- type Runtime
Constants ¶
const ( CallOptions = "call_options" // Used to identify option for model, like temperature, etc. Recommend use ModelCallOption struct. Stream = "stream" // Used to identify whether it is a streaming output. ReasoningTokens = "reasoning_tokens" // The token usage during the reasoning process. ReasoningDuration = "reasoning_duration" // The duration during the reasoning process. The unit is microseconds. )
Tags for model-type span.
const ( RetrieverProvider = "retriever_provider" // Data retrieval providers, such as Elasticsearch (ES), VikingDB, etc. VikingDBName = "vikingdb_name" // When using VikingDB to provide retrieval capabilities, db name. VikingDBRegion = "vikingdb_region" // When using VikingDB to provide retrieval capabilities, db region. ESName = "es_name" // When using ES to provide retrieval capabilities, es name. ESIndex = "es_index" // When using ES to provide retrieval capabilities, es index. ESCluster = "es_cluster" // When using ES to provide retrieval capabilities, es cluster. )
Tags for retriever-type span
const ( PromptProvider = "prompt_provider" // Prompt providers, such as CozeLoop, Langsmith, etc. PromptKey = "prompt_key" PromptVersion = "prompt_version" PromptLabel = "prompt_label" )
Tags for prompt-type span.
const ( SpanType = "span_type" Input = "input" Output = "output" Error = "error" Runtime_ = "runtime" ModelProvider = "model_provider" ModelName = "model_name" InputTokens = "input_tokens" InputCachedTokens = "input_cached_tokens" OutputTokens = "output_tokens" Tokens = "tokens" ModelPlatform = "model_platform" ModelIdentification = "model_identification" TokenUsageBackup = "token_usage_backup" LatencyFirstResp = "latency_first_resp" CallType = "call_type" LogID = "log_id" TraceID = "trace_id" )
Internal experimental field. Not recommended for use unless you know what you're doing. Instead, use the corresponding Set method.
const ( VPromptHubSpanType = "prompt_hub" VPromptTemplateSpanType = "prompt" VPromptExecuteSpanType = "prompt_execute" VPromptExecuteStreamingSpanType = "prompt_execute_streaming" VModelSpanType = "model" VRetrieverSpanType = "retriever" VToolSpanType = "tool" )
SpanType tag builtin values
const ( VRoleUser = "user" VRoleSystem = "system" VRoleAssistant = "assistant" VRoleTool = "tool" // VToolChoiceNone Reference: https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages VToolChoiceNone = "none" // Means the model will not call any tool and instead generates a message. VToolChoiceAuto = "auto" // Means the model can pick between generating a message or calling one or more tools. VToolChoiceRequired = "required" // Means the model must call one or more tools. VToolChoiceFunction = "function" // Forces the model to call that tool. )
Tag values for model messages.
const ( VLangGo = "go" VLangPython = "python" VLangTypeScript = "ts" VLibEino = "eino" VLibLangChain = "langchain" VLibOpentelemetry = "opentelemetry" VSceneCustom = "custom" // user custom, it has the same meaning as blank. VScenePromptHub = "prompt_hub" // get_prompt VScenePromptTemplate = "prompt_template" // prompt_template VScenePromptExecute = "prompt_execute" // execute_prompt VScenePromptExecuteStreaming = "prompt_execute_streaming" // execute_prompt_streaming VSceneIntegration = "integration" )
Tag values for runtime tags.
const ( VPromptArgSourceInput = "input" VPromptArgSourcePartial = "partial" )
Tag values for prompt input.
const (
ToolCallID = "tool_call_id"
)
Tags for tool-type span.
const (
VErrDefault = -1 // Default StatusCode for errors.
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ModelAudioURL ¶ added in v0.1.8
type ModelCallOption ¶
type ModelCallOption struct {
Temperature float32 `json:"temperature"`
MaxTokens int64 `json:"max_tokens,omitempty"`
Stop []string `json:"stop,omitempty"`
TopP float32 `json:"top_p,omitempty"`
N int64 `json:"n,omitempty"`
TopK *int64 `json:"top_k,omitempty"`
PresencePenalty *float32 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float32 `json:"frequency_penalty,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
}
ModelCallOption is the option for model span, for tag key: call_options
type ModelChoice ¶
type ModelChoice struct {
FinishReason string `json:"finish_reason"`
Index int64 `json:"index"`
Message *ModelMessage `json:"message"`
}
type ModelFileURL ¶
type ModelFileURL struct {
Name string `json:"name,omitempty"`
// Required. You can enter a valid file URL or MDN Base64 data of file.
// MDN: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data#syntax
URL string `json:"url,omitempty"`
Detail string `json:"detail,omitempty"`
Suffix string `json:"suffix,omitempty"`
}
type ModelImageURL ¶
type ModelImageURL struct {
Name string `json:"name,omitempty"`
// Required. You can enter a valid image URL or MDN Base64 data of image.
// MDN: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data#syntax
URL string `json:"url,omitempty"`
Detail string `json:"detail,omitempty"`
}
type ModelInput ¶
type ModelInput struct {
Messages []*ModelMessage `json:"messages,omitempty"`
Tools []*ModelTool `json:"tools,omitempty"`
ModelToolChoice *ModelToolChoice `json:"tool_choice,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
}
ModelInput is the input for model span, for tag key: input
type ModelMessage ¶
type ModelMessage struct {
Role string `json:"role"` // from enum VRole in span_value
Content string `json:"content,omitempty"` // single content
ReasoningContent string `json:"reasoning_content,omitempty"` // only for output
Parts []*ModelMessagePart `json:"parts,omitempty"` // multi-modality content
Name string `json:"name,omitempty"`
ToolCalls []*ModelToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Signature string `json:"signature,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
type ModelMessagePart ¶
type ModelMessagePart struct {
Type ModelMessagePartType `json:"type"` // Required. The type of the content.
Text string `json:"text,omitempty"`
ImageURL *ModelImageURL `json:"image_url,omitempty"`
FileURL *ModelFileURL `json:"file_url,omitempty"`
AudioURL *ModelAudioURL `json:"audio_url,omitempty"`
VideoURL *ModelVideoURL `json:"video_url,omitempty"`
Signature string `json:"signature,omitempty"`
}
type ModelMessagePartType ¶
type ModelMessagePartType string
var ( ModelMessagePartTypeText ModelMessagePartType = "text" ModelMessagePartTypeImage ModelMessagePartType = "image_url" ModelMessagePartTypeFile ModelMessagePartType = "file_url" ModelMessagePartTypeAudio ModelMessagePartType = "audio_url" ModelMessagePartTypeVideo ModelMessagePartType = "video_url" )
type ModelOutput ¶
type ModelOutput struct {
ID string `json:"id,omitempty"`
Choices []*ModelChoice `json:"choices"`
}
ModelOutput is the output for model span, for tag key: output
type ModelTool ¶
type ModelTool struct {
Type string `json:"type"` // Always be: "function"
Function *ModelToolFunction `json:"function"`
}
type ModelToolCall ¶
type ModelToolCall struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"` // Always be: "function"
Function *ModelToolCallFunction `json:"function"`
Signature string `json:"signature,omitempty"`
}
type ModelToolCallFunction ¶
type ModelToolChoice ¶
type ModelToolChoice struct {
Type string `json:"type"` // from enum VToolChoice in span_value
Function *ModelToolCallFunction `json:"function,omitempty"` // field name only.
}
type ModelToolFunction ¶
type ModelToolFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters"`
}
type ModelVideoURL ¶ added in v0.1.8
type PromptArgument ¶
type PromptArgument struct {
Key string `json:"key"`
Value any `json:"value"`
Source string `json:"source"` // from enum VPromptArgSource in span_value.go
ValueType PromptArgumentValueType `json:"value_type"`
}
type PromptArgumentValueType ¶ added in v0.1.3
type PromptArgumentValueType string
var ( PromptArgumentValueTypeText PromptArgumentValueType = "text" PromptArgumentValueTypeModelMessage PromptArgumentValueType = "model_message" PromptArgumentValueTypeMessagePart PromptArgumentValueType = "model_message_part" )
type PromptInput ¶
type PromptInput struct {
Templates []*ModelMessage `json:"templates"`
Arguments []*PromptArgument `json:"arguments"`
}
PromptInput is the input of prompt span, for tag key: input
type PromptOutput ¶
type PromptOutput struct {
Prompts []*ModelMessage `json:"prompts"`
}
PromptOutput is the output of prompt span, for tag key: output
type RetrieverCallOption ¶
type RetrieverDocument ¶
type RetrieverInput ¶
type RetrieverInput struct {
Query string `json:"query,omitempty"`
}
type RetrieverOutput ¶
type RetrieverOutput struct {
Documents []*RetrieverDocument `json:"documents,omitempty"`
}
type Runtime ¶
type Runtime struct {
Language string `json:"language"` // from enum VLang in span_value.go
Library string `json:"library,omitempty"` // integration library, from enum VLib in span_value.go
Scene string `json:"scene,omitempty"` // usage scene, from enum VScene in span_value.go
SceneVersion string `json:"scene_version,omitempty"`
// Dependency Versions.
LibraryVersion string `json:"library_version,omitempty"`
LoopSDKVersion string `json:"loop_sdk_version,omitempty"`
// Extra info.
Extra map[string]interface{} `json:"extra,omitempty"`
}