Documentation
¶
Overview ¶
Package objects contains some objects need used by schema and biz. To avoid circular dependencies, we put them here. NOTE: there are some history issue, the json tag is not consistent. To reduce the maintenance cost, we keep the json tag as it is. For the new objects, we will use the same json tag, just use the camel case.
Index ¶
- Constants
- func ConvertGUIDPtrToInt(guid *GUID) (int, error)
- func ConvertGUIDPtrToIntPtr(guid *GUID) (*int, error)
- func ConvertGUIDPtrsToIntPtrs(guid []*GUID) ([]*int, error)
- func ConvertGUIDPtrsToInts(guid []*GUID) ([]int, error)
- func ConvertGUIDToInt(guid GUID) (int, error)
- func ConvertGUIDToIntPtr(guid GUID) (*int, error)
- func Evaluate(condition Condition, data any) bool
- func IntGuids(guids []*GUID) []int
- func MarshalDecimal(d decimal.Decimal) graphql.Marshaler
- func MatchChannelTags(allowedTags []string, matchMode ChannelTagsMatchMode, channelTags []string) bool
- func SerializeOverrideOperations(ops []OverrideOperation) (string, error)
- func ToExpr(condition Condition) (string, error)
- func UnmarshalDecimal(v any) (decimal.Decimal, error)
- type APIKeyProfile
- type APIKeyProfiles
- type APIKeyQuota
- type APIKeyQuotaCalendarDuration
- type APIKeyQuotaCalendarDurationUnit
- type APIKeyQuotaPastDuration
- type APIKeyQuotaPastDurationUnit
- type APIKeyQuotaPeriod
- type APIKeyQuotaPeriodType
- type AzureCredential
- type CapabilityPolicy
- type ChannelCredentials
- type ChannelModelAssociation
- type ChannelPolicies
- type ChannelRateLimit
- type ChannelRegexAssociation
- type ChannelSettings
- type ChannelTagsMatchMode
- type ChannelTagsModelAssociation
- type ChannelTagsRegexAssociation
- type Condition
- type ConditionType
- type CostItem
- type DataStorageSettings
- type DisabledAPIKey
- type Error
- type ErrorResponse
- type ExcludeAssociation
- type GCPCredential
- type GCPCredentialsJSON
- type GCS
- type GUID
- type HeaderEntry
- type JSONRawMessage
- type ModelAssociation
- type ModelAssociationWhen
- type ModelCard
- type ModelCardCost
- type ModelCardLimit
- type ModelCardModalities
- type ModelCardReasoning
- type ModelIDAssociation
- type ModelMapping
- type ModelPrice
- type ModelPriceItem
- type ModelSettings
- type OAuthCredentials
- type OverrideOperation
- type PriceItemCode
- type PriceTier
- type Pricing
- type PricingMode
- type ProjectProfile
- type ProjectProfiles
- type PromptAction
- type PromptActionType
- type PromptActivationCondition
- type PromptActivationConditionComposite
- type PromptActivationConditionType
- type PromptProtectionAction
- type PromptProtectionScope
- type PromptProtectionSettings
- type PromptSettings
- type PromptWriteCacheVariant
- type PromptWriteCacheVariantCode
- type ProxyConfig
- type ProxyType
- type RegexAssociation
- type RoleInfo
- type S3
- type TierCost
- type TieredPricing
- type TransformOptions
- type UserInfo
- type UserProjectInfo
- type WebDAV
Constants ¶
const ( OverrideOpSet = "set" OverrideOpDelete = "delete" OverrideOpRename = "rename" OverrideOpCopy = "copy" OverrideOpArrayAppend = "array_append" OverrideOpArrayPrepend = "array_prepend" OverrideOpArrayInsert = "array_insert" )
Override operation types.
Variables ¶
This section is empty.
Functions ¶
func ConvertGUIDPtrToInt ¶
func ConvertGUIDPtrToIntPtr ¶
func ConvertGUIDPtrsToInts ¶
func ConvertGUIDToInt ¶
ConvertGUIDToInt converts a GUID to an int id. TODO: validate the type from the context.
func ConvertGUIDToIntPtr ¶
func MatchChannelTags ¶ added in v0.9.32
func MatchChannelTags(allowedTags []string, matchMode ChannelTagsMatchMode, channelTags []string) bool
func SerializeOverrideOperations ¶ added in v0.9.3
func SerializeOverrideOperations(ops []OverrideOperation) (string, error)
SerializeOverrideOperations converts override operations to a JSON string for storage.
Types ¶
type APIKeyProfile ¶
type APIKeyProfile struct {
Name string `json:"name"`
ModelMappings []ModelMapping `json:"modelMappings"`
Quota *APIKeyQuota `json:"quota,omitempty"`
LoadBalanceStrategy *string `json:"loadBalanceStrategy,omitempty"`
ChannelIDs []int `json:"channelIDs,omitempty"`
ChannelTags []string `json:"channelTags,omitempty"`
ChannelTagsMatchMode ChannelTagsMatchMode `json:"channelTagsMatchMode,omitempty"`
ModelIDs []string `json:"modelIDs,omitempty"`
}
func (*APIKeyProfile) MatchChannelTags ¶ added in v0.9.25
func (p *APIKeyProfile) MatchChannelTags(tags []string) bool
type APIKeyProfiles ¶
type APIKeyProfiles struct {
ActiveProfile string `json:"activeProfile"`
Profiles []APIKeyProfile `json:"profiles"`
}
type APIKeyQuota ¶ added in v0.8.3
type APIKeyQuota struct {
Requests *int64 `json:"requests,omitempty"`
TotalTokens *int64 `json:"totalTokens,omitempty"`
Cost *decimal.Decimal `json:"cost,omitempty"`
Period APIKeyQuotaPeriod `json:"period"`
}
type APIKeyQuotaCalendarDuration ¶ added in v0.8.3
type APIKeyQuotaCalendarDuration struct {
Unit APIKeyQuotaCalendarDurationUnit `json:"unit"`
}
type APIKeyQuotaCalendarDurationUnit ¶ added in v0.8.3
type APIKeyQuotaCalendarDurationUnit string
const ( APIKeyQuotaCalendarDurationUnitDay APIKeyQuotaCalendarDurationUnit = "day" APIKeyQuotaCalendarDurationUnitMonth APIKeyQuotaCalendarDurationUnit = "month" )
type APIKeyQuotaPastDuration ¶ added in v0.8.3
type APIKeyQuotaPastDuration struct {
Value int64 `json:"value"`
Unit APIKeyQuotaPastDurationUnit `json:"unit"`
}
type APIKeyQuotaPastDurationUnit ¶ added in v0.8.3
type APIKeyQuotaPastDurationUnit string
const ( APIKeyQuotaPastDurationUnitMinute APIKeyQuotaPastDurationUnit = "minute" APIKeyQuotaPastDurationUnitHour APIKeyQuotaPastDurationUnit = "hour" APIKeyQuotaPastDurationUnitDay APIKeyQuotaPastDurationUnit = "day" )
type APIKeyQuotaPeriod ¶ added in v0.8.3
type APIKeyQuotaPeriod struct {
Type APIKeyQuotaPeriodType `json:"type"`
PastDuration *APIKeyQuotaPastDuration `json:"pastDuration,omitempty"`
CalendarDuration *APIKeyQuotaCalendarDuration `json:"calendarDuration,omitempty"`
}
type APIKeyQuotaPeriodType ¶ added in v0.8.3
type APIKeyQuotaPeriodType string
const ( APIKeyQuotaPeriodTypeAllTime APIKeyQuotaPeriodType = "all_time" APIKeyQuotaPeriodTypePastDuration APIKeyQuotaPeriodType = "past_duration" APIKeyQuotaPeriodTypeCalendarDuration APIKeyQuotaPeriodType = "calendar_duration" )
type AzureCredential ¶ added in v0.6.5
type AzureCredential struct {
// APIVersion is a optional version for the channel.
APIVersion string `json:"apiVersion"`
}
type CapabilityPolicy ¶ added in v0.8.3
type CapabilityPolicy string
const ( CapabilityPolicyUnlimited CapabilityPolicy = "unlimited" CapabilityPolicyRequire CapabilityPolicy = "require" CapabilityPolicyForbid CapabilityPolicy = "forbid" )
type ChannelCredentials ¶
type ChannelCredentials struct {
// APIKey is the API key for the channel, for the single key channel, e.g. Codex, Claude code, Antigravity.
// It is kept for backward compatibility with existing data, recommend to use OAuth instead.
APIKey string `json:"apiKey,omitempty"`
// OAuth is the OAuth credentials for the channel, for the OAuth channel, e.g. Codex, Claude code, Antigravity.
OAuth *OAuthCredentials `json:"oauth,omitempty"`
// APIKeys is a list of API keys for the channel.
// When multiple keys are provided, they will be used in a round-robin fashion.
APIKeys []string `json:"apiKeys,omitempty"`
// Azure configuration for the channel.
Azure *AzureCredential `json:"azure,omitempty"`
// GCP is the GCP credentials for the channel.
GCP *GCPCredential `json:"gcp,omitempty"`
}
func (*ChannelCredentials) GetAllAPIKeys ¶ added in v0.9.3
func (c *ChannelCredentials) GetAllAPIKeys() []string
GetAllAPIKeys returns all API keys for the channel, combining APIKey and APIKeys fields. This ensures backward compatibility with old data that only has APIKey set.
func (*ChannelCredentials) GetEnabledAPIKeys ¶ added in v0.9.3
func (c *ChannelCredentials) GetEnabledAPIKeys(disabledKeys []DisabledAPIKey) []string
GetEnabledAPIKeys returns API keys that are not disabled.
func (*ChannelCredentials) IsOAuth ¶ added in v0.9.3
func (c *ChannelCredentials) IsOAuth() bool
IsOAuth returns true if OAuth credentials are configured and valid. It checks both the new OAuth field and legacy APIKey field for backward compatibility.
type ChannelModelAssociation ¶ added in v0.7.0
type ChannelPolicies ¶ added in v0.8.3
type ChannelPolicies struct {
Stream CapabilityPolicy `json:"stream,omitempty"`
}
type ChannelRateLimit ¶ added in v0.9.32
type ChannelRegexAssociation ¶ added in v0.7.0
type ChannelSettings ¶
type ChannelSettings struct {
// ExtraModelPrefix sets the channel accept the model with the extra prefix.
// e.g. a channel
// supported_modles is ["deepseek-chat", "deepseek-reasoner"]
// extraModelPrefix is "deepseek"
// then the model "deepseek-chat", "deepseek-reasoner", "deepseek/deepseek-chat", "deepseek/deepseek-reasoner" will be accepted.
// And if other channel support "deepseek/deepseek-chat", "deepseek/deepseek-reasoner" modles, the two channels can accept the request both.
ExtraModelPrefix string `json:"extraModelPrefix"`
// AutoTrimedModelPrefixes configures prefixes to automatically trim the model name when added to supported models.
// e.g. a channel
// supported_modles is ["deepseek-ai/deepseek-chat", "openai/gpt-4"]
// autoTrimedModelPrefixes is ["openai", "deepseek"]
// then the model "openai/gpt-4", "deepseek/deepseek-chat", "deepseek-chat", "gpt-4" will be accepted.
AutoTrimedModelPrefixes []string `json:"autoTrimedModelPrefixes"`
// ModelMappings add model alias for the model in the channels.
// e.g. {"from": "deepseek-chat", "to": "deepseek/deepseek-chat"} will add a alias "deepseek-chat" for "deepseek/deepseek-chat".
ModelMappings []ModelMapping `json:"modelMappings"`
// HideOriginalModels hides the original models from the model list when model mappings are configured.
// When enabled, only the mapped model names (from field) will be exposed, not the actual model names (to field).
HideOriginalModels bool `json:"hideOriginalModels"`
// HideMappedModels hides the mapped models from the model list when model mappings are configured.
// When enabled, only the original model names (from field) will be exposed, not the mapped model names (to field).
HideMappedModels bool `json:"hideMappedModels"`
// OverrideParameters sets the channel override the request body.
// A json string.
// e.g. {"max_tokens": 100}, {"temperature": 0.7}
// Deprecated Use bodyOverrideOperations instead.
OverrideParameters string `json:"overrideParameters"`
// BodyOverrideOperations sets the channel override operations for the request body.
// When present (including an empty array), it takes precedence over OverrideParameters.
BodyOverrideOperations []OverrideOperation `json:"bodyOverrideOperations,omitempty"`
// OverrideHeaders sets the channel override the request headers.
// e.g. [{"key": "User-Agent", "value": "AxonHub"}]
// Supported ops: set (default), delete, rename, copy.
// Deprecated Use headerOverrideOperations instead.
OverrideHeaders []HeaderEntry `json:"overrideHeaders"`
// HeaderOverrideOperations sets the channel override operations for request headers.
// When present (including an empty array), it takes precedence over OverrideHeaders.
HeaderOverrideOperations []OverrideOperation `json:"headerOverrideOperations,omitempty"`
// Proxy configuration for the channel. If not set, defaults to environment proxy type.
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
// TransformOptions configures the transform options for the channel.
TransformOptions TransformOptions `json:"transformOptions"`
// PassThroughUserAgent controls whether to pass through the original User-Agent header to upstream AI providers.
// When set to nil, it inherits from the global system setting.
// When set to true/false, it overrides the global setting.
PassThroughUserAgent *bool `json:"passThroughUserAgent,omitempty"`
// PassThroughBody controls whether to forward the original request body directly
// to the upstream provider and the raw provider response/stream directly to the client
// without re-serialization through the transform pipelines.
// Only effective when the inbound and outbound API formats are identical.
PassThroughBody bool `json:"passThroughBody,omitempty"`
// RateLimit configures the upstream rate limit for the channel.
// When configured, the load balancer will skip channels that have exceeded their rate limits.
RateLimit *ChannelRateLimit `json:"rateLimit,omitempty"`
}
type ChannelTagsMatchMode ¶ added in v0.9.30
type ChannelTagsMatchMode string
ChannelTagsMatchMode controls how profile channel tags are matched. If this enum is changed, update MatchChannelTags in this file.
const ( ChannelTagsMatchModeAny ChannelTagsMatchMode = "any" ChannelTagsMatchModeAll ChannelTagsMatchMode = "all" ChannelTagsMatchModeNone ChannelTagsMatchMode = "none" )
func (ChannelTagsMatchMode) IsValid ¶ added in v0.9.30
func (m ChannelTagsMatchMode) IsValid() bool
func (ChannelTagsMatchMode) OrDefault ¶ added in v0.9.30
func (m ChannelTagsMatchMode) OrDefault() ChannelTagsMatchMode
type ChannelTagsModelAssociation ¶ added in v0.7.4
type ChannelTagsRegexAssociation ¶ added in v0.7.4
type Condition ¶ added in v0.9.32
type Condition struct {
Type ConditionType `json:"type"`
Logic string `json:"logic,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
Field string `json:"field,omitempty"`
Operator string `json:"operator,omitempty"`
Value any `json:"value,omitempty"`
}
func (*Condition) UnmarshalJSON ¶ added in v0.9.32
type ConditionType ¶ added in v0.9.32
type ConditionType string
const ( ConditionTypeCondition ConditionType = "condition" ConditionTypeGroup ConditionType = "group" )
type CostItem ¶ added in v0.8.3
type CostItem struct {
ItemCode PriceItemCode `json:"itemCode"`
PromptWriteCacheVariantCode PromptWriteCacheVariantCode `json:"promptWriteCacheVariantCode,omitempty"`
Quantity int64 `json:"quantity"`
TierBreakdown []TierCost `json:"tierBreakdown,omitempty"`
Subtotal decimal.Decimal `json:"subtotal"`
}
type DataStorageSettings ¶ added in v0.4.0
type DataStorageSettings struct {
// DSN is the database data storage.
DSN *string `json:"dsn"`
// Directory is the directory of the fs data storage.
Directory *string `json:"directory"`
// S3 is the s3 data storage.
S3 *S3 `json:"s3"`
// GCS is the gcs data storage.
GCS *GCS `json:"gcs"`
// WebDAV is the webdav data storage.
WebDAV *WebDAV `json:"webdav"`
}
type DisabledAPIKey ¶ added in v0.9.3
type DisabledAPIKey struct {
Key string `json:"key"`
DisabledAt time.Time `json:"disabledAt"`
ErrorCode int `json:"errorCode"`
Reason string `json:"reason,omitempty"`
}
DisabledAPIKey 记录被禁用的 API key 信息(敏感,按 credentials 同级保护) 注意:禁用判断以 Key 明文为主键。
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
type ExcludeAssociation ¶ added in v0.7.1
type GCPCredential ¶
type GCPCredentialsJSON ¶
type GCPCredentialsJSON struct {
Type string `json:"type" validate:"required"`
ProjectID string `json:"projectID" validate:"required"`
PrivateKeyID string `json:"privateKeyID" validate:"required"`
PrivateKey string `json:"privateKey" validate:"required"`
ClientEmail string `json:"clientEmail" validate:"required"`
ClientID string `json:"clientID" validate:"required"`
AuthURI string `json:"authURI" validate:"required"`
TokenURI string `json:"tokenURI" validate:"required"`
AuthProviderX509CertURL string `json:"authProviderX509CertURL" validate:"required"`
ClientX509CertURL string `json:"clientX509CertURL" validate:"required"`
UniverseDomain string `json:"universeDomain" validate:"required"`
}
type HeaderEntry ¶ added in v0.5.0
type JSONRawMessage ¶
type JSONRawMessage []byte
func (JSONRawMessage) MarshalGQL ¶
func (m JSONRawMessage) MarshalGQL(w io.Writer)
MarshalGQL returns m as the JSON encoding of m.
func (JSONRawMessage) MarshalJSON ¶
func (m JSONRawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*JSONRawMessage) UnmarshalGQL ¶
func (m *JSONRawMessage) UnmarshalGQL(v any) error
UnmarshalGQL sets *m to a copy of data.
func (*JSONRawMessage) UnmarshalJSON ¶
func (m *JSONRawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type ModelAssociation ¶ added in v0.7.0
type ModelAssociation struct {
// channel_model: the specified model id in the specified channel
// channel_regex: the specified pattern in the specified channel
// regex: the pattern for all channels
// model: the specified model id
// channel_tags_model: the specified model id in channels with specified tags (OR logic)
// channel_tags_regex: the specified pattern in channels with specified tags (OR logic)
Type string `json:"type"`
Priority int `json:"priority"` // Lower value = higher priority, default 0
Disabled bool `json:"disabled"`
When *ModelAssociationWhen `json:"when,omitempty"`
ChannelModel *ChannelModelAssociation `json:"channelModel"`
ChannelRegex *ChannelRegexAssociation `json:"channelRegex"`
Regex *RegexAssociation `json:"regex"`
ModelID *ModelIDAssociation `json:"modelId"`
ChannelTagsModel *ChannelTagsModelAssociation `json:"channelTagsModel"`
ChannelTagsRegex *ChannelTagsRegexAssociation `json:"channelTagsRegex"`
}
type ModelAssociationWhen ¶ added in v0.9.32
type ModelCard ¶ added in v0.7.0
type ModelCard struct {
Reasoning ModelCardReasoning `json:"reasoning"`
ToolCall bool `json:"toolCall"`
Temperature bool `json:"temperature"`
Modalities ModelCardModalities `json:"modalities"`
Vision bool `json:"vision"`
Cost ModelCardCost `json:"cost"`
Limit ModelCardLimit `json:"limit"`
Knowledge string `json:"knowledge"`
ReleaseDate string `json:"releaseDate"`
LastUpdated string `json:"lastUpdated"`
}
type ModelCardCost ¶ added in v0.7.0
type ModelCardLimit ¶ added in v0.7.0
type ModelCardModalities ¶ added in v0.7.0
type ModelCardReasoning ¶ added in v0.7.0
type ModelIDAssociation ¶ added in v0.7.0
type ModelIDAssociation struct {
ModelID string `json:"modelId"`
Exclude []*ExcludeAssociation `json:"exclude"`
}
type ModelMapping ¶
type ModelPrice ¶ added in v0.8.3
type ModelPrice struct {
// Items is the list of price items for the price.
Items []ModelPriceItem `json:"items"`
}
ModelPrice is the price for the thing.
func (*ModelPrice) Equals ¶ added in v0.8.3
func (p *ModelPrice) Equals(other ModelPrice) bool
func (*ModelPrice) Validate ¶ added in v0.8.3
func (p *ModelPrice) Validate() error
type ModelPriceItem ¶ added in v0.8.3
type ModelPriceItem struct {
// ItemCode is the code of the item.
ItemCode PriceItemCode `json:"itemCode"`
// Pricing is the pricing for the item.
Pricing Pricing `json:"pricing"`
// PromptWriteCacheVariants is the list of variants for the item prompt write cached tokens.
// If the variants present, it will find the variant price first, if not hit, it will use the item pricing.
PromptWriteCacheVariants []PromptWriteCacheVariant `json:"promptWriteCacheVariants,omitempty"`
}
func (*ModelPriceItem) Equals ¶ added in v0.8.3
func (i *ModelPriceItem) Equals(other *ModelPriceItem) bool
func (*ModelPriceItem) FindPromptWriteCacheVariantPricing ¶ added in v0.8.3
func (i *ModelPriceItem) FindPromptWriteCacheVariantPricing(variantCode PromptWriteCacheVariantCode) Pricing
FindPromptWriteCacheVariantPricing finds the variant pricing for the item prompt write cached tokens. If the variant pricing is not found, it will return the item pricing.
func (*ModelPriceItem) Validate ¶ added in v0.8.3
func (i *ModelPriceItem) Validate() error
type ModelSettings ¶ added in v0.7.0
type ModelSettings struct {
Associations []*ModelAssociation `json:"associations"`
}
type OAuthCredentials ¶ added in v0.8.3
type OAuthCredentials = oauth.OAuthCredentials
type OverrideOperation ¶ added in v0.9.3
type OverrideOperation struct {
Op string `json:"op"`
Path string `json:"path,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Value string `json:"value,omitempty"`
Condition string `json:"condition,omitempty"`
// Index is the target position for array_insert. Only used by array_insert.
// Negative values count from the end (-1 = before last). Out-of-range values are clamped to [0, len].
Index *int `json:"index,omitempty"`
// Splat controls whether a JSON-array value is spread into the target array
// (true: each element inserted individually) or inserted as a single nested element (false).
// Only meaningful for array_append, array_prepend, and array_insert. Defaults to true.
Splat *bool `json:"splat,omitempty"`
}
OverrideOperation defines a structured override operation for request body/header manipulation.
func HeaderEntriesToOverrideOperations ¶ added in v0.9.3
func HeaderEntriesToOverrideOperations(headers []HeaderEntry) []OverrideOperation
func ParseOverrideOperations ¶ added in v0.9.3
func ParseOverrideOperations(raw string) ([]OverrideOperation, error)
ParseOverrideOperations parses the override parameters string. Supports both legacy map format (JSON object) and new operation array format (JSON array). Legacy format is automatically converted to OverrideOperation slice.
type PriceItemCode ¶ added in v0.8.3
type PriceItemCode string
const ( // PriceItemCodeUsage is the price item code for the token usage. PriceItemCodeUsage PriceItemCode = "prompt_tokens" // PriceItemCodeCompletion is the price item code for the token completion. PriceItemCodeCompletion PriceItemCode = "completion_tokens" // PriceItemCodePromptCachedToken is the price item code for the cached token usage. PriceItemCodePromptCachedToken PriceItemCode = "prompt_cached_tokens" // PriceItemCodeWriteCachedTokens is the price item code for the cached token write. //nolint:gosec // not token. PriceItemCodeWriteCachedTokens PriceItemCode = "prompt_write_cached_tokens" )
type PriceTier ¶ added in v0.8.3
type PriceTier struct {
// UpTo is the upper bound of the token usage for the price tier.
// If the upper bound is nil, it means no upper bound, it must be the last price tier.
UpTo *int64 `json:"upTo,omitempty"`
// PricePerUnit is the price per token for the price tier.
PricePerUnit decimal.Decimal `json:"pricePerUnit"`
}
PriceTier is the price tier for the tiered pricing.
type Pricing ¶ added in v0.8.3
type Pricing struct {
Mode PricingMode `json:"mode"`
// FlatFee is the fixed fee for the pricing.
FlatFee *decimal.Decimal `json:"flatFee,omitempty"`
// UsagePerUnit is the price per token for the pricing.
UsagePerUnit *decimal.Decimal `json:"usagePerUnit,omitempty"`
// UsageTiered is the tiered pricing for the pricing.
UsageTiered *TieredPricing `json:"usageTiered,omitempty"`
}
type PricingMode ¶ added in v0.8.3
type PricingMode string
const ( // PricingModeFlatFee means the request is charged a fixed fee. PricingModeFlatFee PricingMode = "flat_fee" // PricingModeUsagePerUnit means the request is charged a fee bases on the token usage. // e.g. $0.01 per token, if the usage is 1,500 then the fee is $0.01 x 1,500 = $15.00. PricingModeUsagePerUnit PricingMode = "usage_per_unit" // PricingModeTiered means the request is charged a fee based on the token usage tiers. // e.g. a tier price is [1,000, 2,000, 3,000] for [$0.01, $0.02, $0.03], if the usage is 1,500 then the fee is // $0.01 x 1000 + $0.02 x (1500-1000) = $20.00. PricingModeTiered PricingMode = "usage_tiered" )
type ProjectProfile ¶ added in v0.9.30
type ProjectProfile struct {
Name string `json:"name"`
ChannelIDs []int `json:"channelIDs,omitempty"`
ChannelTags []string `json:"channelTags,omitempty"`
ChannelTagsMatchMode ChannelTagsMatchMode `json:"channelTagsMatchMode,omitempty"`
}
func (*ProjectProfile) MatchChannelTags ¶ added in v0.9.30
func (p *ProjectProfile) MatchChannelTags(tags []string) bool
type ProjectProfiles ¶ added in v0.9.30
type ProjectProfiles struct {
ActiveProfile string `json:"activeProfile"`
Profiles []ProjectProfile `json:"profiles"`
}
type PromptAction ¶ added in v0.8.0
type PromptAction struct {
// Type is the type of prompt action.
// It is continue to add more action types in the future.
Type PromptActionType `json:"type"`
}
PromptAction is the action to perform when the prompt is activated.
type PromptActionType ¶ added in v0.8.0
type PromptActionType string
const ( // PromptActionTypePrepend is the action to prepend the prompt before the request messages. PromptActionTypePrepend PromptActionType = "prepend" // PromptActionTypeAppend is the action to append the prompt after the request messages. PromptActionTypeAppend PromptActionType = "append" )
type PromptActivationCondition ¶ added in v0.8.0
type PromptActivationCondition struct {
// Type is the type of prompt activation condition.
// It is continue to add more condition types in the future.
Type PromptActivationConditionType `json:"type"`
// ModelID is the ID of the model to activate the prompt.
ModelID *string `json:"model_id,omitempty"`
// ModelPattern is the pattern of the model to activate the prompt.
// The pattern is a regular expression.
ModelPattern *string `json:"model_pattern,omitempty"`
// APIKeyID is the ID of the API key to activate the prompt.
APIKeyID *int `json:"api_key_id,omitempty"`
}
PromptActivationCondition is the condition to activate the prompt.
type PromptActivationConditionComposite ¶ added in v0.8.0
type PromptActivationConditionComposite struct {
// Conditions is the conditions to activate the prompt.
// At least one condition must be met to activate the prompt.
Conditions []PromptActivationCondition `json:"conditions,omitempty"`
}
PromptActivationConditionComposite is the composite condition to activate the prompt.
type PromptActivationConditionType ¶ added in v0.8.0
type PromptActivationConditionType string
const ( // PromptActivationConditionTypeModelID is the condition to activate the prompt for the specified model ID. PromptActivationConditionTypeModelID PromptActivationConditionType = "model_id" // PromptActivationConditionTypeModelPattern is the condition to activate the prompt for the models that match the pattern. PromptActivationConditionTypeModelPattern PromptActivationConditionType = "model_pattern" // PromptActivationConditionTypeAPIKey is the condition to activate the prompt for the specified API key. PromptActivationConditionTypeAPIKey PromptActivationConditionType = "api_key" )
type PromptProtectionAction ¶ added in v0.9.20
type PromptProtectionAction string
const ( PromptProtectionActionMask PromptProtectionAction = "mask" PromptProtectionActionReject PromptProtectionAction = "reject" )
type PromptProtectionScope ¶ added in v0.9.20
type PromptProtectionScope string
const ( PromptProtectionScopeSystem PromptProtectionScope = "system" PromptProtectionScopeDeveloper PromptProtectionScope = "developer" PromptProtectionScopeUser PromptProtectionScope = "user" PromptProtectionScopeAssistant PromptProtectionScope = "assistant" PromptProtectionScopeTool PromptProtectionScope = "tool" )
type PromptProtectionSettings ¶ added in v0.9.20
type PromptProtectionSettings struct {
Action PromptProtectionAction `json:"action"`
Replacement string `json:"replacement,omitempty"`
Scopes []PromptProtectionScope `json:"scopes,omitempty"`
}
type PromptSettings ¶ added in v0.8.0
type PromptSettings struct {
// Action is the action to perform when the prompt is activated.
Action PromptAction `json:"action"`
// Conditions of the prompts must to be met to activate the prompt.
// All conditions must be met to activate the prompt.
Conditions []PromptActivationConditionComposite `json:"conditions,omitempty"`
}
type PromptWriteCacheVariant ¶ added in v0.8.3
type PromptWriteCacheVariant struct {
// VariantCode is the code of the variant.
VariantCode PromptWriteCacheVariantCode `json:"variantCode"`
// Pricing is the pricing for the variant.
Pricing Pricing `json:"pricing"`
}
PromptWriteCacheVariant is the variant for cached token write.
func (*PromptWriteCacheVariant) Equals ¶ added in v0.8.3
func (p *PromptWriteCacheVariant) Equals(other *PromptWriteCacheVariant) bool
func (*PromptWriteCacheVariant) Validate ¶ added in v0.8.3
func (p *PromptWriteCacheVariant) Validate() error
type PromptWriteCacheVariantCode ¶ added in v0.8.3
type PromptWriteCacheVariantCode string
const ( // PromptWriteCacheVariantCode5Min is the variant code for cached token write in 5 minutes. PromptWriteCacheVariantCode5Min PromptWriteCacheVariantCode = "five_min" // PromptWriteCacheVariantCode1Hour is the variant code for cached token write in 1 hour. PromptWriteCacheVariantCode1Hour PromptWriteCacheVariantCode = "one_hour" )
type ProxyConfig ¶ added in v0.4.2
type ProxyConfig = httpclient.ProxyConfig
type ProxyType ¶ added in v0.4.2
type ProxyType = httpclient.ProxyType
type RegexAssociation ¶ added in v0.7.0
type RegexAssociation struct {
Pattern string `json:"pattern"`
Exclude []*ExcludeAssociation `json:"exclude"`
}
type S3 ¶ added in v0.4.0
type S3 struct {
BucketName string `json:"bucketName"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
// PathStyle enables Path Style access for S3 compatible storage services (e.g., MinIO, Ceph RGW).
// When enabled, uses https://s3.amazonaws.com/<bucket-name>/object format instead of Virtual Hosted Style.
PathStyle bool `json:"pathStyle"`
}
type TieredPricing ¶ added in v0.8.3
type TieredPricing struct {
Tiers []PriceTier `json:"tiers"`
}
func (*TieredPricing) Equals ¶ added in v0.8.3
func (p *TieredPricing) Equals(other *TieredPricing) bool
func (*TieredPricing) Validate ¶ added in v0.8.3
func (p *TieredPricing) Validate() error
type TransformOptions ¶ added in v0.7.10
type TransformOptions struct {
// ForceArrayInstructions forces the channel to accept array format for instructions.
ForceArrayInstructions bool `json:"forceArrayInstructions"`
// ForceArrayInputs forces the channel to accept array format for inputs.
ForceArrayInputs bool `json:"forceArrayInputs"`
// ReplaceDeveloperRoleWithSystem replaces developer role with system in messages for Bailian compatibility.
ReplaceDeveloperRoleWithSystem bool `json:"replaceDeveloperRoleWithSystem"`
}
type UserInfo ¶
type UserInfo struct {
ID GUID `json:"id"`
Email string `json:"email"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
IsOwner bool `json:"isOwner"`
PreferLanguage string `json:"preferLanguage"`
Avatar *string `json:"avatar,omitempty"`
Scopes []string `json:"scopes"`
Roles []RoleInfo `json:"roles"`
Projects []UserProjectInfo `json:"projects"`
}