diff --git a/cookbook/copilot-sdk/python/accessibility-report.md b/cookbook/copilot-sdk/python/accessibility-report.md index 3d67a5fa..ad22c671 100644 --- a/cookbook/copilot-sdk/python/accessibility-report.md +++ b/cookbook/copilot-sdk/python/accessibility-report.md @@ -36,7 +36,7 @@ python accessibility_report.py import asyncio from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -80,7 +80,7 @@ async def main(): # Set up streaming event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() @@ -198,7 +198,7 @@ Unlike `send_and_wait`, this recipe uses streaming for real-time output: ```python def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/managing-local-files.md b/cookbook/copilot-sdk/python/managing-local-files.md index a9e4e35f..f1e78b02 100644 --- a/cookbook/copilot-sdk/python/managing-local-files.md +++ b/cookbook/copilot-sdk/python/managing-local-files.md @@ -20,7 +20,7 @@ import asyncio import os from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) async def main(): @@ -35,11 +35,11 @@ async def main(): # Event handler def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nCopilot: {event.data.content}") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" → Running: {event.data.tool_name}") - elif event.type == SessionEventType.TOOL_EXECUTION_COMPLETE: + elif event.type.value == "tool.execution_complete": print(f" āœ“ Completed: {event.data.tool_call_id}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/pr-visualization.md b/cookbook/copilot-sdk/python/pr-visualization.md index 0b158e4a..2e3d108b 100644 --- a/cookbook/copilot-sdk/python/pr-visualization.md +++ b/cookbook/copilot-sdk/python/pr-visualization.md @@ -45,7 +45,7 @@ import os import re from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -157,9 +157,9 @@ The current working directory is: {os.getcwd()} # Set up event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nšŸ¤– {event.data.content}\n") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" āš™ļø {event.data.tool_name}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/accessibility_report.py b/cookbook/copilot-sdk/python/recipe/accessibility_report.py index c5e0b6c9..69ca6468 100644 --- a/cookbook/copilot-sdk/python/recipe/accessibility_report.py +++ b/cookbook/copilot-sdk/python/recipe/accessibility_report.py @@ -3,7 +3,7 @@ import asyncio from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -47,7 +47,7 @@ async def main(): # Set up streaming event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/managing_local_files.py b/cookbook/copilot-sdk/python/recipe/managing_local_files.py index c0381170..f57bafcb 100644 --- a/cookbook/copilot-sdk/python/recipe/managing_local_files.py +++ b/cookbook/copilot-sdk/python/recipe/managing_local_files.py @@ -4,7 +4,7 @@ import asyncio import os from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) async def main(): @@ -19,11 +19,11 @@ async def main(): # Event handler def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nCopilot: {event.data.content}") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" → Running: {event.data.tool_name}") - elif event.type == SessionEventType.TOOL_EXECUTION_COMPLETE: + elif event.type.value == "tool.execution_complete": print(f" āœ“ Completed: {event.data.tool_call_id}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/pr_visualization.py b/cookbook/copilot-sdk/python/recipe/pr_visualization.py index 9ece3f93..ace1a8a1 100644 --- a/cookbook/copilot-sdk/python/recipe/pr_visualization.py +++ b/cookbook/copilot-sdk/python/recipe/pr_visualization.py @@ -7,7 +7,7 @@ import os import re from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -119,9 +119,9 @@ The current working directory is: {os.getcwd()} # Set up event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nšŸ¤– {event.data.content}\n") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" āš™ļø {event.data.tool_name}") elif event.type.value == "session.idle": done.set()