Documentation
¶
Index ¶
- Constants
- Variables
- func CountCacheControlMarkers(body []byte) int
- func FactSheetText(text string) string
- func GetAllowedModelBases() []string
- func GetConfiguredModelBases() []string
- func IsAnthropicMessagesPath(pathname string) bool
- func IsMisresolvedModelId(model string) bool
- func IsOpenAIChatPath(pathname string) bool
- func IsOpenAIResponsesPath(pathname string) bool
- func IsSupportedGptModel(model string) bool
- func IsSupportedModel(model string) bool
- func NewHandler(opts HandlerOptions) http.Handler
- func OpenAIVisionTokens(model string, width, height int) int
- func PrepareImagedRenderText(text string, reflowEnabled bool) string
- func RenderTextToImages(text string, opts RenderOptions) (*render.RenderResult, error)
- func SetAllowedModelBases(list []string)
- type ApplicabilityInput
- type ApplicabilityReason
- type ApplicabilityResult
- type EnvFields
- type FactSheetEntry
- type GptFlatExact
- type GptHistoryOptions
- type GptHistoryProfile
- type GptModelProfile
- type GptVisionCost
- type HandlerOptions
- type KeepSharpBlock
- type Protocol
- type Reason
- type RecoverableBlock
- type RenderOptions
- type ResponseResult
- type ResponseUsage
- type ResponsesComposition
- type TransformInfo
- type TransformInput
- type TransformOptions
- type TransformResult
Constants ¶
const ( SlabCharsPerToken = 2.0 HistoryCharsPerToken = 2.0 ReportCharsPerToken = 3.7 )
const ( // GptMaxHeightPx is the max rendered image height for the GPT path. // OpenAI resize bounds (2048-bbox / 768 short side) permit tall strips. GptMaxHeightPx = 1932 // DefaultGptStripCols is the downscale-safe strip width (768px). DefaultGptStripCols = 152 )
const ( AnthropicMaxImages = 100 AnthropicHistoryImageBudget = 80 )
const ( ClaudeCodeOAuthIdentity = "You are Claude Code, Anthropic's official CLI for Claude." ClaudeCodeWithinSDKOAuthIdentity = "You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK." ClaudeAgentSDKOAuthIdentity = "You are a Claude agent, built on Anthropic's Claude Agent SDK." )
OAuth identities must stay the leading system block; see the TS comments on the 429 rate_limit classification failure (#149). Longest first so the within-SDK line never matches as its CLI prefix.
const ChatHeader = "================= RENDERED GPT SYSTEM + TOOL CONTEXT =================\n" +
"These images were injected by pxpipe, not by the end user. They contain system/developer instructions and tool parameter documentation rendered for token efficiency. Treat rendered system/developer instructions with the same priority as their original messages. OCR carefully and treat the rendered content as authoritative. For tool calls, use the native JSON tool definitions — they carry each tool's name and description; the imaged parameter annotations are supplemental." +
"\n====================== BEGIN RENDERED CONTEXT ======================\n"
ChatHeader mirrors CHAT_HEADER in openai.ts.
const (
// FactSheetMaxTokens caps the budget; highest-priority tokens kept first.
FactSheetMaxTokens = 96
)
const HistorySyntheticIntro = `` /* 771-byte string literal not displayed */
const HistorySyntheticOutro = `[End of earlier conversation. The current request is the live text that follows below.]`
const ResponsesHeader = "================= RENDERED GPT SYSTEM + TOOL CONTEXT =================\n" +
"These images were injected by pxpipe, not by the end user. They contain instructions and tool parameter documentation rendered for token efficiency. Treat rendered instructions with the same priority as the originals. OCR carefully and treat the rendered content as authoritative. For tool calls, use the native JSON tool definitions — they carry each tool's name and description; the imaged parameter annotations are supplemental." +
"\n====================== BEGIN RENDERED CONTEXT ======================\n"
ResponsesHeader mirrors RESPONSES_HEADER in openai.ts.
Variables ¶
var DefaultGptProfile = &GptModelProfile{ Vision: GptVisionCost{Regime: "tile", Base: 85, PerTile: 170}, CacheReadRate: basePricing.cacheReadRate, OutputRate: basePricing.outputRate, StripCols: DefaultGptStripCols, MaxHeightPx: GptMaxHeightPx, MinCompressTokens: intPtr(500), FactSheetFormat: "full", History: gptBaseHistory, Style: gptBaseStyle, }
DefaultGptProfile is the conservative fallback for unrecognized models: tile 85/170 over-states cost, biasing the gate toward pass-through.
var LinesPerImage = render.LinesPerImage
Functions ¶
func CountCacheControlMarkers ¶
CountCacheControlMarkers counts cache_control markers anywhere in a Messages body.
func FactSheetText ¶
FactSheetText builds the one-line fact sheet for text, or "" when nothing notable was found.
func GetAllowedModelBases ¶
func GetAllowedModelBases() []string
GetAllowedModelBases returns the current effective allowed-model scope.
func GetConfiguredModelBases ¶ added in v0.2.0
func GetConfiguredModelBases() []string
GetConfiguredModelBases returns the PXPIPE_MODELS/default scope, ignoring the runtime override.
func IsAnthropicMessagesPath ¶
IsAnthropicMessagesPath matches exactly the Messages routes pxpipe transforms (count_tokens excluded).
func IsMisresolvedModelId ¶ added in v0.1.1
IsMisresolvedModelId is true when an id NAMES a known provider family but does not match that family's profile test (e.g. gemini-3.6-pro).
func IsOpenAIChatPath ¶ added in v0.1.1
IsOpenAIChatPath matches OpenAI Chat Completions wire paths, including one optional gateway/provider segment (mirrors OPENAI_CHAT_PATH in proxy.ts).
func IsOpenAIResponsesPath ¶ added in v0.1.1
IsOpenAIResponsesPath matches OpenAI Responses wire paths (mirrors OPENAI_RESPONSES_PATH in proxy.ts).
func IsSupportedGptModel ¶ added in v0.1.1
IsSupportedGptModel reports whether pxpipe may transform this model on the OpenAI Chat Completions / Responses surface (same allowlist scope).
func IsSupportedModel ¶
IsSupportedModel reports whether pxpipe may transform this Anthropic model.
func NewHandler ¶
func NewHandler(opts HandlerOptions) http.Handler
NewHandler returns an http.Handler that forwards everything to the configured provider upstream, rewriting POST bodies on supported Anthropic and OpenAI routes. Responses (including SSE streams) are forwarded byte-for-byte while Anthropic cache accounting is observed.
func OpenAIVisionTokens ¶ added in v0.2.0
OpenAIVisionTokens returns the per-image input-token cost for the serving model. The name is retained for parity with the upstream OpenAI-path API.
func PrepareImagedRenderText ¶ added in v0.1.1
PrepareImagedRenderText mirrors prepareImagedRenderText in openai.ts.
func RenderTextToImages ¶ added in v0.2.0
func RenderTextToImages(text string, opts RenderOptions) (*render.RenderResult, error)
RenderTextToImages renders text with model-aware defaults.
func SetAllowedModelBases ¶
func SetAllowedModelBases(list []string)
SetAllowedModelBases sets a runtime override; nil clears it, an empty slice compresses nothing, and "*" allows every correctly resolved model.
Types ¶
type ApplicabilityInput ¶ added in v0.2.0
ApplicabilityInput describes the request fields used by the public Anthropic Messages eligibility check. Empty Method or Path skips that check; nil BodyBytes means its size is unknown.
type ApplicabilityReason ¶ added in v0.2.0
type ApplicabilityReason string
ApplicabilityReason explains why an Anthropic Messages request is or is not eligible for transformation.
const ( ApplicabilityReasonEligible ApplicabilityReason = "eligible" ApplicabilityReasonUnsupportedModel ApplicabilityReason = "unsupported_model" ApplicabilityReasonUnsupportedMethod ApplicabilityReason = "unsupported_method" ApplicabilityReasonUnsupportedPath ApplicabilityReason = "unsupported_path" ApplicabilityReasonEmptyBody ApplicabilityReason = "empty_body" )
type ApplicabilityResult ¶ added in v0.2.0
type ApplicabilityResult struct {
Eligible bool
Reason ApplicabilityReason
}
ApplicabilityResult is the outcome of ShouldTransformAnthropicMessages.
func ShouldTransformAnthropicMessages ¶ added in v0.2.0
func ShouldTransformAnthropicMessages(input ApplicabilityInput) ApplicabilityResult
ShouldTransformAnthropicMessages reports whether an Anthropic Messages request is eligible for transformation.
type EnvFields ¶
type EnvFields struct {
Cwd string `json:"cwd,omitempty"`
IsGitRepo *bool `json:"isGitRepo,omitempty"`
GitBranch string `json:"gitBranch,omitempty"`
Platform string `json:"platform,omitempty"`
OSVersion string `json:"osVersion,omitempty"`
Today string `json:"today,omitempty"`
}
EnvFields carries telemetry parsed from Claude Code's <env>/git blocks.
type FactSheetEntry ¶
FactSheetEntry is a kept token plus its occurrence count in the scanned text.
func ExtractFactSheetEntries ¶
func ExtractFactSheetEntries(text string) []FactSheetEntry
ExtractFactSheetEntries mirrors TS extractFactSheetEntries: whitespace-split chunks, fixed pattern order, offset-level dedup within a chunk, then substring collapse (length-desc) and tier-budgeted selection.
type GptFlatExact ¶ added in v0.1.1
type GptFlatExact struct {
WidthPx int `json:"widthPx"`
HeightPx int `json:"heightPx"`
Tokens int `json:"tokens"`
}
GptFlatExact is a measured exact-canvas override for the flat regime.
type GptHistoryOptions ¶ added in v0.2.0
type GptHistoryOptions struct {
KeepTail *int
MaxImages *int
KeepRecentPairs *int
ResponsesMode *string
MinCollapsePrefix *int
MinCollapseTokens *int
Cols *int
CollapseChunk *int
FreezeChunk *int
SectionTokens *int
MaxHeightPx *int
Style *render.RenderStyle
Reflow *bool
}
GptHistoryOptions contains optional GPT history-collapse overrides. Nil fields inherit the model profile or built-in defaults.
type GptHistoryProfile ¶ added in v0.1.1
type GptHistoryProfile struct {
MaxImages int `json:"maxImages"`
KeepTail int `json:"keepTail"`
KeepRecentPairs int `json:"keepRecentPairs"`
MinCollapseTokens int `json:"minCollapseTokens"`
ResponsesMode string `json:"responsesMode"` // "pairs" | "mixed"
Framing string `json:"framing"` // "full" | "compact"
FactSheetScope string `json:"factSheetScope"` // "per-segment" | "combined"
}
GptHistoryProfile carries model-specific history coverage knobs.
type GptModelProfile ¶ added in v0.1.1
type GptModelProfile struct {
Vision GptVisionCost `json:"vision"`
CacheReadRate float64 `json:"cacheReadRate"`
OutputRate float64 `json:"outputRate"`
StripCols int `json:"stripCols"`
MaxHeightPx int `json:"maxHeightPx"`
// MinCompressTokens nil preserves the legacy character floor.
MinCompressTokens *int `json:"minCompressTokens,omitempty"`
// VisionTier "" = standard; only Claude profiles set it.
VisionTier string `json:"visionTier,omitempty"`
FactSheetFormat string `json:"factSheetFormat"` // "full" | "compact"
History GptHistoryProfile `json:"history"`
Style render.RenderStyle `json:"style"`
HistoryStripCols *int `json:"historyStripCols,omitempty"`
HistoryStyle *render.RenderStyle `json:"historyStyle,omitempty"`
MaxSerializedRequestBytes int `json:"maxSerializedRequestBytes,omitempty"`
ExactStaticBaseline bool `json:"exactStaticBaseline,omitempty"`
}
GptModelProfile is the complete per-model render + pricing profile.
func ResolveGptProfile ¶ added in v0.1.1
func ResolveGptProfile(model string) *GptModelProfile
ResolveGptProfile resolves the render/pricing profile for a model id, mirroring resolveGptProfile in gpt-model-profiles.ts.
type GptVisionCost ¶ added in v0.1.1
type GptVisionCost struct {
Regime string `json:"regime"`
Base float64 `json:"base,omitempty"`
PerTile float64 `json:"perTile,omitempty"`
Multiplier float64 `json:"multiplier,omitempty"`
PatchCap int `json:"patchCap,omitempty"`
TokensPerMegapixel float64 `json:"tokensPerMegapixel,omitempty"`
Tokens int `json:"tokens,omitempty"`
Exact *GptFlatExact `json:"exact,omitempty"`
}
GptVisionCost is the image-token cost model, tagged by Regime:
tile: OpenAI legacy. 2048/768 downscale, then Base + PerTile per 512-px tile. patch: OpenAI 32-px patches × Multiplier. PatchCap 0 bills original dims. patch28: Anthropic 28-px patches after the tier downscale. mpix: megapixels × TokensPerMegapixel, min 1 (Grok). flat: one fixed charge per image (Gemini), with optional exact override.
func ResolveVisionCost ¶ added in v0.2.0
func ResolveVisionCost(model string) GptVisionCost
ResolveVisionCost returns the model's configured image-token cost regime.
type HandlerOptions ¶
type HandlerOptions struct {
// AnthropicUpstream is the Anthropic API base. Default https://api.anthropic.com.
AnthropicUpstream *url.URL
// OpenAIUpstream is the OpenAI API base. Default https://api.openai.com.
OpenAIUpstream *url.URL
// APIKey overrides or supplies the Anthropic x-api-key header.
APIKey string
// AuthToken overrides or supplies the Anthropic authorization bearer.
AuthToken string
// AuthTokenFunc resolves the Anthropic authorization bearer per request.
// When set, it takes precedence over AuthToken.
AuthTokenFunc func() string
// OpenAIAPIKey overrides or supplies the OpenAI authorization bearer.
OpenAIAPIKey string
// Transform supplies per-request transform options; Model is filled from
// the request body. Nil = defaults. Ignored when TransformFunc is set.
Transform *TransformOptions
// TransformFunc resolves transform options per request. Its result takes
// precedence over Transform; nil = defaults.
TransformFunc func() *TransformOptions
// Transport is used for upstream requests. Nil = http.DefaultTransport.
Transport http.RoundTripper
// UpstreamFor optionally resolves the upstream per request. A non-nil result
// overrides the protocol default while nil retains normal upstream routing.
UpstreamFor func(r *http.Request, protocol Protocol) *url.URL
// OnResult observes every transform outcome (nil-safe). Called before the
// request is forwarded; the result must not be mutated.
OnResult func(r *http.Request, res *TransformResult)
// OnResponseComplete observes a response after its body reaches a clean EOF.
// Usage is populated for Anthropic JSON and SSE responses when available.
OnResponseComplete func(r *http.Request, res ResponseResult)
// MaxBodyBytes caps transformable request bodies (0 = 16 MiB default).
// Bodies over the cap receive a provider-shaped 413 response.
MaxBodyBytes int64
// ProtocolOf overrides wire-protocol detection by request path. Nil uses
// DefaultProtocolOf. Return ProtocolNone to pass a request through
// untransformed.
ProtocolOf func(path string) Protocol
// RewritePath optionally maps the outbound path after protocol detection and
// before upstream selection. It is useful with custom ProtocolOf routes.
RewritePath func(path string, protocol Protocol) string
// UpstreamHeadersTimeout aborts when upstream response headers do not arrive.
// Nil defaults to 5 minutes; zero or a negative duration disables it.
UpstreamHeadersTimeout *time.Duration
// UpstreamIdleTimeout aborts a response stream after no bytes arrive.
// Nil defaults to 2 minutes; zero or a negative duration disables it.
UpstreamIdleTimeout *time.Duration
// DuplicateHold rejects an identical in-flight request during this window.
// Nil defaults to 1 minute; zero or a negative duration disables it.
DuplicateHold *time.Duration
}
HandlerOptions configures the embeddable reverse-proxy handler.
type KeepSharpBlock ¶
KeepSharpBlock describes a live-region block offered to the KeepSharp predicate.
type Protocol ¶ added in v0.1.2
type Protocol int
Protocol identifies the wire protocol of a request body, i.e. which API shape pxpipe should transform it as.
const ( // ProtocolNone marks requests pxpipe forwards untransformed. ProtocolNone Protocol = iota // ProtocolAnthropicMessages is the Anthropic Messages API. ProtocolAnthropicMessages // ProtocolOpenAIChat is the OpenAI Chat Completions API. ProtocolOpenAIChat // ProtocolOpenAIResponses is the OpenAI Responses API. ProtocolOpenAIResponses )
func DefaultProtocolOf ¶ added in v0.1.2
DefaultProtocolOf is the built-in path matcher used when HandlerOptions.ProtocolOf is nil. It recognizes the Anthropic Messages routes plus the OpenAI Chat Completions / Responses routes (with one optional gateway/provider prefix segment).
type Reason ¶
type Reason string
Reason classifies a TransformAnthropicMessages outcome.
const ( ReasonApplied Reason = "applied" ReasonUnsupportedModel Reason = "unsupported_model" ReasonParseError Reason = "parse_error" ReasonBelowMinChars Reason = "below_min_chars" ReasonBelowMinTokens Reason = "below_min_tokens" ReasonNotProfitable Reason = "not_profitable" ReasonCompressDisabled Reason = "compress_disabled" ReasonImageLimit Reason = "image_limit" ReasonTransformError Reason = "transform_error" ReasonPassthrough Reason = "passthrough" )
type RecoverableBlock ¶
type RecoverableBlock struct {
ID string `json:"id"`
Kind string `json:"kind"`
ToolUseID string `json:"toolUseId,omitempty"`
Text string `json:"text"`
ImageCount int `json:"imageCount"`
}
RecoverableBlock carries the original text of an imaged block when EmitRecoverable is set.
type RenderOptions ¶ added in v0.2.0
type RenderOptions struct {
Model string
Cols int
Shrink *bool
Reflow bool
MaxCharsPerImage int
Style *render.RenderStyle
MaxHeightPx int
}
RenderOptions configures RenderTextToImages. When Model is set, its profile supplies unset geometry and style values.
type ResponseResult ¶ added in v0.3.0
type ResponseResult struct {
StatusCode int
Usage *ResponseUsage
}
ResponseResult describes a completed upstream response.
type ResponseUsage ¶ added in v0.3.0
type ResponseUsage struct {
InputTokens int64
OutputTokens int64
CacheCreationInputTokens int64
CacheReadInputTokens int64
}
ResponseUsage contains provider-reported token usage.
type ResponsesComposition ¶ added in v0.1.1
type ResponsesComposition struct {
Instructions int `json:"instructions"`
SystemDeveloper int `json:"systemDeveloper"`
UserAssistant int `json:"userAssistant"`
FunctionCalls int `json:"functionCalls"`
FunctionOutputs int `json:"functionOutputs"`
ReasoningEncrypted int `json:"reasoningEncrypted"`
CompactionOpaque int `json:"compactionOpaque"`
ToolsJSON int `json:"toolsJson"`
Other int `json:"other"`
TotalLocal int `json:"totalLocal"`
ImageParts int `json:"imageParts"`
CompletedFunctionPairs *int `json:"completedFunctionPairs,omitempty"`
RecentNativeFunctionPairs *int `json:"recentNativeFunctionPairs,omitempty"`
OldFunctionPairs *int `json:"oldFunctionPairs,omitempty"`
OpenFunctionCalls *int `json:"openFunctionCalls,omitempty"`
OrphanFunctionOutputs *int `json:"orphanFunctionOutputs,omitempty"`
MalformedFunctionItems *int `json:"malformedFunctionItems,omitempty"`
ImageableFunctionCalls *int `json:"imageableFunctionCalls,omitempty"`
ImageableFunctionOutputs *int `json:"imageableFunctionOutputs,omitempty"`
CollapsedFunctionPairs *int `json:"collapsedFunctionPairs,omitempty"`
CollapsedFunctionCalls *int `json:"collapsedFunctionCalls,omitempty"`
CollapsedFunctionOutputs *int `json:"collapsedFunctionOutputs,omitempty"`
BarrierTypes []string `json:"barrierTypes,omitempty"`
}
ResponsesComposition is the local o200k decomposition of a Responses request plus the planner's native-tool-state classification.
type TransformInfo ¶
type TransformInfo struct {
Compressed bool `json:"compressed"`
Reason string `json:"reason,omitempty"`
OrigChars int `json:"origChars"`
CompressedChars int `json:"compressedChars"`
ImageCount int `json:"imageCount"`
ImageBytes int `json:"imageBytes"`
ImagePixels int `json:"imagePixels,omitempty"`
OutgoingTextChars int `json:"outgoingTextChars,omitempty"`
SerializedRequestBytes int `json:"serializedRequestBytes,omitempty"`
SizeLimitOutcome string `json:"sizeLimitOutcome,omitempty"`
PinChars int `json:"pinChars,omitempty"`
PinError string `json:"pinError,omitempty"`
BillingLine string `json:"billingLine,omitempty"`
StaticChars int `json:"staticChars"`
DynamicChars int `json:"dynamicChars"`
DynamicBlockCount int `json:"dynamicBlockCount"`
UnknownStaticTags []string `json:"unknownStaticTags,omitempty"`
ChurningStaticTags []string `json:"churningStaticTags,omitempty"`
Env *EnvFields `json:"env,omitempty"`
SystemSha8 string `json:"systemSha8,omitempty"`
FirstUserSha8 string `json:"firstUserSha8,omitempty"`
FirstImagePNG []byte `json:"-"`
FirstImageWidth int `json:"firstImageWidth,omitempty"`
FirstImageHeight int `json:"firstImageHeight,omitempty"`
ImagePNGs [][]byte `json:"-"`
ImageDims []imageDim `json:"imageDims,omitempty"`
ImageSourceText string `json:"imageSourceText,omitempty"`
ToolResultImgs int `json:"toolResultImgs,omitempty"`
NativeImages int `json:"nativeImages,omitempty"`
NativeImageBytes int `json:"nativeImageBytes,omitempty"`
ImageBudgetSkips int `json:"imageBudgetSkips,omitempty"`
ImageByteSkips int `json:"imageByteSkips,omitempty"`
ImageBytesNearLimit bool `json:"imageBytesNearLimit,omitempty"`
WireImages int `json:"wireImages,omitempty"`
ToolDocsChars int `json:"toolDocsChars,omitempty"`
DroppedChars int `json:"droppedChars"`
DroppedCodepointsTop map[string]int `json:"droppedCodepointsTop,omitempty"`
PassthroughReasons map[string]int `json:"passthroughReasons,omitempty"`
GateEval *slabGateEval `json:"gateEval,omitempty"`
BucketChars map[string]int `json:"bucketChars,omitempty"`
HistoryTextChars int `json:"historyTextChars,omitempty"`
KeptSharpBlocks int `json:"keptSharpBlocks,omitempty"`
Recoverable []RecoverableBlock `json:"recoverable,omitempty"`
TruncatedToolResults int `json:"truncatedToolResults,omitempty"`
OmittedChars int `json:"omittedChars,omitempty"`
CollapsedTurns int `json:"collapsedTurns,omitempty"`
CollapsedChars int `json:"collapsedChars,omitempty"`
CollapsedImages int `json:"collapsedImages,omitempty"`
HistoryImageSha string `json:"historyImageSha,omitempty"`
HistoryFreezeStep int `json:"historyFreezeStep,omitempty"`
HistoryPackFill bool `json:"historyPackFill,omitempty"`
HistoryBudgetTrimmed bool `json:"historyBudgetTrimmed,omitempty"`
CachePrefixSha8 string `json:"cachePrefixSha8,omitempty"`
CachePrefixBytes int `json:"cachePrefixBytes,omitempty"`
CachePrefixToolsSha8 string `json:"cachePrefixToolsSha8,omitempty"`
CachePrefixSystemSha8 string `json:"cachePrefixSystemSha8,omitempty"`
CachePrefixHeadSha8 string `json:"cachePrefixHeadSha8,omitempty"`
CachePrefixMarkedSha8 string `json:"cachePrefixMarkedSha8,omitempty"`
CachePrefixMarkedBytes int `json:"cachePrefixMarkedBytes,omitempty"`
CachePrefixMarkerPos string `json:"cachePrefixMarkerPos,omitempty"`
HistoryReason string `json:"historyReason,omitempty"`
// GPT-path (OpenAI Chat/Responses) fields.
ImageTokens int `json:"imageTokens,omitempty"`
BaselineImagedTokens int `json:"baselineImagedTokens,omitempty"`
NativeInjectedTokens int `json:"nativeInjectedTokens,omitempty"`
ImageSourceTexts []string `json:"imageSourceTexts,omitempty"`
ResponsesComposition *ResponsesComposition `json:"responsesComposition,omitempty"`
// contains filtered or unexported fields
}
TransformInfo is the per-request diagnostic block (Anthropic-path subset of the TS TransformInfo).
func TransformOpenAIChatCompletions ¶ added in v0.1.1
func TransformOpenAIChatCompletions(body []byte, opts *TransformOptions) ([]byte, *TransformInfo)
TransformOpenAIChatCompletions ports transformOpenAIChatCompletions.
func TransformOpenAIResponses ¶ added in v0.1.1
func TransformOpenAIResponses(body []byte, opts *TransformOptions) ([]byte, *TransformInfo)
TransformOpenAIResponses ports transformOpenAIResponses.
func TransformRequest ¶
func TransformRequest(body []byte, opts *TransformOptions) (outBody []byte, info *TransformInfo)
TransformRequest is the Go port of pxpipe's transformRequest.
type TransformInput ¶
type TransformInput struct {
Body []byte
Model string
Options *TransformOptions
}
TransformInput is the library-level input for one Anthropic Messages body.
type TransformOptions ¶
type TransformOptions struct {
Model string
Compress *bool
CompressTools *bool
CompressToolResults *bool
MinCompressChars *int
MinToolResultChars *int
Cols *int
MaxImagesPerToolResult *int
MaxImageBytes *int
CharsPerToken *float64
HistoryAmortizationHorizon *int
PriorWarmTokens *float64
PriorWarmImageTokens *float64
Reflow *bool
KeepSharp func(KeepSharpBlock) bool
EmitRecoverable bool
// CollapseHistory gates GPT-path history imaging (default true).
CollapseHistory *bool
// GptHistory overrides GPT-path history-collapse tuning.
GptHistory *GptHistoryOptions
// contains filtered or unexported fields
}
TransformOptions mirrors the TS TransformOptions surface that applies to the Anthropic path. Nil-able fields distinguish "unset → default".
type TransformResult ¶
type TransformResult struct {
Body []byte
Model string
Applied bool
Reason Reason
Detail string
Info *TransformInfo
Cache struct {
OwnsCacheControl bool
MarkerCount int
}
}
TransformResult is the library-level outcome, including cache_control ownership so hosts do not stack a second marker injector.
func TransformAnthropicMessages ¶
func TransformAnthropicMessages(input TransformInput) *TransformResult
TransformAnthropicMessages is the model-gated library entry mirroring the TS transformAnthropicMessages wrapper.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pxpipe
command
|
|
|
internal
|
|
|
atlas
Package atlas loads the pre-baked glyph atlases (Spleen 5x8 + JetBrains Mono 10/12/14; 1-bit and 8-bit grayscale companions) dumped from the pxpipe TS reference implementation.
|
Package atlas loads the pre-baked glyph atlases (Spleen 5x8 + JetBrains Mono 10/12/14; 1-bit and 8-bit grayscale companions) dumped from the pxpipe TS reference implementation. |
|
o200k
Package o200k provides an offline o200k_base token counter.
|
Package o200k provides an offline o200k_base token counter. |
|
Package render ports pxpipe's text→PNG renderer: it wraps text onto a fixed-pitch glyph grid (Spleen 5x8 or JetBrains Mono atlases) and encodes dense grayscale/RGB PNG pages sized for Anthropic's vision tiling.
|
Package render ports pxpipe's text→PNG renderer: it wraps text onto a fixed-pitch glyph grid (Spleen 5x8 or JetBrains Mono atlases) and encodes dense grayscale/RGB PNG pages sized for Anthropic's vision tiling. |
