consts

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 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-Loop-Traceparent"
	TraceContextHeaderBaggage = "X-Loop-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"
)
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"

	CutOff = "cut_off"
)

System reserved tag fields.

View Source
const (
	GlobalTraceVersion = 1
)
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")
)
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 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

Jump to

Keyboard shortcuts

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