Class ContentFactory

java.lang.Object
uno.anahata.ai.context.provider.ContentFactory

public class ContentFactory extends Object
A factory for generating content parts from registered ContextProviders.

This class orchestrates the execution of context providers based on their assigned ContextPosition. it supports both sequential and parallel execution of providers.

Author:
anahata
  • Constructor Details

    • ContentFactory

      public ContentFactory()
  • Method Details

    • produceParts

      public List<com.google.genai.types.Part> produceParts(ContextPosition position)
      Produces a list of content parts from all enabled context providers for the given position.
      Parameters:
      position - The position in the context where the parts should be inserted.
      Returns:
      A list of generated parts.
    • produceParts

      public List<com.google.genai.types.Part> produceParts(ContextPosition position, boolean parallel)
      Produces a list of content parts from all enabled context providers for the given position.
      Parameters:
      position - The position in the context where the parts should be inserted.
      parallel - If true, providers are executed concurrently using the common ForkJoinPool.
      Returns:
      A list of generated parts, including metadata and content.
    • processProvider

      public List<com.google.genai.types.Part> processProvider(ContextProvider provider)
      Executes a single provider, calculates timing and size, and formats the output parts. This method is designed to be safe for both sequential and parallel execution.
      Parameters:
      provider - The context provider to execute.
      Returns:
      A list of parts containing the provider's metadata and generated content.