printer
¶
RecordType
module-attribute
¶
RecordType = Union[
BaseMessage,
StringFuture,
Image,
PrinterPush,
PrinterPop,
]
Types allowed in the prompt records.
Indexing
¶
Indexing(
method: Optional[str] = None,
ind: int = 0,
prefix: str = "",
suffix: Optional[str] = None,
)
The indexing method for the printer.
Source code in src/appl/core/printer.py
get_index
¶
Get the index string for the current or given index.
Source code in src/appl/core/printer.py
PrinterPush
dataclass
¶
PrinterPush(
new_role: Optional[MessageRole] = None,
separator: Optional[str] = None,
indexing: Optional[Indexing] = None,
inc_indent: str = "",
new_indent: Optional[str] = None,
is_inline: Optional[bool] = False,
)
A record to push a new printer state to the stack.
indexing
class-attribute
instance-attribute
¶
The indexing method to be used.
is_inline
class-attribute
instance-attribute
¶
Whether the state is inline.
new_indent
class-attribute
instance-attribute
¶
The new indent to be used.
new_role
class-attribute
instance-attribute
¶
new_role: Optional[MessageRole] = None
The new role to be used for the message.
PrinterState
dataclass
¶
PrinterState(
role: Optional[MessageRole] = None,
separator: str = "\n",
indexing: Indexing = Indexing(None, 0),
indent: str = "",
is_inline: bool = False,
is_start: bool = True,
current_sep: str = "",
)
A state of the printer.
current_sep
class-attribute
instance-attribute
¶
current_sep: str = ''
The current separator to be used between texts.
indent
class-attribute
instance-attribute
¶
indent: str = ''
The indent to be used in the beginning of each line.
indexing
class-attribute
instance-attribute
¶
The indexing method to be used.
is_inline
class-attribute
instance-attribute
¶
is_inline: bool = False
Whether the state is inline. Inline means the first indent and indexing is inherited from the previous non-inline state.
is_start
class-attribute
instance-attribute
¶
is_start: bool = True
Whether the state is at the start of the scope.
role
class-attribute
instance-attribute
¶
role: Optional[MessageRole] = None
The role to be used for the message.
PromptPrinter
¶
PromptPrinter(
states: Optional[List[PrinterState]] = None,
is_newline: bool = True,
)
A class to print prompt records as conversation.
The printer maintains a stack of printer states about the current role, separator, indexing, and indentation.
Source code in src/appl/core/printer.py
pop
¶
push
¶
push(data: PrinterPush) -> None
PromptRecords
¶
A class represents a list of prompt records.
Source code in src/appl/core/printer.py
as_convo
¶
as_convo() -> Conversation
copy
¶
extend
¶
record
¶
record(record: Union[str, RecordType]) -> None
Record a string, message, image, printer push or printer pop.