Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ uv pip install -e ".[dev]"

```python
import asyncio
from copilot import CopilotClient
from copilot import CopilotClient, SessionEvent

async def main():
# Create and start client
Expand All @@ -29,7 +29,7 @@ async def main():
# Wait for response using session.idle event
done = asyncio.Event()

def on_event(event):
def on_event(event: SessionEvent):
if event.type.value == "assistant.message":
print(event.data.content)
elif event.type.value == "session.idle":
Expand Down Expand Up @@ -73,7 +73,7 @@ await client.start()

session = await client.create_session({"model": "gpt-5"})

def on_event(event):
def on_event(event: SessionEvent):
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This README code block now annotates event as SessionEvent, but the snippet doesn't import SessionEvent (or qualify it), so copy/pasting just this block will raise NameError. Consider adding from copilot import SessionEvent within the same code block (or dropping the annotation in this snippet if you want it import-free).

Copilot uses AI. Check for mistakes.
print(f"Event: {event['type']}")
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With event: SessionEvent, event['type'] is incorrect because SessionEvent is a dataclass and isn't subscriptable. This example should use event.type (or event.type.value) to print the event type.

Suggested change
print(f"Event: {event['type']}")
print(f"Event: {event.type.value}")

Copilot uses AI. Check for mistakes.

session.on(on_event)
Expand Down Expand Up @@ -185,7 +185,7 @@ Enable streaming to receive assistant response chunks as they're generated:

```python
import asyncio
from copilot import CopilotClient
from copilot import CopilotClient, SessionEvent

async def main():
client = CopilotClient()
Expand All @@ -199,7 +199,7 @@ async def main():
# Use asyncio.Event to wait for completion
done = asyncio.Event()

def on_event(event):
def on_event(event: SessionEvent):
if event.type.value == "assistant.message_delta":
# Streaming message chunk - print incrementally
delta = event.data.delta_content or ""
Expand Down
Loading