tracespec

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
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.

View Source
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

View Source
const (
	PromptProvider = "prompt_provider" // Prompt providers, such as CozeLoop, Langsmith, etc.
	PromptKey      = "prompt_key"
	PromptVersion  = "prompt_version"
)

Tags for prompt-type span.

View Source
const (
	SpanType = "span_type"
	Input    = "input"
	Output   = "output"
	Error    = "error"
	Runtime_ = "runtime"

	ModelProvider       = "model_provider"
	ModelName           = "model_name"
	InputTokens         = "input_tokens"
	OutputTokens        = "output_tokens"
	Tokens              = "tokens"
	ModelPlatform       = "model_platform"
	ModelIdentification = "model_identification"
	TokenUsageBackup    = "token_usage_backup"
	LatencyFirstResp    = "latency_first_resp"
)

Internal experimental field. Not recommended for use unless you know what you're doing. Instead, use the corresponding Set method.

View Source
const (
	VPromptHubSpanType      = "prompt_hub"
	VPromptTemplateSpanType = "prompt"
	VModelSpanType          = "model"
	VRetrieverSpanType      = "retriever"
	VToolSpanType           = "tool"
)

SpanType tag builtin values

View Source
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.

View Source
const (
	VLangGo         = "go"
	VLangPython     = "python"
	VLangTypeScript = "ts"

	VLibEino      = "eino"
	VLibLangChain = "langchain"

	VSceneCustom         = "custom"          // user custom, it has the same meaning as blank.
	VScenePromptHub      = "prompt_hub"      // get_prompt
	VScenePromptTemplate = "prompt_template" // prompt_template
	VSceneIntegration    = "integration"
)

Tag values for runtime tags.

View Source
const (
	VPromptArgSourceInput   = "input"
	VPromptArgSourcePartial = "partial"
)

Tag values for prompt input.

View Source
const (
	VErrDefault = -1 // Default StatusCode for errors.
)

Variables

This section is empty.

Functions

This section is empty.

Types

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"`
}

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"`
	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"`
}

type ModelMessagePartType

type ModelMessagePartType string
var (
	ModelMessagePartTypeText  ModelMessagePartType = "text"
	ModelMessagePartTypeImage ModelMessagePartType = "image_url"
	ModelMessagePartTypeFile  ModelMessagePartType = "file_url"
)

type ModelOutput

type ModelOutput struct {
	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"`
}

type ModelToolCallFunction

type ModelToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments,omitempty"`
}

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 PromptArgument

type PromptArgument struct {
	Key    string `json:"key"`
	Value  any    `json:"value"`
	Source string `json:"source"` // from enum VPromptArgSource in span_value.go
}

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 RetrieverCallOption struct {
	TopK     int64    `json:"top_k,omitempty"`
	MinScore *float64 `json:"min_score,omitempty"`
	Filter   string   `json:"filter,omitempty"`
}

type RetrieverDocument

type RetrieverDocument struct {
	ID      string    `json:"id,omitempty"`
	Index   string    `json:"index,omitempty"`
	Content string    `json:"content"`
	Vector  []float64 `json:"vector,omitempty"`
	Score   float64   `json:"score"`
}

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

	// Dependency Versions.
	LibraryVersion string `json:"library_version,omitempty"`
	LoopSDKVersion string `json:"loop_sdk_version,omitempty"`
}

Jump to

Keyboard shortcuts

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