Documentation
¶
Index ¶
- func BuildOpenAIUsageJSON(count int64) []byte
- func CountClaudeInputTokens(payload []byte) (int64, error)
- func CountOpenAIChatTokens(enc tokenizer.Codec, payload []byte) (int64, error)
- func LogWithRequestID(ctx context.Context) *log.Entry
- func NewProxyAwareHTTPClient(ctx context.Context, _ any, auth *cliproxyauth.Auth, timeout time.Duration) *http.Client
- func TokenizerForModel(model string) (tokenizer.Codec, error)
- func TranslateStreamWithClaudeInputTokens(ctx context.Context, upstreamFormat, responseFormat sdktranslator.Format, ...) [][]byte
- type ClaudeInputTokenState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildOpenAIUsageJSON ¶
BuildOpenAIUsageJSON returns a minimal usage structure understood by downstream translators.
func CountClaudeInputTokens ¶
CountClaudeInputTokens estimates tokens for a Claude request with the O200kBase tokenizer.
func CountOpenAIChatTokens ¶
CountOpenAIChatTokens approximates prompt tokens for OpenAI chat completions payloads.
func LogWithRequestID ¶
LogWithRequestID returns a logrus entry. The public plugin does not import CLIProxyAPI internal request-id helpers, so missing IDs stay off the fields.
func NewProxyAwareHTTPClient ¶
func NewProxyAwareHTTPClient(ctx context.Context, _ any, auth *cliproxyauth.Auth, timeout time.Duration) *http.Client
NewProxyAwareHTTPClient matches the CPA helper signature used by the Agent v1 executor. cfg is ignored; proxy selection comes from auth.ProxyURL, then the context RoundTripper.
func TokenizerForModel ¶
TokenizerForModel returns a tokenizer codec suitable for an OpenAI-style model id.
func TranslateStreamWithClaudeInputTokens ¶
func TranslateStreamWithClaudeInputTokens( ctx context.Context, upstreamFormat, responseFormat sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any, state *ClaudeInputTokenState, ) [][]byte
TranslateStreamWithClaudeInputTokens translates a stream chunk and estimates Claude message_start input usage once.
Types ¶
type ClaudeInputTokenState ¶
type ClaudeInputTokenState struct {
// contains filtered or unexported fields
}
ClaudeInputTokenState tracks the one-time input token update for a translated Claude stream.
func NewClaudeInputTokenState ¶
func NewClaudeInputTokenState(sourceFormat, upstreamFormat, responseFormat sdktranslator.Format, originalRequest []byte) *ClaudeInputTokenState
NewClaudeInputTokenState creates request-scoped state for translated Claude input token usage.