Package org.machanism.machai.ai.manager
Interface GenAIProvider
- All Known Implementing Classes:
NoneProvider,OpenAIProvider,WebProvider
public interface GenAIProvider
Interface for generic AI providers (GenAIProvider) supporting prompts, file
operations, and tool augmentation.
Implementations should provide concrete behavior for each method, supporting model-specific logic, resource/file handling, embeddings, and extensibility through function tools.
Usage example:
provider.prompt("Hello!");
provider.addFile(new File("some.txt"));
List<Float> emb = provider.embedding("any text");
- Author:
- Viktor Tovstyi
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a file for processing.voidAdds a file via a URL (downloads/uses remote file).voidAdds a custom function tool to the provider for runtime invocation.voidclear()Clears all internal state and stored files for this provider instance.Returns the embedding vector for the supplied string using the underlying model.voidLogs input events, optionally into a temporary directory.voidinstructions(String instructions) Sets or updates instruction text for the provider session.voidSelects the model name for this provider instance.perform()Performs the main action, typically runs or triggers model output.voidSends a prompt string to the provider.voidpromptFile(File file, String bundleMessageName) Sends a prompt using the contents of a file.voidsetWorkingDir(File workingDir)
-
Method Details
-
prompt
Sends a prompt string to the provider.- Parameters:
text- The input prompt string
-
promptFile
Sends a prompt using the contents of a file.- Parameters:
file- The input filebundleMessageName- The message identifier or bundle- Throws:
IOException- If file cannot be read
-
addFile
Adds a file for processing.- Parameters:
file- File to be added- Throws:
IOException- For IO/file errorsFileNotFoundException- If file cannot be found
-
addFile
Adds a file via a URL (downloads/uses remote file).- Parameters:
fileUrl- URL for file- Throws:
IOException- For IO/file errorsFileNotFoundException- If remote file cannot be found
-
embedding
-
clear
void clear()Clears all internal state and stored files for this provider instance. -
addTool
void addTool(String name, String description, Function<Object[], Object> function, String... paramsDesc) Adds a custom function tool to the provider for runtime invocation.- Parameters:
name- Tool/function namedescription- Description of function/toolfunction- The function accepting a JsonNode and returning an ObjectparamsDesc- Parameter descriptions
-
instructions
Sets or updates instruction text for the provider session.- Parameters:
instructions- Usage/setup instructions
-
perform
String perform()Performs the main action, typically runs or triggers model output.- Returns:
- Output result or response
-
inputsLog
Logs input events, optionally into a temporary directory.- Parameters:
bindexTempDir- Directory for writing logs
-
model
Selects the model name for this provider instance.- Parameters:
chatModelName- The name of the model in use
-
setWorkingDir
-