prompttrail.agent package
Subpackages
- prompttrail.agent.session_transformers package
- prompttrail.agent.subroutine package
- Submodules
- prompttrail.agent.subroutine.session_init_strategy module
- prompttrail.agent.subroutine.squash_strategy module
- Module contents
- prompttrail.agent.templates package
- prompttrail.agent.tools package
Submodules
prompttrail.agent.runners module
- class prompttrail.agent.runners.APIRunner(model: Model, template: Template, user_interface: UserInterface, host: str = '127.0.0.1', port: int = 8000)
Bases:
Runner- __init__(model: Model, template: Template, user_interface: UserInterface, host: str = '127.0.0.1', port: int = 8000)
Abstract class for runner. Runner is a class to run the templates. It is responsible for rendering templates and handling user interactions.
- run(session: Session | None = None, max_messages: int | None = 100, debug_mode: bool = False) Session
Run method implementation for APIRunner.
This method is mainly for compatibility with the Runner interface. The actual processing is done through the API endpoints.
- start_server()
- class prompttrail.agent.runners.CommandLineRunner(model: Model, template: Template, user_interface: UserInterface)
Bases:
Runner- run(session: Session | None = None, max_messages: int | None = 100, debug_mode: bool = False) Session
Command line runner. This runner is for debugging purpose. It prints out the messages to the console.
- Parameters:
session (Optional[Session], optional) – If set, use the session given. Otherwise, create a new session. Defaults to None.
max_messages (Optional[int], optional) – Maximum number of messages to yield. If number of messages exceeds this number, the conversation is forced to stop. Defaults to 100.
debug_mode (bool, optional) – If set, print out debug messages. Defaults to False.
- Returns:
Final session of the conversation.
- Return type:
- class prompttrail.agent.runners.Runner(model: Model, template: Template, user_interface: UserInterface)
Bases:
Debuggable- __init__(model: Model, template: Template, user_interface: UserInterface)
Abstract class for runner. Runner is a class to run the templates. It is responsible for rendering templates and handling user interactions.
- class prompttrail.agent.runners.SessionState(session: prompttrail.core._core.Session, current_event: prompttrail.agent.templates._core.UserInteractionEvent | None = None, is_running: bool = False, websocket: starlette.websockets.WebSocket | None = None)
Bases:
object- __init__(session: Session, current_event: UserInteractionEvent | None = None, is_running: bool = False, websocket: WebSocket | None = None) None
- current_event: UserInteractionEvent | None = None
- is_running: bool = False
- websocket: WebSocket | None = None
- prompttrail.agent.runners.cutify_role(role: Literal['system', 'user', 'assistant', 'tool_result', 'control']) str
Cutify role name based on OpenAI’s naming convention.
- prompttrail.agent.runners.pretty_print_metadata(metadata: Dict[str, Any]) str
prompttrail.agent.user_interface module
- class prompttrail.agent.user_interface.CLIInterface
Bases:
UserInterface- ask(session: Session, description: str | None = 'Input> ', default: str | None = None) str
Ask the user for input via the command line interface.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
The user’s input as a string.
- class prompttrail.agent.user_interface.DefaultOrEchoMockInterface
Bases:
MockInterface- ask(session: Session, description: str | None = None, default: str | None = None) str
Base mock provider that returns an empty string.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
An empty string.
- class prompttrail.agent.user_interface.EchoMockInterface
Bases:
MockInterface- ask(session: Session, description: str | None = None, default: str | None = None) str
Mock the user interaction by echoing the last message.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
The last message as the user’s input.
- class prompttrail.agent.user_interface.MockInterface
Bases:
UserInterface- ask(session: Session, description: str | None = None, default: str | None = None) str
Base mock provider that returns an empty string.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
An empty string.
- class prompttrail.agent.user_interface.SingleTurnResponseMockInterface(conversation_table: Dict[str, str])
Bases:
MockInterface- __init__(conversation_table: Dict[str, str])
Initialize logging for the class.
- ask(session: Session, description: str | None = None, default: str | None = None) str
Mock the user interaction by providing pre-defined responses based on the conversation history.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
The pre-defined response based on the conversation history.
- class prompttrail.agent.user_interface.UserInterface
Bases:
Debuggable- abstract ask(session: Session, instruction: str | None, default: str | None = None) str
Ask the user for input.
- Parameters:
session – The current session of the conversation.
description – The description of the input prompt.
default – The default value for the input prompt.
- Returns:
The user’s input as a string.
Module contents
Agent module for PromptTrail.