consts

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ComBaseURL = "https://api.coze.com"
	CnBaseURL                         = "https://api.coze.cn"
	DefaultOAuthRefreshTTL            = 900 * time.Second
	OAuthRefreshAdvanceTime           = 60 * time.Second
	DefaultPromptCacheMaxCount        = 100
	DefaultPromptCacheRefreshInterval = 1 * time.Minute
	DefaultTimeout                    = 3 * time.Second
	DefaultUploadTimeout              = 30 * time.Second
)

default values for loop client

View Source
const (
	LogIDHeader     = "x-tt-logid"
	AuthorizeHeader = "Authorization"
)
View Source
const (
	MaxTagKvCountInOneSpan = 50

	MaxBytesOfOneTagValueOfInputOutput = 1 * 1024 * 1024
	TextTruncateCharLength             = 1000

	MaxBytesOfOneTagValueDefault = 1024
	MaxBytesOfOneTagKeyDefault   = 1024
)

Define various boundary size.

View Source
const (
	Equal = "="
	Comma = ","
)
View Source
const (
	TraceContextHeaderParent  = "X-Cozeloop-Traceparent"
	TraceContextHeaderBaggage = "X-Cozeloop-Tracestate"
)

On the basis of W3C, the "loop" prefix is added to avoid conflicts with other traces that use W3C.

View Source
const (
	TracePromptHubSpanName              = "PromptHub"
	TracePromptTemplateSpanName         = "PromptTemplate"
	TracePromptExecuteSpanName          = "PromptExecute"
	TracePromptExecuteStreamingSpanName = "PromptExecuteStreaming"
)
View Source
const (
	PromptNormalTemplateStartTag = "{{"
	PromptNormalTemplateEndTag   = "}}"
)
View Source
const (
	UserID             = "user_id"
	MessageID          = "message_id"
	ThreadID           = "thread_id"
	StartTimeFirstResp = "start_time_first_resp"
	LatencyFirstResp   = "latency_first_resp"
	DeploymentEnv      = "deployment_env"

	CutOff = "cut_off"
)

System reserved tag fields.

View Source
const (
	GlobalTraceVersion = 0
)
View Source
const (
	StatusCodeErrorDefault int = -1
)

Variables

View Source
var (
	ErrInvalidParam  = NewError("invalid param")
	ErrInternal      = NewError("internal error")
	ErrRemoteService = NewError("remote service error")
	ErrClientClosed  = NewError("client already closed")

	ErrAuthInfoRequired = NewError("api token or jwt oauth info is required")
	ErrParsePrivateKey  = NewError("failed to parse private key")
	ErrHeaderParent     = NewError("header traceparent is illegal")
	ErrTemplateRender   = NewError("template render error")
)
View Source
var BaggageSpecialChars = []string{"=", ","}
View Source
var ReserveFieldTypes = map[string][]reflect.Type{
	UserID:                 {reflect.TypeOf(typeStr)},
	MessageID:              {reflect.TypeOf(typeStr)},
	ThreadID:               {reflect.TypeOf(typeStr)},
	tracespec.InputTokens:  {reflect.TypeOf(typeInt64), reflect.TypeOf(typeInt), reflect.TypeOf(typeInt32)},
	tracespec.OutputTokens: {reflect.TypeOf(typeInt64), reflect.TypeOf(typeInt), reflect.TypeOf(typeInt32)},
	tracespec.Tokens:       {reflect.TypeOf(typeInt64), reflect.TypeOf(typeInt), reflect.TypeOf(typeInt32)},
	StartTimeFirstResp:     {reflect.TypeOf(typeInt64), reflect.TypeOf(typeInt), reflect.TypeOf(typeInt32)},
	LatencyFirstResp:       {reflect.TypeOf(typeInt64), reflect.TypeOf(typeInt), reflect.TypeOf(typeInt32)},
}

ReserveFieldTypes Define the allowed types for each reserved field.

Functions

This section is empty.

Types

type AuthError

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

func NewAuthError

func NewAuthError(error *AuthErrorFormat, httpCode int, logID string) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

LoopError 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 AuthErrorFormat

type AuthErrorFormat struct {
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
	Error        string `json:"error"`
}

authErrorFormat represents the error response from Coze API

type FinishEventInfo added in v0.1.9

type FinishEventInfo struct {
	EventType   SpanFinishEvent
	IsEventFail bool
	ItemNum     int // maybe multiple span is processed in one event
	DetailMsg   string
	ExtraParams *FinishEventInfoExtra
}

type FinishEventInfoExtra added in v0.1.9

type FinishEventInfoExtra struct {
	IsRootSpan bool
	LatencyMs  int64
}

type LoopError

type LoopError struct {
	Msg string
	// contains filtered or unexported fields
}

func NewError

func NewError(msg string) *LoopError

func (*LoopError) Error

func (e *LoopError) Error() string

func (*LoopError) Unwrap

func (e *LoopError) Unwrap() error

func (*LoopError) Wrap

func (e *LoopError) Wrap(err error) *LoopError

type RemoteServiceError

type RemoteServiceError struct {
	HttpCode int
	ErrCode  int
	ErrMsg   string
	LogID    string
	// contains filtered or unexported fields
}

func NewRemoteServiceError

func NewRemoteServiceError(httpCode, errCode int, errMsg, logID string) *RemoteServiceError

func (*RemoteServiceError) Error

func (e *RemoteServiceError) Error() string

func (*RemoteServiceError) Unwrap

func (e *RemoteServiceError) Unwrap() error

func (*RemoteServiceError) Wrap

type SpanFinishEvent added in v0.1.9

type SpanFinishEvent string
const (
	SpanFinishEventSpanQueueEntryRate SpanFinishEvent = "queue_manager.span_entry.rate"
	SpanFinishEventFileQueueEntryRate SpanFinishEvent = "queue_manager.file_entry.rate"

	SpanFinishEventFlushSpanRate SpanFinishEvent = "exporter.span_flush.rate"
	SpanFinishEventFlushFileRate SpanFinishEvent = "exporter.file_flush.rate"
)

Jump to

Keyboard shortcuts

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