Versions in this module Expand all Collapse all v1 v1.0.0 Aug 13, 2025 Changes in this version + const DefaultPromptTemplate + const MaxFunctionNameLength + const MaxPrefixLength + func ApplyOptions(adapter *Adapter, opts []Option) + func ExtractFunctionCalls(candidates []string) []functionCall + func ExtractFunctionCallsDetailed(candidates []string) ([]functionCall, bool) + func HasCompleteJSON(content string) bool + func ValidateFunctionCall(call functionCall) bool + func ValidateFunctionCallArray(calls []functionCall) bool + func ValidateFunctionName(name string) error + type Adapter struct + func New(opts ...Option) *Adapter + func (a *Adapter) GenerateToolCallID() string + func (a *Adapter) TransformCompletionsRequest(req openai.ChatCompletionNewParams) (openai.ChatCompletionNewParams, error) + func (a *Adapter) TransformCompletionsRequestWithContext(ctx context.Context, req openai.ChatCompletionNewParams) (openai.ChatCompletionNewParams, error) + func (a *Adapter) TransformCompletionsResponse(resp openai.ChatCompletion) (openai.ChatCompletion, error) + func (a *Adapter) TransformCompletionsResponseWithContext(ctx context.Context, resp openai.ChatCompletion) (openai.ChatCompletion, error) + func (a *Adapter) TransformStreamingResponse(stream ChatCompletionStreamInterface) *StreamAdapter + func (a *Adapter) TransformStreamingResponseWithContext(ctx context.Context, stream ChatCompletionStreamInterface) *StreamAdapter + type ChatCompletionStreamInterface interface + Close func() error + Current func() openai.ChatCompletionChunk + Err func() error + Next func() bool + type FunctionCallDetectionData struct + ContentLength int + FunctionCount int + FunctionNames []string + JSONCandidates int + Performance PerformanceMetrics + Streaming bool + func (d FunctionCallDetectionData) EventType() MetricEvent + type JSONCandidate struct + Content []rune + End int + Start int + type JSONExtractor struct + func NewJSONExtractor(input string) *JSONExtractor + func (je *JSONExtractor) ExtractJSONBlocks() []string + type MetricEvent string + const MetricEventFunctionCallDetection + const MetricEventToolTransformation + type MetricEventData interface + EventType func() MetricEvent + type Option func(*Adapter) + func DefaultOptions() []Option + func WithCancelUpstreamOnStop(cancel bool) Option + func WithCustomPromptTemplate(template string) Option + func WithLogLevel(level slog.Level) Option + func WithLogger(logger *slog.Logger) Option + func WithMetricsCallback(callback func(MetricEventData)) Option + func WithPromptBufferReuseLimit(thresholdBytes int) Option + func WithStreamingEarlyDetection(lookAheadChars int) Option + func WithStreamingToolBufferSize(limitBytes int) Option + func WithSystemMessageSupport(supported bool) Option + func WithToolCollectMaxBytes(maxBytes int) Option + func WithToolCollectWindow(duration time.Duration) Option + func WithToolMaxCalls(maxCalls int) Option + func WithToolPolicy(policy ToolPolicy) Option + type ParseState int + const StateInArray + const StateInEscape + const StateInObject + const StateInString + type PerformanceMetrics struct + MemoryAllocatedBytes int64 + ProcessingDuration time.Duration + SubOperations map[string]time.Duration + type StreamAdapter struct + func (s *StreamAdapter) Close() error + func (s *StreamAdapter) Current() openai.ChatCompletionChunk + func (s *StreamAdapter) Err() error + func (s *StreamAdapter) Next() bool + type ToolPolicy int + const ToolAllowMixed + const ToolCollectThenStop + const ToolDrainAll + const ToolStopOnFirst + func (tp ToolPolicy) String() string + type ToolTransformationData struct + Performance PerformanceMetrics + PromptLength int + ToolCount int + ToolNames []string + func (d ToolTransformationData) EventType() MetricEvent Other modules containing this package github.com/juburr/openai-tool-adapter/v2 github.com/juburr/openai-tool-adapter/v3