common

package
v7.2.91 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSSEEventBytes

func AppendSSEEventBytes(out []byte, event string, payload []byte, trailingNewlines int) []byte

func AppendSSEEventString

func AppendSSEEventString(out []byte, event, payload string, trailingNewlines int) []byte

func AttachCacheControl added in v7.2.55

func AttachCacheControl(dst []byte, src gjson.Result) []byte

AttachCacheControl copies a Claude-compatible cache_control object from src onto dst. Returns dst unchanged when cache_control is missing or not an object.

func AttachMessageCacheControl added in v7.2.55

func AttachMessageCacheControl(msg []byte, src gjson.Result) []byte

AttachMessageCacheControl applies message-level cache_control onto the last content block. Part-level cache_control wins when the last block already has one. String content is promoted to a content array so Claude can accept cache_control.

func ClaudeInputTokensJSON

func ClaudeInputTokensJSON(count int64) []byte

func ClaudeMessageSystemReminderText added in v7.2.30

func ClaudeMessageSystemReminderText(content gjson.Result) (string, bool)

ClaudeMessageSystemReminderText converts a Claude message-level system value into ordinary user-visible reminder text for non-Claude upstream formats.

func GeminiTokenCountJSON

func GeminiTokenCountJSON(count int64) []byte

func InteractionsUsage added in v7.2.51

func InteractionsUsage(root gjson.Result) gjson.Result

func JoinRawArray added in v7.2.89

func JoinRawArray(items [][]byte) []byte

func NewRawArrayItems added in v7.2.89

func NewRawArrayItems(capacity int64) [][]byte

NewRawArrayItems creates a raw item slice sized for the expected input.

func NormalizeOpenAIFileData added in v7.2.90

func NormalizeOpenAIFileData(filename, fallbackMIMEType, fileData string) (mimeType, data string, ok bool)

NormalizeOpenAIFileData returns the MIME type and raw base64 payload for OpenAI file content.

func SSEEventData

func SSEEventData(event string, payload []byte) []byte

func SetRawArrayItems added in v7.2.89

func SetRawArrayItems(data []byte, path string, items [][]byte) []byte

SetRawArrayItems replaces an empty JSON array at path with raw items. The single-item path avoids allocating an intermediate joined array.

Types

This section is empty.

Jump to

Keyboard shortcuts

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