Package org.machanism.machai.ai.manager


package org.machanism.machai.ai.manager
Provider-resolution and usage-tracking infrastructure for generative-AI integrations.

This package contains the manager-side API used to resolve Genai implementations from provider and model identifiers, initialize them with application configuration, and collect token-consumption statistics across provider invocations.

Core responsibilities

  • Resolve a concrete provider implementation from a model identifier such as OpenAI:gpt-4o-mini or a provider-specific class name.
  • Initialize provider instances using a Configurator.
  • Capture and aggregate per-call Usage metrics for logging.

Included types

  • GenaiProviderManager creates and initializes provider instances and logs aggregated token usage.
  • Usage represents immutable token-usage metrics for a single AI interaction.

Provider identifiers

Provider resolution expects identifiers in the form Provider:Model. When the provider segment is omitted, the implementation falls back to the default "none" provider while preserving the supplied model value. Short provider names are mapped to conventional implementation class names under org.machanism.machai.ai.provider, while fully qualified class names may also be supplied directly.

Typical usage


 Configurator conf = ...;
 Genai provider = GenaiProviderManager.getProvider("OpenAI:gpt-4o-mini", conf);

 provider.prompt("Summarize this project.");
 String response = provider.perform();

 GenaiProviderManager.addUsage(provider.usage());
 GenaiProviderManager.logUsage();