helps

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildOpenAIUsageJSON

func BuildOpenAIUsageJSON(count int64) []byte

BuildOpenAIUsageJSON returns a minimal usage structure understood by downstream translators.

func CountClaudeInputTokens

func CountClaudeInputTokens(payload []byte) (int64, error)

CountClaudeInputTokens estimates tokens for a Claude request with the O200kBase tokenizer.

func CountOpenAIChatTokens

func CountOpenAIChatTokens(enc tokenizer.Codec, payload []byte) (int64, error)

CountOpenAIChatTokens approximates prompt tokens for OpenAI chat completions payloads.

func LogWithRequestID

func LogWithRequestID(ctx context.Context) *log.Entry

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

func TokenizerForModel(model string) (tokenizer.Codec, error)

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.

Jump to

Keyboard shortcuts

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