Interface Genai

All Known Implementing Classes:
AbstractAIProvider, AnthropicProvider, CodeMieProvider, GenaiAdapter, OpenAIProvider, ToolsProvider

public interface Genai
Contract for a generative-AI provider integration.

A Genai 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 = ...;
 Genai provider = GenaiProviderManager.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 Type
    Method
    Description
    void
    addPrompts(FunctionTools functionTool)
    Scans the provided FunctionTools instance for methods annotated with Prompt, and registers each prompt for use during a run.
    void
    Registers a set of tool functions that may be invoked during a run.
    void
    Clears any stored files and session/provider state.
    void
    init(String model, Configurator conf)
    Initializes the provider with application configuration.
    void
    inputsLog(File bindexTempDir)
    Enables logging of provider inputs to the given directory.
    void
    instructions(String instructions)
    Sets system/session instructions for the current conversation.
    Executes the provider to produce a response based on the accumulated prompts and state.
    void
    prompt(String text)
    Adds a user prompt to the current session.
    void
    setErrorHandling(boolean errorHandling)
    Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions.
    void
    setProjectDir(File projectDir)
    Sets the working directory for the provider, which may be used by tool handlers.
  • Method Details

    • init

      void init(String model, Configurator conf)
      Initializes the provider with application configuration.
      Parameters:
      model - the model identifier or name to use
      conf - configuration source
    • prompt

      void prompt(String text)
      Adds a user prompt to the current session.
      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

      void instructions(String instructions)
      Sets system/session instructions for the current conversation.
      Parameters:
      instructions - instruction text
    • perform

      String perform()
      Executes the provider to produce a response based on the accumulated prompts and state.
      Returns:
      the provider response as a string
    • inputsLog

      void inputsLog(File bindexTempDir)
      Enables logging of provider inputs to the given directory.
      Parameters:
      bindexTempDir - directory used for writing log files
    • addTools

      void addTools(FunctionTools tools)
      Registers a set of tool functions that may be invoked during a run.
      Parameters:
      tools - the FunctionTools instance containing tool methods
    • addPrompts

      void addPrompts(FunctionTools functionTool)
      Scans the provided FunctionTools instance for methods annotated with Prompt, and registers each prompt for use during a run.
      Parameters:
      functionTool - the FunctionTools instance whose methods will be scanned for Prompt annotations
    • setProjectDir

      void setProjectDir(File projectDir)
      Sets the working directory for the provider, which may be used by tool handlers.
      Parameters:
      projectDir - the project directory
    • setErrorHandling

      void setErrorHandling(boolean errorHandling)
      Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions.
      Parameters:
      errorHandling - true to return tool errors as response text; false to propagate them immediately