forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.py
More file actions
31 lines (23 loc) · 757 Bytes
/
arrays.py
File metadata and controls
31 lines (23 loc) · 757 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
import sys
import traceback
from pydantic import BaseModel, Field
from beeai_framework.errors import FrameworkError
from beeai_framework.template import PromptTemplate, PromptTemplateInput
def main() -> None:
class ColorsObject(BaseModel):
colors: list[str] = Field(..., min_length=1)
template: PromptTemplate[ColorsObject] = PromptTemplate(
PromptTemplateInput(
schema=ColorsObject,
template="""Colors: {{#colors}}{{.}}, {{/colors}}""",
)
)
# Colors: Green, Yellow,
output = template.render(colors=["Green", "Yellow"])
print(output)
if __name__ == "__main__":
try:
main()
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())