Documentation
¶
Overview ¶
Package toolconverters provides utilities for converting MCP tool definitions to various LLM provider formats.
Index ¶
- func ConvertAnthropicToolCallsToSharedTypes(ctx *logging.ContextMap, contentBlocks []anthropic.ContentBlockUnion) ([]sharedtypes.ToolCall, []error)
- func ConvertAzureToolCallsToSharedTypes(ctx *logging.ContextMap, toolCalls []openai.ChatCompletionMessageToolCallUnion) ([]sharedtypes.ToolCall, []error)
- func ConvertMCPToAnthropicFormat(ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool) ([]anthropic.ToolUnionParam, []error)
- func ConvertMCPToAzureFormat(ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool) ([]openai.ChatCompletionToolUnionParam, []error)
- func ConvertMCPToOpenAIFormat(ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool) ([]openai.ChatCompletionToolUnionParam, []error)
- func ConvertOpenAIToolCallsToSharedTypes(ctx *logging.ContextMap, ...) ([]sharedtypes.ToolCall, []error)
- func ConvertSharedTypesToAnthropicToolCalls(ctx *logging.ContextMap, toolCalls []sharedtypes.ToolCall) ([]anthropic.ContentBlockParamUnion, []error)
- func ConvertSharedTypesToOpenAIToolCalls(ctx *logging.ContextMap, toolCalls []sharedtypes.ToolCall) ([]openai.ChatCompletionMessageToolCallUnionParam, []error)
- func SanitizeToolName(name string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertAnthropicToolCallsToSharedTypes ¶
func ConvertAnthropicToolCallsToSharedTypes( ctx *logging.ContextMap, contentBlocks []anthropic.ContentBlockUnion, ) ([]sharedtypes.ToolCall, []error)
ConvertAnthropicToolCallsToSharedTypes converts Anthropic content blocks containing tool_use blocks to shared ToolCall format.
Parameters:
ctx: The logging context map. contentBlocks: Array of Anthropic response content blocks.
Returns:
[]sharedtypes.ToolCall: Shared format tool calls. []error: List of errors for tool calls that were skipped during conversion.
func ConvertAzureToolCallsToSharedTypes ¶
func ConvertAzureToolCallsToSharedTypes( ctx *logging.ContextMap, toolCalls []openai.ChatCompletionMessageToolCallUnion, ) ([]sharedtypes.ToolCall, []error)
ConvertAzureToolCallsToSharedTypes converts Azure OpenAI tool call responses to the shared ToolCall format used throughout the AALI framework. Azure OpenAI Service uses the same response format as OpenAI.
func ConvertMCPToAnthropicFormat ¶
func ConvertMCPToAnthropicFormat( ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool, ) ([]anthropic.ToolUnionParam, []error)
ConvertMCPToAnthropicFormat converts MCP tools to Anthropic tool definition format.
Parameters:
ctx: The logging context map. mcpTools: Array of MCP tool definitions (typed MCPTool structs).
Returns:
[]anthropic.ToolUnionParam: Anthropic formatted tools. []error: List of errors (empty for typed input, kept for API compatibility).
func ConvertMCPToAzureFormat ¶
func ConvertMCPToAzureFormat( ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool, ) ([]openai.ChatCompletionToolUnionParam, []error)
ConvertMCPToAzureFormat converts MCP tool definitions to Azure OpenAI format. Azure OpenAI Service uses the same SDK and format as OpenAI, so this function wraps the OpenAI converter for clarity and future flexibility.
func ConvertMCPToOpenAIFormat ¶
func ConvertMCPToOpenAIFormat( ctx *logging.ContextMap, mcpTools []sharedtypes.MCPTool, ) ([]openai.ChatCompletionToolUnionParam, []error)
ConvertMCPToOpenAIFormat converts MCP tools to OpenAI function calling format.
Parameters:
ctx: The logging context map. mcpTools: Array of MCP tool definitions (typed MCPTool structs).
Returns:
[]openai.ChatCompletionToolUnionParam: OpenAI formatted tools. []error: List of errors (empty for typed input, kept for API compatibility).
func ConvertOpenAIToolCallsToSharedTypes ¶
func ConvertOpenAIToolCallsToSharedTypes( ctx *logging.ContextMap, openaiToolCalls []openai.ChatCompletionMessageToolCallUnion, ) ([]sharedtypes.ToolCall, []error)
ConvertOpenAIToolCallsToSharedTypes converts OpenAI SDK tool calls to shared ToolCall format.
Parameters:
ctx: The logging context map. openaiToolCalls: Array of OpenAI tool call responses.
Returns:
[]sharedtypes.ToolCall: Shared format tool calls. []error: List of errors for tool calls that were skipped during conversion.
func ConvertSharedTypesToAnthropicToolCalls ¶
func ConvertSharedTypesToAnthropicToolCalls( ctx *logging.ContextMap, toolCalls []sharedtypes.ToolCall, ) ([]anthropic.ContentBlockParamUnion, []error)
ConvertSharedTypesToAnthropicToolCalls converts shared ToolCall format to Anthropic content blocks for conversation history reconstruction.
Parameters:
ctx: The logging context map. toolCalls: Array of shared format tool calls.
Returns:
[]anthropic.ContentBlockParamUnion: Anthropic formatted content blocks. []error: List of errors for tool calls that failed conversion.
func ConvertSharedTypesToOpenAIToolCalls ¶
func ConvertSharedTypesToOpenAIToolCalls( ctx *logging.ContextMap, toolCalls []sharedtypes.ToolCall, ) ([]openai.ChatCompletionMessageToolCallUnionParam, []error)
ConvertSharedTypesToOpenAIToolCalls converts shared ToolCall format to OpenAI SDK tool call params. This is used when reconstructing conversation history with assistant messages that made tool calls.
Parameters:
ctx: The logging context map. toolCalls: Array of shared format tool calls.
Returns:
[]openai.ChatCompletionMessageToolCallUnionParam: OpenAI formatted tool call params. []error: List of errors for tool calls that failed conversion.
func SanitizeToolName ¶
sanitizeToolName converts tool names to OpenAI-compatible format.
Types ¶
This section is empty.