ccproxy.llms.formatters.common¶
ccproxy.llms.formatters.common
¶
Shared helpers used by formatter adapters.
IndexedToolCallTracker
¶
ObfuscationTokenFactory
¶
ReasoningBuffer
¶
ReasoningPartState
dataclass
¶
ReasoningPartState(
buffer=list(), signature=None, open=False
)
Mutable reasoning buffer for a specific summary segment.
ToolCallState
dataclass
¶
ToolCallState(
id,
index,
call_id=None,
item_id=None,
name=None,
arguments="",
arguments_parts=list(),
output_index=-1,
emitted=False,
initial_emitted=False,
name_emitted=False,
arguments_emitted=False,
arguments_done_emitted=False,
item_done_emitted=False,
added_emitted=False,
completed=False,
final_arguments=None,
)
Mutable state for a single streaming tool call.
ToolCallTracker
¶
ThinkingSegment
dataclass
¶
Lightweight reasoning segment mirroring Anthropic's ThinkingBlock.
ensure_identifier
¶
Return a stable identifier and suffix for the given prefix.
If an existing identifier already matches the prefix we reuse its suffix.
Existing identifiers that begin with resp_ are also understood so both
resp and alternate prefixes can build consistent derived identifiers.
Source code in ccproxy/llms/formatters/common/identifiers.py
normalize_suffix
¶
Return the suffix part of an identifier split on the first underscore.
build_anthropic_tool_use_block
¶
Create an Anthropic ToolUseBlock from a tracked tool-call state.
Source code in ccproxy/llms/formatters/common/streams.py
emit_anthropic_tool_use_events
¶
Build start/stop events for a tool-use block at the given index.
Source code in ccproxy/llms/formatters/common/streams.py
merge_thinking_segments
¶
Collapse adjacent segments that share the same signature.
Source code in ccproxy/llms/formatters/common/thinking.py
convert_anthropic_usage_to_openai_completion_usage
¶
Translate Anthropic Usage values into OpenAI Completion usage.
Source code in ccproxy/llms/formatters/common/usage.py
convert_anthropic_usage_to_openai_responses_usage
¶
Translate Anthropic Usage values into OpenAI Responses usage.
Source code in ccproxy/llms/formatters/common/usage.py
convert_openai_completion_usage_to_responses_usage
¶
Map Completion usage payloads into Responses Usage structures.
Source code in ccproxy/llms/formatters/common/usage.py
convert_openai_responses_usage_to_anthropic_usage
¶
Translate OpenAI Responses usage into Anthropic Usage models.
Source code in ccproxy/llms/formatters/common/usage.py
convert_openai_responses_usage_to_completion_usage
¶
Normalize Responses usage into the legacy CompletionUsage envelope.