The GeminiBatcher is the core component of the gmeini-batcher library, serving as its primary interface. It integrates the logic of all the internal classes to efficiently chunk and batch content before querying the Gemini API.
The GeminiApi object provides a wrapper around the Gemini Python SDK, allowing for additional error handling.
config (GeminiConfig)
The default config settings to be used when querying the Gemini API.
Initialisation
Initializes the GeminiBatcher object with a given Gemini configuration. This involves creating the GeminiApi object which allows for API calls to Gemini models to be made.
__init__(config)
Arguments
config (GeminiConfig)
The configuration settings for queries to the Gemini model (such as model name, system prompt, caching options, etc). This can, optionally, be changed when calling generate_content().
Methods
generate_content()
The base function responsible for generating responses from the Gemini API. It determines which sub-functions to used based on the type of the input, ensuring that the response is generated appropriately.
he list of questions to be answered from the content.
chunking_strategy (BaseStrategy)
The chunking strategy to be used to split the input into chunks.
batching_strategy (BaseStrategy)
The strategy used to group questions into batches.
config (GeminiConfig, optional)
The configuration settings for the query (such as model name, system prompt, caching options, etc). This only needs to be provided if you’d like to make changes to the original config provided when initialises the GeminiBatcher object.
Returns
Response
An object containing all of the relevant information about the queries reponse. Including its answers and token usage. Optional information such as the chunks/batches generated can also be provided depending on the provided. config parameter.
Raises
NotImplemenentedError
If an unsupported chunking or batching strategy for the given input type is provided.