Class ContextProvider

java.lang.Object
uno.anahata.ai.context.provider.ContextProvider
Direct Known Subclasses:
ApplicationFramesContextProvider, ChatStatusProvider, ContextSummaryProvider, CoreSystemInstructionsMdFileProvider, EnvironmentVariablesProvider, StatefulResourcesProvider, SystemPropertiesProvider

public abstract class ContextProvider extends Object
An abstract base class for modules that contribute dynamic context or instructions to the AI model's prompt.

Context providers are executed before each request to the model. They can provide system instructions, workspace information, or any other relevant data that should be included in the context.

This class manages the enabled/disabled state and the target position within the prompt.

  • Constructor Details

    • ContextProvider

      public ContextProvider(ContextPosition pos)
      Constructs a ContextProvider with a specific target position.
      Parameters:
      pos - The position in the prompt where this provider's content should be placed.
  • Method Details

    • getId

      public abstract String getId()
      Gets the unique identifier for this provider.

      This ID is used for internal tracking, configuration, and persistence.

      Returns:
      A non-null, unique string ID (e.g., "core-context-summary").
    • getDisplayName

      public abstract String getDisplayName()
      Gets the human-readable display name for this provider.
      Returns:
      A non-null, descriptive name.
    • getDescription

      public String getDescription()
      Gets a brief, human-readable description of what this provider does.
      Returns:
      The description.
    • getParts

      public abstract List<com.google.genai.types.Part> getParts(Chat chat)
      Generates a list of Part objects to be included in the model's prompt.

      This method is called by the ContentFactory before each request. Implementations should be efficient and avoid long-running operations.

      Parameters:
      chat - The current Chat instance, providing access to the session state.
      Returns:
      A list of Parts, or an empty list if the provider has no content to add.