Synthesis strategy
Defines a base class for response synthesis strategies used in Gen AI applications.
References
NONE
BaseSynthesisStrategy()
Bases: ABC
An abstract base class for the response synthesis strategies used in Gen AI applications.
The BaseSynthesisStrategy class provides a framework for synthesizing responses based on the provided
synthesis context. Subclasses must implement the synthesize method to define how the response is generated.
This class uses the Context Object pattern to avoid parameter proliferation and provide a clean, type-safe interface. Each strategy can extract only the parameters it needs from the context.
Initializes a new instance of the BaseSynthesisStrategy class.
synthesize(context)
abstractmethod
async
Synthesizes a response based on the provided synthesis context.
This abstract method must be implemented by subclasses to define the logic for generating a response. The context object contains all possible parameters that strategies might need, allowing each implementation to extract only what it requires.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context |
SynthesisContext
|
The synthesis context containing all parameters needed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The synthesized response. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented in a subclass. |
SynthesisPromptKey
Bases: StrEnum
The keys for the synthesis strategy.