Package org.machanism.machai.ai.provider.impl
This package contains provider adapters that connect Machai's common AI interfaces to specific runtime backends and tool execution strategies. The implementations translate prompts, instructions, tool definitions, web-search configuration, MCP server configuration, embedding requests, and usage accounting between Machai's internal provider model and the corresponding external API or local execution mechanism.
Included providers
OpenAIProvideradapts the OpenAI Java SDK Responses API and embedding API. It supports conversational prompting, function tools, MCP tools, web search, usage tracking, and embedding generation for OpenAI-compatible endpoints.AnthropicProvideradapts the Anthropic Java SDK Beta Messages API. It supports message construction, local function tools, optional web search (versions20250305and20260209), MCP server forwarding, prompt-cache control for the last registered tool, and usage tracking.CodeMieProviderintegrates with EPAM CodeMie authentication, obtains an OAuth 2.0 access token via password-grant or client-credentials flow, and delegates requests to an appropriate downstream provider based on the configured model prefix:gpt-*,gemini-*,text-embedding-*,codemie-text-embedding-*, andamazon.titan-embed-text-*prefixes are routed toOpenAIProvider;claude-*prefixes are routed toAnthropicProvider.ToolsProviderexecutes locally registered function tools directly from structured YAML prompts, which is useful for tool-only workflows and deterministic host-side execution. It operates in a fail-fast mode: exceptions from tool execution are propagated immediately rather than being returned as model text.NoneProvideris a disabled provider implementation for configurations that intentionally perform no AI work. It discards submitted input and returnsnull. Initializing it with the"log"model enables INFO-level logging of provider calls; any other model disables that diagnostic logging.
Typical usage
Applications normally create a provider through the higher-level Machai
provider factory or adapter APIs, initialize it with a model name and a
Configurator, add any
required prompts or tools, and call perform() to execute the request.
Providers may be reused after calling clear() to reset accumulated
conversation input. Provider-specific setup, including credentials and
endpoint configuration, must be supplied through the configurator before
initialization.
Genai provider = new OpenAIProvider();
provider.init("gpt-4.1", configurator);
provider.prompt("Summarize the project architecture.");
String answer = provider.perform();
provider.clear();
The ToolsProvider uses the
special model name "yaml" and interprets the last submitted prompt as
a YAML tool-call descriptor:
ToolsProvider provider = new ToolsProvider();
provider.init("yaml", configurator);
// Register tools through a package-specific adapter or subclass.
provider.prompt("tool: myTool\nparams:\n key: value");
String result = provider.perform();
Configuration keys such as API credentials, base URLs, timeouts, maximum output tokens, tool-call limits, MCP endpoints, and web-search options are interpreted by the individual provider implementations. See each provider's class-level documentation for the supported keys and backend-specific behavior.
- Since:
- 1.2.0
- Author:
- Viktor Tovstyi
-
ClassesClassDescriptionAnthropic-backed implementation of Machai's
Genaiabstraction.Genaiimplementation that integrates with EPAM CodeMie.No-op implementation ofGenaithat performs no AI processing.OpenAI-backedGenaiimplementation.AI provider implementation for managing and invoking host-defined function tools.