1from typing import List
2
3from kern.agent import Agent, RunOutput # noqa
4from kern.models.fireworks import Fireworks
5from pydantic import BaseModel, Field
6from rich.pretty import pprint # noqa
7
8class MovieScript(BaseModel):
9 setting: str = Field(
10 ..., description="Provide a nice setting for a blockbuster movie."
11 )
12 ending: str = Field(
13 ...,
14 description="Ending of the movie. If not available, provide a happy ending.",
15 )
16 genre: str = Field(
17 ...,
18 description="Genre of the movie. If not available, select action, thriller or romantic comedy.",
19 )
20 name: str = Field(..., description="Give a name to this movie")
21 characters: List[str] = Field(..., description="Name of characters for this movie.")
22 storyline: str = Field(
23 ..., description="3 sentence storyline for the movie. Make it exciting!"
24 )
25
26# Agent that uses JSON mode
27agent = Agent(
28 model=Fireworks(id="accounts/fireworks/models/llama-v3p1-405b-instruct"),
29 description="You write movie scripts.",
30 output_schema=MovieScript,
31)
32
33# Get the response in a variable
34response: RunOutput = agent.run("New York")
35pprint(response.content)
36
37# agent.print_response("New York")