Class AnthropicToolConverter

java.lang.Object
com.tnsai.llm.providers.AnthropicToolConverter

public final class AnthropicToolConverter extends Object
Translates the OpenAI-flavoured intermediate tool schema into Anthropic's Messages-API tool shape.

The framework's ToolSchemaGenerator emits tools in an OpenAI-flavoured intermediate form: each tool is {"type":"function","function":{name,description,parameters,examples}}. Anthropic's tool definition is flatter — name, description, input_schema, optional input_examples — and splits @ToolExample handling across two surfaces:

  • input_examples carries flat positive input objects.
  • description absorbs negative examples (Claude has no native negative-examples surface).

Used by AnthropicClient for direct Claude calls and by BedrockClient for Bedrock-hosted Anthropic Claude models — the on-wire tool contract is identical between the two. Bedrock documents the same Messages-API tool schema for anthropic.* model IDs.

See Also:
  • Method Details

    • convertToClaudeTools

      public static List<Map<String,Object>> convertToClaudeTools(List<Map<String,Object>> tools)
      Convert an OpenAI-flavoured tool list into Anthropic's tool list.

      Tools whose type is not "function", or whose function object is missing, are skipped silently — the intermediate schema only emits function-typed entries today.

      Parameters:
      tools - intermediate tools (OpenAI shape); never null
      Returns:
      Anthropic-shaped tools; empty list if the input is empty