| 4 | from copilot import CopilotClient, SessionConfig, MessageOptions, PermissionHandler |
| 5 | |
| 6 | async def main(): |
| 7 | client = CopilotClient() |
| 8 | |
| 9 | try: |
| 10 | await client.start() |
| 11 | session = await client.create_session(SessionConfig(model="gpt-5", |
| 12 | on_permission_request=PermissionHandler.approve_all)) |
| 13 | |
| 14 | response = await session.send_and_wait(MessageOptions(prompt="Hello!")) |
| 15 | |
| 16 | if response: |
| 17 | print(response.data.content) |
| 18 | |
| 19 | await session.destroy() |
| 20 | except Exception as e: |
| 21 | print(f"Error: {e}") |
| 22 | finally: |
| 23 | await client.stop() |
| 24 | |
| 25 | if __name__ == "__main__": |
| 26 | asyncio.run(main()) |