1from typing import Iterator # noqa
2
3from kern.agent import Agent, RunOutputEvent # noqa
4from kern.models.deepinfra import DeepInfra # noqa
5
6agent = Agent(
7 model=DeepInfra(id="meta-llama/Llama-2-70b-chat-hf"),
8 markdown=True,
9)
10
11# Get the response in a variable
12run_response: Iterator[RunOutputEvent] = agent.run(
13 "Share a 2 sentence horror story", stream=True
14)
15for chunk in run_response:
16 print(chunk.content)
17
18# Print the response in the terminal
19agent.print_response("Share a 2 sentence horror story", stream=True)