Base Classes
- class afterimage.base.BaseGenerator[source]
Bases:
objectIntended to serve as the base class for all generator classes
- async ainitialize(instruction_generator_callback=None)[source]
Initializes the generator by creating the correspondent prompt if it doesn’t exist.
- initialize(instruction_generator_callback=None)[source]
Initializes the generator by creating the correspondent prompt if it doesn’t exist.
- load_conversations(limit: int | None = None, offset: int | None = None) list[EvaluatedConversationWithContext][source]
- class afterimage.base.BaseInstructionGeneratorCallback[source]
Bases:
objectIntended to serve as the base class for all custom instruction generator callbacks
- async acreate_correspondent_prompt(respondent_prompt: str) str[source]
Create a correspondent prompt based on the respondent prompt asynchronously.
This method can be overridden by subclasses to customize correspondent prompt creation. By default, returns None, which means the conversation generator should handle it.
- Parameters:
respondent_prompt – The prompt for the respondent (assistant)
- Returns:
The correspondent prompt, or None if the generator should handle it
- Return type:
str
- create_correspondent_prompt(respondent_prompt: str) str | None[source]
Create a correspondent prompt based on the respondent prompt.
This method can be overridden by subclasses to customize correspondent prompt creation. By default, returns None, which means the conversation generator should handle it.
- Parameters:
respondent_prompt – The prompt for the respondent (assistant)
- Returns:
The correspondent prompt, or None if the generator should handle it
- Return type:
str
- class afterimage.base.BaseRespondentPromptModifierCallback[source]
Bases:
objectIntended to serve as the base class for all custom respondent prompt modifier callbacks
- async acall(respondent_prompt: str, context: str, instruction: str) GeneratedResponsePrompt[source]
- async agenerate(respondent_prompt, context, instruction) GeneratedResponsePrompt[source]
- generate(respondent_prompt, context, instruction) GeneratedResponsePrompt[source]
- class afterimage.base.BaseStoppingCallback[source]
Bases:
objectBase class for callbacks that decide when to stop generation.
- async should_stop(state: GenerationState) bool[source]
Return True if generation should stop.
- Parameters:
state – The current state of the generation process.