Class GenericGenaiAdapter<TExchange,TSpecification>

java.lang.Object
org.machanism.machai.ai.provider.AbstractAIProvider
org.machanism.machai.mcp.server.GenericGenaiAdapter<TExchange,TSpecification>
Type Parameters:
TExchange - the type representing the server exchange/context
TSpecification - the type representing the tool specification
All Implemented Interfaces:
Genai

public class GenericGenaiAdapter<TExchange,TSpecification> extends AbstractAIProvider
A generic adapter for integrating GenAI tools with different server implementations.

This class abstracts the process of registering tools and their schemas, allowing for flexible integration with various server types by parameterizing the exchange and specification types.

Since:
1.2.0
Author:
Viktor Tovstyi
  • Constructor Details

    • GenericGenaiAdapter

      public GenericGenaiAdapter(List<TSpecification> toolSpecifications, AbstractMcpServer.ToolSpecificationBuilder<TExchange> builder)
      Constructs a new GenericGenaiAdapter.
      Parameters:
      toolSpecifications - the list to which tool specifications will be added
      builder - the builder responsible for creating tool and specification objects
  • Method Details

    • addTool

      protected void addTool(String name, String description, ToolFunction function, ParamDescriptor... paramsDesc)
      Registers a new tool with the adapter.
      Specified by:
      addTool in class AbstractAIProvider
      Parameters:
      name - the name of the tool
      description - the description of the tool
      function - the function to execute when the tool is called
      paramsDesc - the parameter descriptions for the tool, each in the format "name:type:required:description"
    • toHumanReadable

      public static String toHumanReadable(String toolName)
      Converts a function tool name in Python style (snake_case or camelCase) to a human-readable format. Examples: "my_function_tool" -> "My Tool Tool" "doSomething_cool" -> "Do Something Cool" "anotherToolName" -> "Another Tool Name"
      Parameters:
      toolName - the function tool name to convert
      Returns:
      the human-readable format
    • perform

      public String perform()