Package org.machanism.machai.process.provider
The package separates provider-facing orchestration from provider-specific
transport code. ProcessProvider defines the common lifecycle for
initialization, instructions, prompts, tool and resource registration,
execution, project-directory context, error handling, and state clearing.
Implementations may retain conversation or request state between calls, so a
caller should use ProcessProvider.clear() when beginning an
independent request and should not assume that every implementation has the
same execution semantics.
Provider contracts and decorators
-
ProcessProvideris the primary abstraction for conversational or process-oriented providers.EmbeddingProvideris the separate contract for providers that turn text into embedding vectors. -
ProcessProviderAdapteris a delegating implementation useful for decorating a provider with application-level concerns such as logging, metrics, retries, or request shaping. Set its delegate before forwarding lifecycle calls. -
AbstractAIProvidersupplies shared state and reflection-based registration for methods annotated withTool,Prompt, andResource. It also provides model, configuration, project-directory, instruction, token-limit, and tool-error handling state for concrete subclasses.
Included implementations
-
NoneProvideris an intentional no-op provider. It accepts lifecycle input without retaining or processing it, returnsnullfromNoneProvider.perform(), and always reports an immutable empty tool list. Initializing it with model"log"enables diagnostic INFO messages; other model values disable those messages. -
ToolsProvideris a lightweight local dispatcher. It stores prompts, keeps registered tools in registration order, and, when initialized with model"yaml", parses the most recently submitted prompt as a YAML mapping. The mapping must contain atoolname and may containparams; the named function is invoked, with non-string results serialized as JSON. A YAML execution requires at least one prompt. Register annotated functions throughProcessProvider.addTools(org.machanism.machai.process.tools.FunctionTools, String[])rather than calling the protected registration hook directly.
Supporting utilities
ToolLogger records tool, prompt, and resource invocation details while
abbreviating payloads at INFO level and retaining complete payloads at DEBUG
level. TypeConverter converts reflected tool parameters from string
or JSON representations and maps Java parameter types to simplified schema
type names. These utilities support the provider infrastructure and are not
provider-selection mechanisms.
Typical usage
The following example registers annotated host functions and dispatches a
YAML request. The YAML tool value must match a registered function
name; the Configurator setup is application-specific.
ProcessProvider provider = new ToolsProvider();
provider.init("yaml", configurator);
provider.addTools(functionTools, null);
provider.prompt("tool: summarize\nparams:\n path: README.md");
String result = provider.perform();
provider.clear();
Use the no-op implementation when processing must be deliberately disabled:
ProcessProvider provider = new NoneProvider();
provider.init("log", configurator);
provider.prompt("This input is accepted and discarded.");
String result = provider.perform(); // always null
- Since:
- 1.2.0
- See Also:
-
ClassDescriptionBase implementation of the
ProcessProvidercontract shared by concrete provider integrations.EmbeddingProvider defines the contract for AI embedding providers.No-op implementation ofProcessProviderthat performs no AI processing.Contract for a generative-AI provider integration.DelegatingProcessProviderimplementation.Internal logging utility for tool inputs, results, and execution errors.Defines the types of operations whose activity can be logged.AI provider implementation for managing and invoking host-defined function tools.Utility class for converting between Java types and their string representations, as well as mapping Java types to simplified type names (e.g., "string", "integer", "array").