forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_template.py
More file actions
32 lines (23 loc) · 740 Bytes
/
basic_template.py
File metadata and controls
32 lines (23 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
import traceback
from pydantic import BaseModel
from beeai_framework.errors import FrameworkError
from beeai_framework.template import PromptTemplate, PromptTemplateInput
def main() -> None:
class UserMessage(BaseModel):
label: str
input: str
template: PromptTemplate[UserMessage] = PromptTemplate(
PromptTemplateInput(
schema=UserMessage,
template="""{{label}}: {{input}}""",
)
)
prompt = template.render(label="Query", input="What interesting things happened on this day in history?")
print(prompt)
if __name__ == "__main__":
try:
main()
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())