modifiers
¶
ASSISTANT_ROLE
module-attribute
¶
ASSISTANT_ROLE = MessageRole(ASSISTANT)
The assistant role with name not specified.
MaybeOneOrMany
module-attribute
¶
A type that can be either a single item, a sequence of items, or None.
OneOrMany
module-attribute
¶
A type that can be either a single item or a sequence of items.
SYSTEM_ROLE
module-attribute
¶
SYSTEM_ROLE = MessageRole(SYSTEM)
The system role with name not specified.
StrOrImg
module-attribute
¶
A type that can be either a string or an image.
String
module-attribute
¶
String = Union[StringFuture, str]
String is a type alias for StringFuture or str.
ApplStr
¶
ApplStr(
sep: Optional[str] = None,
indexing: Union[Indexing, Optional[str]] = None,
indent: Optional[Union[str, int]] = None,
new_indent: Optional[Union[str, int]] = None,
is_inline: Optional[bool] = None,
role: Optional[MessageRole] = None,
_ctx: Optional[PromptContext] = None,
)
Bases: Compositor
A compositor that represents a string in the prompt.
Attributes:
-
_sep
–The class default separator string is an empty string.
-
_new_indent
–The class default new indentation string is an empty string.
-
_is_inline
–The class default inline flag is True.
Examples:
Parameters:
-
sep
(Optional[str]
, default:None
) –The separator string. Defaults to use the class default.
-
indexing
(Union[Indexing, Optional[str]]
, default:None
) –The indexing mode. Defaults to use the class default.
-
indent
(Optional[Union[str, int]]
, default:None
) –The indentation string. Defaults to use the class default.
-
new_indent
(Optional[Union[str, int]]
, default:None
) –The new indentation string. Defaults to use the class default.
-
is_inline
(Optional[bool]
, default:None
) –Flag indicating if the modifier is inline. Defaults to use the class default.
-
role
(Optional[MessageRole]
, default:None
) –The role of the modifier. Defaults to use the class default.
-
_ctx
(Optional[PromptContext]
, default:None
) –The prompt context filled automatically by the APPL function.
Source code in src/appl/core/modifiers.py
CallFuture
¶
CallFuture(
func: Callable,
*args: Any,
use_process: bool = False,
lazy_eval: bool = False,
**kwargs: Any
)
Bases: FutureValue
Represent a function call that may not be ready yet.
Parameters:
-
func
(Callable
) –The function to call.
-
*args
(Any
, default:()
) –The arguments of the function.
-
use_process
(bool
, default:False
) –Whether to use a process pool executor.
-
lazy_eval
(bool
, default:False
) –Whether to delay the start of the call until needed.
-
**kwargs
(Any
, default:{}
) –The keyword arguments of the function.
Source code in src/appl/core/types/futures.py
CmpStringFuture
¶
CmpStringFuture(
a: StringFuture,
b: StringFuture,
op: Callable[[str, str], bool],
)
Bases: FutureValue
Represent a comparison between a StringFuture and another value.
Source code in src/appl/core/types/futures.py
Compositor
¶
Compositor(
sep: Optional[str] = None,
indexing: Union[Indexing, Optional[str]] = None,
indent: Optional[Union[str, int]] = None,
new_indent: Optional[Union[str, int]] = None,
is_inline: Optional[bool] = None,
role: Optional[MessageRole] = None,
_ctx: Optional[PromptContext] = None,
)
Bases: PrinterModifier
The contextual compositor of the prompts.
This class represents a contextual compositor that modifies the behavior of the printer. It provides various options for customizing the output format of the prompts within this context manager.
Attributes:
-
_sep
(Optional[str]
) –The class default separator string is None, indicating inherit from the parent.
-
_indexing
(Indexing
) –The class default indexing mode is empty indexing.
-
_inc_indent
(str
) –The class default indentation string is empty string.
-
_new_indent
(Optional[str]
) –The class default new indentation string is None, indicating not overwrite the indent.
-
_is_inline
(bool
) –The class default inline flag is False.
-
_new_role
(Optional[MessageRole]
) –The class default role of the modifier is None, indicating not overwrite the role.
Parameters:
-
sep
(Optional[str]
, default:None
) –The separator string. Defaults to use the class default.
-
indexing
(Union[Indexing, Optional[str]]
, default:None
) –The indexing mode. Defaults to use the class default.
-
indent
(Optional[Union[str, int]]
, default:None
) –The indentation string. Defaults to use the class default.
-
new_indent
(Optional[Union[str, int]]
, default:None
) –The new indentation string. Defaults to use the class default.
-
is_inline
(Optional[bool]
, default:None
) –Flag indicating if the modifier is inline. Defaults to use the class default.
-
role
(Optional[MessageRole]
, default:None
) –The role of the modifier. Defaults to use the class default.
-
_ctx
(Optional[PromptContext]
, default:None
) –The prompt context filled automatically by the APPL function.
Source code in src/appl/core/modifiers.py
ContentList
¶
Bases: BaseModel
Represent a list of contents containing text and images.
append
¶
append(content: StrOrImg) -> None
Append a content to the list.
If the last content is a string, it will be concatenated with the new content.
Source code in src/appl/core/types/content.py
extend
¶
get_contents
¶
get_contents() -> List[Dict[str, Any]]
Return the contents as a list of dictionaries.
Source code in src/appl/core/types/content.py
FutureValue
¶
Bases: ABC
Represents a value that may not be ready yet.
Image
¶
Bases: BaseModel
Represent an image in the message.
See the guide for more information about the detail level.
Source code in src/appl/core/types/content.py
from_file
classmethod
¶
Construct an image prompt from an image file.
from_image
classmethod
¶
Construct an image prompt from a PIL ImageFile.
Source code in src/appl/core/types/content.py
MessageRole
¶
PrinterModifier
¶
PrinterModifier(_ctx: Optional[PromptContext] = None)
Bases: AbstractContextManager
The contextual compositor of the prompt printer.
Controls the behavior of the prompt printer within the context manager. Should only be used within the APPL function.
Parameters:
-
_ctx
(Optional[PromptContext]
, default:None
) –The prompt context filled automatically by the APPL function.
Source code in src/appl/core/modifiers.py
ResponseType
¶
The type of generation response.
UNFINISHED
class-attribute
instance-attribute
¶
The response is not finished.
StringFuture
¶
StringFuture(content: Any = '', set_value: bool = False)
Bases: FutureValue
, BaseModel
StringFuture is a string that may not be ready yet.
Source code in src/appl/core/types/futures.py
from_list
classmethod
¶
from_list(content: List[Any]) -> StringFuture
join
¶
join(iterable: Iterable[StringFuture]) -> StringFuture
Concatenate any number of strings.
The StringFuture whose method is called is inserted in between each given StringFuture. The result is returned as a new StringFuture.
Source code in src/appl/core/types/futures.py
materialized
¶
materialized() -> StringFuture