Input Formats
Handle different input formats for agent requests.
Input Formats.
1"""2Input Formats3=============================45Input Formats.6"""78from kern.agent import Agent910# ---------------------------------------------------------------------------11# Create Agent12# ---------------------------------------------------------------------------13agent = Agent()1415# ---------------------------------------------------------------------------16# Run Agent17# ---------------------------------------------------------------------------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 repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/02_input_output45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python input_formats.py