prompttrail.agent.session_transformers package
Module contents
- class prompttrail.agent.session_transformers.CodeBlock(lang: str, code: str)
Bases:
objectA code block extracted from markdown.
- __init__(lang: str, code: str) None
- code: str
- lang: str
- class prompttrail.agent.session_transformers.DangerouslyEvaluatePythonCode(key: str, code: str)
Bases:
MetadataTransformerA hook that evaluates Python code blocks.
- __init__(key: str, code: str)
Initialize the hook.
- Parameters:
key – Key to store evaluation result in metadata
code – Key of code block to evaluate from metadata
- process_metadata(metadata: Metadata, session: Session) Metadata
Evaluate Python code from metadata and store result.
- Parameters:
metadata – Current metadata
session – Current conversation session
- Returns:
Updated session with evaluation result stored in metadata[key]
- Raises:
KeyError – If code_key is not found in metadata
- class prompttrail.agent.session_transformers.Debugger(message_shown_when_called: str)
Bases:
MetadataTransformerHook that prints debug information.
- __init__(message_shown_when_called: str)
Initialize logging for the class.
- class prompttrail.agent.session_transformers.ExtractMarkdownCodeBlock(key: str, lang: str, raise_error_on_empty: bool = False)
Bases:
MetadataTransformerA hook that extracts code blocks from markdown content.
- __init__(key: str, lang: str, raise_error_on_empty: bool = False)
Initialize the hook.
- Parameters:
key – Key to store the extracted code block in metadata
lang – Programming language of the code block to extract
- class prompttrail.agent.session_transformers.LambdaSessionTransformer(transform_fn)
Bases:
SessionTransformerHook that transforms the session using a lambda function.
- __init__(transform_fn)
Initialize logging for the class.
- class prompttrail.agent.session_transformers.MetadataTransformer
Bases:
SessionTransformerHook that transforms the session.
- __init__()
Initialize logging for the class.
- class prompttrail.agent.session_transformers.ResetMetadata(keys: str | List[str] | None = None)
Bases:
MetadataTransformerHook that resets metadata in session.
- __init__(keys: str | List[str] | None = None)
Initialize logging for the class.
- class prompttrail.agent.session_transformers.SessionTransformer
Bases:
DebuggableBase class for hooks in the agent template.
- __init__()
Initialize logging for the class.
- class prompttrail.agent.session_transformers.UpdateMetadata(key: str, value: Any)
Bases:
MetadataTransformerHook that updates a metadata value.
- __init__(key: str, value: Any)
Initialize logging for the class.