Respondent Prompt Modifiers
- class afterimage.WithContextRespondentPromptModifier(prompt_template: str | None = None)[source]
Bases:
BaseRespondentPromptModifierCallbackModifies respondent prompt by adding context.
- Parameters:
prompt_template – Custom prompt template. If None, uses default_respondent_prompt_with_context. If it contains {prompt} and/or {context}, they will be replaced by the respondent prompt and the context, respectively.
- async agenerate(respondent_prompt: str, context: str, instruction: str) GeneratedResponsePrompt[source]
Generates a modified respondent prompt by injecting context and instructions asynchronously.
- generate(respondent_prompt: str, context: str, instruction: str) GeneratedResponsePrompt[source]
Generates a modified respondent prompt by injecting context and instructions.
- Parameters:
respondent_prompt – The original prompt for the respondent
context – Additional context to be included
instruction – The instruction associated with the prompt
- Returns:
GeneratedResponsePrompt containing the modified prompt and context
- class afterimage.WithRAGRespondentPromptModifier(retriever: ContextRetriever, prompt_template: str | None = None)[source]
Bases:
WithContextRespondentPromptModifierModifies respondent prompt by adding relevant context using a retrieval strategy.
- Parameters:
retriever – Strategy for retrieving relevant context
prompt_template – Custom prompt template. If None, uses default_rag_respondent_prompt_with_context.