#!/usr/bin/env python3 """ Example usage of PicoGent """ import asyncio from picogent import Agent, Config async def main(): """Example usage""" # Load config config = Config.from_file("config.example.json") # Create agent agent = Agent(config) # Simple chat example print("=== Simple Chat ===") response = await agent.chat("List all files in the current directory") print(response) print() # Session-based conversation print("=== Session-based Conversation ===") agent.clear_session() # Start fresh response1 = await agent.run("Create a simple hello.py file", session_file="example_session.jsonl") print("Step 1:", response1) print() response2 = await agent.run("Now read the file you just created", session_file="example_session.jsonl") print("Step 2:", response2) print() # Show session history print("=== Session History ===") messages = agent.get_session_messages() for i, msg in enumerate(messages): print(f"{i+1}. {msg['role']}: {str(msg['content'])[:100]}...") if __name__ == "__main__": asyncio.run(main())