Input Formats

Handle different input formats for agent requests.

Input Formats.

1"""
2Input Formats
3=============================
4
5Input Formats.
6"""
7
8from kern.agent import Agent
9
10# ---------------------------------------------------------------------------
11# Create Agent
12# ---------------------------------------------------------------------------
13agent = Agent()
14
15# ---------------------------------------------------------------------------
16# Run Agent
17# ---------------------------------------------------------------------------
18if __name__ == "__main__":
19 agent.print_response(
20 {
21 "role": "user",
22 "content": [
23 {"type": "text", "text": "What's in this image?"},
24 {
25 "type": "image_url",
26 "image_url": {
27 "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
28 },
29 },
30 ],
31 },
32 stream=True,
33 markdown=True,
34 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/02_input_output
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python input_formats.py