Documentation
¶
Index ¶
- Constants
- Variables
- func Compare[T cmp.Ordered](val T, values []T, qType QueryTypeEnum) bool
- func CompareBool(val bool, values []bool, qType QueryTypeEnum) bool
- func SizeOfString(s string) int
- func SizeofSpans(spans SpanList) int
- type AgentStep
- type Annotation
- func (a *Annotation) CorrectAutoEvaluateScore(score float64, reasoning string, updateBy string)
- func (a *Annotation) GenID() error
- func (a *Annotation) GetAutoEvaluateMetadata() *AutoEvaluateMetadata
- func (a *Annotation) GetDatasetMetadata() *ManualDatasetMetadata
- func (a *Annotation) ToFornaxAnnotation(ctx context.Context) (fa *annotation.Annotation)
- type AnnotationCorrection
- type AnnotationCorrectionType
- type AnnotationList
- type AnnotationManualFeedback
- type AnnotationStatus
- type AnnotationType
- type AnnotationValue
- type AnnotationValueType
- type Attachment
- type AttrTos
- type AutoEvaluateMetadata
- type BasicInfo
- type Error
- type Field
- type FieldOptions
- type FieldType
- type FilterField
- type FilterFields
- type FilterObject
- type InputFilter
- type ManualDatasetMetadata
- type MetricsInfo
- type ModelInfo
- type ObjectStorage
- type OutputFilter
- type PlatformType
- type QueryAndOrEnum
- type QueryTypeEnum
- type RootStep
- type Span
- func (s *Span) AddAnnotation(annotation *Annotation)
- func (s *Span) AddAutoEvalAnnotation(taskID, evaluatorRecordID, evaluatorVersionID int64, score float64, ...) (*Annotation, error)
- func (s *Span) AddManualDatasetAnnotation(datasetID int64, userID string, annotationType AnnotationType) (*Annotation, error)
- func (s *Span) BuildFeedback(t AnnotationType, key string, value AnnotationValue, reasoning, userID string, ...) (*Annotation, error)
- func (s *Span) ClipSpan()
- func (s *Span) ExtractByJsonpath(ctx context.Context, key string, jsonpath string) (string, error)
- func (s *Span) GetCustomTags() map[string]string
- func (s *Span) GetFieldValue(fieldName string, isSystem, isCustom bool) any
- func (s *Span) GetSystemTags() map[string]string
- func (s *Span) GetTTL(ctx context.Context) TTL
- func (s *Span) GetTenant() string
- func (s *Span) IsModelSpan() bool
- func (s *Span) IsResponseAPISpan() bool
- func (s *Span) IsValidSpan() error
- func (s *Span) MergeHistoryContext(ctx context.Context, historySpans []*Span)
- type SpanList
- func (s SpanList) FilterSpans(f *FilterFields) SpanList
- func (s SpanList) GetAnnotationTagIDs() []string
- func (s SpanList) GetEvaluatorVersionIDs() []int64
- func (s SpanList) GetUserIDs() []string
- func (s SpanList) SetAnnotations(annotations AnnotationList)
- func (s SpanList) SortByStartTime(desc bool)
- func (s SpanList) Stat(ctx context.Context) (inputTokens, outputTokens int64, err error)
- func (s SpanList) Uniq() SpanList
- type SpanListType
- type SpanTransCfgList
- type SpanTransConfig
- type Step
- type StepType
- type StringWrapper
- type Struct
- type TTL
- type Tag
- type TagFilter
- type TagValue
- type TagValueType
- type TraceAdvanceInfo
- type Trajectory
- type TrajectoryList
Constants ¶
View Source
const ( AnnotationValueTypeCategory AnnotationValueType = "category" // 等于string AnnotationValueTypeString AnnotationValueType = "string" AnnotationValueTypeLong AnnotationValueType = "long" AnnotationValueTypeNumber AnnotationValueType = "number" // 等于float AnnotationValueTypeDouble AnnotationValueType = "double" AnnotationValueTypeBool AnnotationValueType = "bool" AnnotationStatusNormal AnnotationStatus = "normal" AnnotationStatusInactive AnnotationStatus = "inactive" AnnotationStatusDeleted AnnotationStatus = "deleted" AnnotationCorrectionTypeLLM AnnotationCorrectionType = "llm" AnnotationCorrectionTypeManual AnnotationCorrectionType = "manual" AnnotationTypeAutoEvaluate AnnotationType = "auto_evaluate" AnnotationTypeManualEvaluationSet AnnotationType = "manual_evaluation_set" AnnotationTypeManualFeedback AnnotationType = "manual_feedback" AnnotationTypeCozeFeedback AnnotationType = "coze_feedback" AnnotationTypeManualDataset AnnotationType = "manual_dataset" AnnotationTypeOpenAPIFeedback AnnotationType = "openapi_feedback" AnnotationOpenAPIFeedbackFieldPrefix = "feedback_openapi_" AnnotationManualFeedbackFieldPrefix = "manual_feedback_" )
View Source
const ( QueryTypeEnumMatch QueryTypeEnum = "match" QueryTypeEnumNotMatch QueryTypeEnum = "not_match" QueryTypeEnumEq QueryTypeEnum = "eq" QueryTypeEnumNotEq QueryTypeEnum = "not_eq" QueryTypeEnumLte QueryTypeEnum = "lte" QueryTypeEnumGte QueryTypeEnum = "gte" QueryTypeEnumLt QueryTypeEnum = "lt" QueryTypeEnumGt QueryTypeEnum = "gt" QueryTypeEnumExist QueryTypeEnum = "exist" QueryTypeEnumNotExist QueryTypeEnum = "not_exist" QueryTypeEnumIn QueryTypeEnum = "in" QueryTypeEnumNotIn QueryTypeEnum = "not_in" QueryTypeEnumAlwaysTrue QueryTypeEnum = "always_true" // 永远为真的条件, 为了保持语意一致还是需要放入SQL QueryAndOrEnumAnd QueryAndOrEnum = "and" QueryAndOrEnumOr QueryAndOrEnum = "or" FieldTypeString FieldType = "string" FieldTypeLong FieldType = "long" FieldTypeDouble FieldType = "double" FieldTypeBool FieldType = "bool" PlatformDefault PlatformType = "default" PlatformCozeLoop PlatformType = "cozeloop" PlatformPrompt PlatformType = "prompt" PlatformEvaluator PlatformType = "evaluator" PlatformEvalTarget PlatformType = "evaluation_target" PlatformOpenAPI PlatformType = "open_api" PlatformCozeWorkflow PlatformType = "coze_workflow" PlatformCozeBot PlatformType = "coze_bot" PlatformVeAgentKit PlatformType = "ve_agentkit" PlatformVeADK PlatformType = "veadk" PlatformCallbackAll PlatformType = "callback_all" SpanListTypeRootSpan SpanListType = "root_span" SpanListTypeAllSpan SpanListType = "all_span" SpanListTypeLLMSpan SpanListType = "llm_span" )
View Source
const ( SpanFieldStartTime = "start_time" SpanFieldSpanId = "span_id" SpanFieldSpanName = "span_name" SpanFieldTraceId = "trace_id" SpanFieldSpaceId = "space_id" SpanFieldParentID = "parent_id" SpanFieldSpanType = "span_type" SpanFieldCallType = "call_type" SpanFieldPSM = "psm" SpanFieldLogID = "logid" SpanFieldInput = "input" SpanFieldOutput = "output" SpanFieldMethod = "method" SpanFieldModelProvider = "model_provider" SpanFieldInputTokens = "input_tokens" SpanFieldOutputTokens = "output_tokens" SpanFieldTokens = "tokens" SpanFieldStatus = "status" SpanFieldStatusCode = "status_code" SpanFieldDuration = "duration" SpanFieldObjectStorage = "object_storage" SpanFieldStartTimeFirstResp = "start_time_first_resp" SpanFieldLatencyFirstResp = "latency_first_resp" SpanFieldStartTimeFirstTokenResp = "start_time_first_token_resp" SpanFieldLatencyFirstTokenResp = "latency_first_token_resp" SpanFieldReasoningDuration = "reasoning_duration" SpanFieldLogicDeleteDate = "logic_delete_date" SpanFieldMessageID = "message_id" SpanFieldUserID = "user_id" SpanFieldPromptKey = "prompt_key" SpanFieldTenant = "tenant" SpanFieldKeyPreviousResponseID = "previous_response_id" SpanFieldKeyResponseID = "response_id" SpanTypePrompt = "prompt" SpanTypeModel = "model" SpanTypeParser = "parser" SpanTypeEmbedding = "embedding" SpanTypeMemory = "memory" SpanTypePlugin = "plugin" SpanTypeFunction = "function" SpanTypeGraph = "graph" SpanTypeRemote = "remote" SpanTypeLoader = "loader" SpanTypeTransformer = "transformer" SpanTypeVectorStore = "vector_store" SpanTypeVectorRetriever = "vector_retriever" SpanTypeAgent = "agent" SpanTypeLLMCall = "LLMCall" SpanStatusSuccess = "success" SpanStatusError = "error" MaxTagLength = 50 MaxKeySize = 100 MaxTextSize = 1024 * 1024 MaxCommonValueSize = 1024 CallTypeEvaluator = "Evaluator" )
View Source
const TagNameJson = "json"
Variables ¶
Functions ¶
func CompareBool ¶
func CompareBool(val bool, values []bool, qType QueryTypeEnum) bool
func SizeOfString ¶
func SizeofSpans ¶
Types ¶
type AgentStep ¶
type AgentStep struct {
// 基础属性
ID *string `json:"id,omitempty"`
// 父ID, trace导入时取parent_span_id
ParentID *string `json:"parent_id,omitempty"`
// name,trace导入时取span_name
Name *string `json:"name,omitempty"`
// 输入
Input *string `json:"input,omitempty"`
// 输出
Output *string `json:"output,omitempty"`
// 子节点,agent执行内部经历了哪些步骤
Steps []*Step `json:"steps"`
// 系统属性
Metadata map[string]string `json:"metadata,omitempty"`
BasicInfo *BasicInfo `json:"basic_info,omitempty"`
MetricsInfo *MetricsInfo `json:"metrics_info,omitempty"`
}
type Annotation ¶
type Annotation struct {
ID string
SpanID string
TraceID string
StartTime time.Time // start time of span
WorkspaceID string
AnnotationType AnnotationType
AnnotationIndex []string
Key string
Value AnnotationValue
Reasoning string
Corrections []AnnotationCorrection
Metadata any
Status AnnotationStatus
CreatedAt time.Time
CreatedBy string
UpdatedAt time.Time
UpdatedBy string
IsDeleted bool
}
func (*Annotation) CorrectAutoEvaluateScore ¶
func (a *Annotation) CorrectAutoEvaluateScore(score float64, reasoning string, updateBy string)
func (*Annotation) GenID ¶
func (a *Annotation) GenID() error
func (*Annotation) GetAutoEvaluateMetadata ¶
func (a *Annotation) GetAutoEvaluateMetadata() *AutoEvaluateMetadata
func (*Annotation) GetDatasetMetadata ¶
func (a *Annotation) GetDatasetMetadata() *ManualDatasetMetadata
func (*Annotation) ToFornaxAnnotation ¶
func (a *Annotation) ToFornaxAnnotation(ctx context.Context) (fa *annotation.Annotation)
type AnnotationCorrection ¶
type AnnotationCorrection struct {
Reasoning string `json:"reasoning,omitempty"`
Value AnnotationValue `json:"value"`
Type AnnotationCorrectionType `json:"type"`
UpdateAt time.Time `json:"update_at"`
UpdatedBy string `json:"updated_by"`
}
type AnnotationCorrectionType ¶
type AnnotationCorrectionType string
type AnnotationList ¶
type AnnotationList []*Annotation
func (AnnotationList) FindByEvaluatorRecordID ¶
func (a AnnotationList) FindByEvaluatorRecordID(evaluatorRecordID int64) (*Annotation, bool)
func (AnnotationList) GetAnnotationTagIDs ¶
func (a AnnotationList) GetAnnotationTagIDs() []string
func (AnnotationList) GetEvaluatorVersionIDs ¶
func (a AnnotationList) GetEvaluatorVersionIDs() []int64
func (AnnotationList) GetUserIDs ¶
func (a AnnotationList) GetUserIDs() []string
func (AnnotationList) Uniq ¶
func (a AnnotationList) Uniq() AnnotationList
type AnnotationStatus ¶
type AnnotationStatus string
type AnnotationType ¶
type AnnotationType string
type AnnotationValue ¶
type AnnotationValue struct {
ValueType AnnotationValueType `json:"value_type,omitempty"` // 类型
LongValue int64 `json:"long_value,omitempty"`
StringValue string `json:"string_value,omitempty"`
FloatValue float64 `json:"float_value,omitempty"`
BoolValue bool `json:"bool_value,omitempty"`
}
func NewBoolValue ¶
func NewBoolValue(v bool) AnnotationValue
func NewDoubleValue ¶
func NewDoubleValue(v float64) AnnotationValue
func NewLongValue ¶
func NewLongValue(v int64) AnnotationValue
func NewStringValue ¶
func NewStringValue(v string) AnnotationValue
type AnnotationValueType ¶
type AnnotationValueType string
type Attachment ¶
type AutoEvaluateMetadata ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) ValueType ¶
func (p *Field) ValueType() (TagValueType, error)
type FieldOptions ¶
type FilterField ¶
type FilterField struct {
FieldName string `mapstructure:"field_name" json:"field_name"`
FieldType FieldType `mapstructure:"field_type" json:"field_type"`
Values []string `mapstructure:"values" json:"values"`
QueryType *QueryTypeEnum `mapstructure:"query_type" json:"query_type"`
QueryAndOr *QueryAndOrEnum `mapstructure:"query_and_or" json:"query_and_or"`
SubFilter *FilterFields `mapstructure:"sub_filter" json:"sub_filter"`
IsSystem bool `mapstructure:"is_system" json:"is_system"`
IsCustom bool `mapstructure:"is_custom" json:"is_custom"`
Hidden bool `mapstructure:"hidden" json:"hidden"`
ExtraInfo map[string]string `mapstructure:"extra_info" json:"extra_info"`
}
func (*FilterField) CheckValue ¶
func (f *FilterField) CheckValue(val any) bool
当前支持特定类型, 满足可用性和可拓展性
func (*FilterField) Satisfied ¶
func (f *FilterField) Satisfied(obj FilterObject) bool
func (*FilterField) SetHidden ¶
func (f *FilterField) SetHidden(hidden bool)
func (*FilterField) Validate ¶
func (f *FilterField) Validate() error
func (*FilterField) ValidateField ¶
func (f *FilterField) ValidateField() error
type FilterFields ¶
type FilterFields struct {
QueryAndOr *QueryAndOrEnum `mapstructure:"query_and_or" json:"query_and_or"`
FilterFields []*FilterField `mapstructure:"filter_fields" json:"filter_fields"`
}
func CombineFilters ¶
func CombineFilters(filters ...*FilterFields) *FilterFields
func GetModelSpansFilter ¶
func GetModelSpansFilter() *FilterFields
func (*FilterFields) Debug ¶
func (f *FilterFields) Debug() string
func (*FilterFields) Satisfied ¶
func (f *FilterFields) Satisfied(obj FilterObject) bool
func (*FilterFields) Traverse ¶
func (f *FilterFields) Traverse(fn func(f *FilterField) error) error
func (*FilterFields) Validate ¶
func (f *FilterFields) Validate() error
type FilterObject ¶
type InputFilter ¶
type InputFilter struct {
KeyWhiteList []string `mapstructure:"key_white_list" json:"key_white_list"`
// contains filtered or unexported fields
}
type ManualDatasetMetadata ¶
type ManualDatasetMetadata struct{}
type MetricsInfo ¶
type MetricsInfo struct {
// 单位毫秒
LlmDuration *string `json:"llm_duration,omitempty"`
// 单位毫秒
ToolDuration *string `json:"tool_duration,omitempty"`
// Tool错误分布,格式为:错误码-->list<ToolStepID>
ToolErrors map[int32][]string `json:"tool_errors,omitempty"`
// Tool错误率
ToolErrorRate *float64 `json:"tool_error_rate,omitempty"`
// Model错误分布,格式为:错误码-->list<ModelStepID>
ModelErrors map[int32][]string `json:"model_errors,omitempty"`
// Model错误率
ModelErrorRate *float64 `json:"model_error_rate,omitempty"`
// Tool Step占比(分母是总子Step)
ToolStepProportion *float64 `json:"tool_step_proportion,omitempty"`
// 输入token数
InputTokens *int32 `json:"input_tokens,omitempty"`
// 输出token数
OutputTokens *int32 `json:"output_tokens,omitempty"`
}
type ModelInfo ¶
type ModelInfo struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
LatencyFirstResp string `json:"latency_first_resp"` // 单位毫秒
ReasoningTokens int64 `json:"reasoning_tokens"`
InputReadCachedTokens int64 `json:"input_read_cached_tokens"`
InputCreationCachedTokens int64 `json:"input_creation_cached_tokens"`
}
type ObjectStorage ¶
type ObjectStorage struct {
InputTosKey string `json:"input_tos_key"`
OutputTosKey string `json:"output_tos_key"`
Attachments []*Attachment `json:"Attachments"`
}
type OutputFilter ¶
type OutputFilter struct {
KeyWhiteList []string `mapstructure:"key_white_list" json:"key_white_list"`
// contains filtered or unexported fields
}
type PlatformType ¶
type PlatformType string
type QueryAndOrEnum ¶
type QueryAndOrEnum string
type QueryTypeEnum ¶
type QueryTypeEnum string
type RootStep ¶
type RootStep struct {
// 唯一ID,trace导入时取span_id
ID *string `json:"id,omitempty"`
// name,trace导入时取span_name
Name *string `json:"name,omitempty"`
// 输入
Input *string `json:"input,omitempty"`
// 输出
Output *string `json:"output,omitempty"`
// 系统属性
Metadata map[string]string `json:"metadata,omitempty"`
BasicInfo *BasicInfo `json:"basic_info,omitempty"`
MetricsInfo *MetricsInfo `json:"metrics_info,omitempty"`
}
type Span ¶
type Span struct {
StartTime int64 `json:"start_time"` // us
SpanID string `json:"span_id"`
ParentID string `json:"parent_id"`
TraceID string `json:"trace_id"`
DurationMicros int64 `json:"duration_micros"` // us
CallType string `json:"call_type"`
PSM string `json:"psm"`
LogID string `json:"log_id"`
WorkspaceID string `json:"space_id"`
SpanName string `json:"span_name"`
SpanType string `json:"span_type"`
Method string `json:"method"`
StatusCode int32 `json:"status_code"`
Input string `json:"input"`
Output string `json:"output"`
ObjectStorage string `json:"object_storage"`
SystemTagsString map[string]string `json:"system_tags_string"`
SystemTagsLong map[string]int64 `json:"system_tags_long"`
SystemTagsDouble map[string]float64 `json:"system_tags_double"`
TagsString map[string]string `json:"tags_string"`
TagsLong map[string]int64 `json:"tags_long"`
TagsDouble map[string]float64 `json:"tags_double"`
TagsBool map[string]bool `json:"tags_bool"`
TagsByte map[string]string `json:"tags_byte"`
AttrTos *AttrTos `json:"-"`
LogicDeleteTime int64 `json:"-"` // us
Annotations AnnotationList `json:"-"`
}
func (*Span) AddAnnotation ¶
func (s *Span) AddAnnotation(annotation *Annotation)
func (*Span) AddAutoEvalAnnotation ¶
func (*Span) AddManualDatasetAnnotation ¶
func (s *Span) AddManualDatasetAnnotation(datasetID int64, userID string, annotationType AnnotationType) (*Annotation, error)
func (*Span) BuildFeedback ¶
func (s *Span) BuildFeedback(t AnnotationType, key string, value AnnotationValue, reasoning, userID string, deleted bool) (*Annotation, error)
func (*Span) ExtractByJsonpath ¶
ExtractByJsonpath 从Span的Input/Output/Tags中提取数据,根据jsonpath返回结果。时间戳按毫秒返回。
func (*Span) GetCustomTags ¶
func (*Span) GetFieldValue ¶
filter使用, 当前只支持特定参数,后续有需要可拓展到其他参数
func (*Span) GetSystemTags ¶
func (*Span) IsModelSpan ¶
func (*Span) IsResponseAPISpan ¶
func (*Span) IsValidSpan ¶
type SpanList ¶
type SpanList []*Span
func (SpanList) FilterSpans ¶
func (s SpanList) FilterSpans(f *FilterFields) SpanList
func (SpanList) GetAnnotationTagIDs ¶
func (SpanList) GetEvaluatorVersionIDs ¶
func (SpanList) GetUserIDs ¶
func (SpanList) SetAnnotations ¶
func (s SpanList) SetAnnotations(annotations AnnotationList)
func (SpanList) SortByStartTime ¶
type SpanListType ¶
type SpanListType string
type SpanTransCfgList ¶
type SpanTransCfgList []*SpanTransConfig
span trans handler config
{
"platform_cfg": {
"cozeloop": [
{
"span_filter": {
"query_and_or": 1,
"filter_fields": []
},
"is_filter_tag": true,
"tag_key_black_list": ["a"]
}
],
"prompt": {}
}
}
type SpanTransConfig ¶
type SpanTransConfig struct {
SpanFilter *FilterFields `mapstructure:"span_filter" json:"span_filter"`
TagFilter *TagFilter `mapstructure:"tag_filter" json:"tag_filter"`
InputFilter *InputFilter `mapstructure:"input_filter" json:"input_filter"`
OutputFilter *OutputFilter `mapstructure:"output_filter" json:"output_filter"`
// contains filtered or unexported fields
}
type Step ¶
type Step struct {
// 基础属性
ID *string `json:"id,omitempty"`
// 父ID, trace导入时取parent_span_id
ParentID *string `json:"parent_id,omitempty"`
// 类型
Type *StepType `json:"type,omitempty"`
// name,trace导入时取span_name
Name *string `json:"name,omitempty"`
// 输入
Input *string `json:"input,omitempty"`
// 输出
Output *string `json:"output,omitempty"`
// 各种类型补充信息
ModelInfo *ModelInfo `json:"model_info,omitempty"`
// 系统属性
Metadata map[string]string `json:"metadata,omitempty"`
BasicInfo *BasicInfo `json:"basic_info,omitempty"`
}
type StringWrapper ¶
type Tag ¶
type Tag struct {
ValueType TagValueType
Key string
Value *TagValue
}
func NewBoolTag ¶
func NewDoubleTag ¶
func NewLongTag ¶
func NewStringTag ¶
func (Tag) GetStringValue ¶
func (Tag) GetTagType ¶
func (t Tag) GetTagType() TagValueType
func (Tag) IsSetValue ¶
type TagFilter ¶
type TagFilter struct {
KeyBlackList []string `mapstructure:"key_black_list" json:"key_black_list"`
// contains filtered or unexported fields
}
type TagValueType ¶
type TagValueType int
const ( TagValueTypeUnknown TagValueType = 1 TagValueTypeBool TagValueType = 2 TagValueTypeInt64 TagValueType = 3 TagValueTypeFloat64 TagValueType = 4 TagValueTypeString TagValueType = 5 )
func (TagValueType) String ¶
func (p TagValueType) String() string
type TraceAdvanceInfo ¶
type Trajectory ¶
type Trajectory struct {
// trace_id
ID *string `json:"id,omitempty"`
// 根节点,记录整个轨迹的信息
RootStep *RootStep `json:"root_step,omitempty"`
// agent step列表,记录轨迹中agent执行信息
AgentSteps []*AgentStep `json:"agent_steps"`
}
func BuildTrajectoryFromSpans ¶
func BuildTrajectoryFromSpans(spanList SpanList) *Trajectory
func (*Trajectory) MarshalString ¶
func (t *Trajectory) MarshalString() (string, error)
type TrajectoryList ¶
type TrajectoryList []*Trajectory
Click to show internal directories.
Click to hide internal directories.