In APPL, expression statements within functions decorated with @ppl are automatically captured as prompts. The capture behavior depends on the type of the value being evaluated (provided the value is not None).
Captured values are categorized into three behaviors:
- Prompts: Basic values like strings or
Message objects. - Sequence of Prompts: Collections like
list or tuple where elements are captured recursively. - Custom Promptable: User-defined types that implement a specific interface.
Note that primitive types like int, float, and bool are not captured automatically. To capture them, you must explicitly convert them to strings or include them in a formatted string.
from appl import ppl, records, AIMessage
@ppl
def greeting(name: str):
"Hello world!"
AIMessage("Nice to meet you.")
return records()
print(greeting("APPL"))
# user: Hello world!
# assistant: Nice to meet you.