Class ContentFactory
java.lang.Object
uno.anahata.ai.context.provider.ContentFactory
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<com.google.genai.types.Part> processProvider(ContextProvider provider) Executes a single provider, calculates timing and size, and formats the output parts.List<com.google.genai.types.Part> produceParts(ContextPosition position) Produces a list of content parts from all enabled context providers for the given position.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.
-
Constructor Details
-
ContentFactory
public ContentFactory()
-
-
Method Details
-
produceParts
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
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
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.
-
