Interface ProcessProvider
- All Known Implementing Classes:
AbstractAIProvider,AbstractAIProvider,AnthropicProvider,CodeMieProvider,CodeMieProvider.ClaudeProviderExtension,CodeMieProvider.OpenAIProviderExtension,NoneProvider,OpenAIProvider,ProcessProviderAdapter,ToolsProvider
A ProcessProvider represents a concrete implementation (for example OpenAI,
Gemini, a local model, etc.) capable of:
- Collecting prompts and system instructions for a conversation,
- Attaching local or remote files for provider-side processing,
- Registering tool functions that may be invoked during a run.
Implementations may keep session state between calls. Use clear() to
reset conversation state.
Typical usage
Configurator conf = ...;
ProcessProvider provider = ProcessProviderManager.getProvider("OpenAI:gpt-4o-mini", conf);
provider.instructions("You are a helpful assistant.");
provider.prompt("Hello!");
String response = provider.perform();
provider.clear();
- Author:
- Viktor Tovstyi
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPrompts(FunctionTools tools) Scans the providedFunctionToolsinstance for methods annotated withPromptand registers each prompt for use during a run.voidaddResources(FunctionTools tools) Scans the providedFunctionToolsinstance for methods annotated withResource, and registers each resource for use during a run.voidaddTools(FunctionTools tools, String[] enabledTools) Registers the tools exposed by the givenFunctionToolsimplementation, optionally restricting registration to a filtered subset of tools.voidclear()Clears any stored files and session/provider state.Returns the names of tools currently registered with the provider.voidinit(String model, Configurator conf) Initializes the provider with application configuration.voidinstructions(String instructions) Sets system/session instructions for the current conversation.perform()Executes the provider to produce a response based on the accumulated prompts, instructions, files, and registered capabilities.voidAdds a user prompt to the current session.voidsetErrorHandling(boolean errorHandling) Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions.voidsetProjectDir(File projectDir) Sets the working directory for the provider, which may be supplied to tool, prompt, and resource handlers.
-
Method Details
-
init
Initializes the provider with application configuration.- Parameters:
model- the model identifier or name to useconf- configuration source used to initialize the provider- Throws:
IllegalArgumentException- if the model or configuration is invalid
-
prompt
Adds a user prompt to the current session.Prompts are accumulated until
perform()orclear()is called. The exact message format sent to the provider is implementation specific.- Parameters:
text- the prompt text
-
clear
void clear()Clears any stored files and session/provider state.This resets the conversation and any accumulated context.
-
instructions
Sets system/session instructions for the current conversation.Calling this method replaces any previously configured instructions. A
nullvalue may be used to clear them when supported by the implementation.- Parameters:
instructions- instruction text
-
perform
String perform()Executes the provider to produce a response based on the accumulated prompts, instructions, files, and registered capabilities.Whether the accumulated session is retained after execution is provider specific. Call
clear()when a new independent conversation is required.- Returns:
- the provider response as a string
-
addTools
Registers the tools exposed by the givenFunctionToolsimplementation, optionally restricting registration to a filtered subset of tools.Implementations are expected to discover tool definitions on the provided
toolsinstance (typically via annotated methods) and make them available for use, applying the enablement filter described below.- Parameters:
tools- theFunctionToolsimplementation containing the tool definitions to register; must not benull.enabledTools- an optional array of regular expression patterns controlling which tools are registered.Each tool is identified internally by a fully qualified name built in the format
<ClassName>:<toolName>, where:<ClassName>is the fully qualified class name of thetoolsimplementation, and<toolName>is the tool's declared name (or the method name if no explicit name is provided).
enabledToolsisnull, all available tools are registered without filtering.
-
getToolNames
Returns the names of tools currently registered with the provider.The returned names may be used for diagnostics, filtering, request construction, or tool-invocation processing. The ordering and mutability of the returned list are provider-specific.
- Returns:
- the names of registered tools, or an empty list when no tools are registered
-
addPrompts
Scans the providedFunctionToolsinstance for methods annotated withPromptand registers each prompt for use during a run.The prompt name, description, role, and parameters are obtained from the annotation and the method signature.
- Parameters:
tools- theFunctionToolsinstance whose methods will be scanned forPromptannotations
-
addResources
Scans the providedFunctionToolsinstance for methods annotated withResource, and registers each resource for use during a run.This method inspects the given class instance to register resource utilities that can be dynamically called by the AI model during generation processes.
- Parameters:
tools- theFunctionToolsinstance whose methods will be scanned for resource annotations
-
setProjectDir
Sets the working directory for the provider, which may be supplied to tool, prompt, and resource handlers.- Parameters:
projectDir- the project directory, ornullto clear the current directory
-
setErrorHandling
void setErrorHandling(boolean errorHandling) Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions. This setting does not suppress provider or configuration errors unrelated to tool invocation.- Parameters:
errorHandling-trueto return tool errors as response text;falseto propagate them immediately
-