mirror of
https://github.com/github/awesome-copilot.git
synced 2026-03-20 08:05:12 +00:00
Fix ImportError: SessionEventType not exported from copilot public API (#1093)
* Initial plan * Fix ImportError: remove SessionEventType from copilot imports, use string comparisons Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/awesome-copilot/sessions/0c514b95-5157-4aa9-8590-cbf3fd337472 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
This commit is contained in:
@@ -36,7 +36,7 @@ python accessibility_report.py
|
|||||||
import asyncio
|
import asyncio
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -80,7 +80,7 @@ async def main():
|
|||||||
|
|
||||||
# Set up streaming event handling
|
# Set up streaming event handling
|
||||||
def handle_event(event: SessionEvent):
|
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)
|
print(event.data.delta_content or "", end="", flush=True)
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
@@ -198,7 +198,7 @@ Unlike `send_and_wait`, this recipe uses streaming for real-time output:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def handle_event(event: SessionEvent):
|
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)
|
print(event.data.delta_content or "", end="", flush=True)
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
@@ -35,11 +35,11 @@ async def main():
|
|||||||
|
|
||||||
# Event handler
|
# Event handler
|
||||||
def handle_event(event: SessionEvent):
|
def handle_event(event: SessionEvent):
|
||||||
if event.type == SessionEventType.ASSISTANT_MESSAGE:
|
if event.type.value == "assistant.message":
|
||||||
print(f"\nCopilot: {event.data.content}")
|
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}")
|
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}")
|
print(f" ✓ Completed: {event.data.tool_call_id}")
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -157,9 +157,9 @@ The current working directory is: {os.getcwd()}
|
|||||||
|
|
||||||
# Set up event handling
|
# Set up event handling
|
||||||
def handle_event(event: SessionEvent):
|
def handle_event(event: SessionEvent):
|
||||||
if event.type == SessionEventType.ASSISTANT_MESSAGE:
|
if event.type.value == "assistant.message":
|
||||||
print(f"\n🤖 {event.data.content}\n")
|
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}")
|
print(f" ⚙️ {event.data.tool_name}")
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -47,7 +47,7 @@ async def main():
|
|||||||
|
|
||||||
# Set up streaming event handling
|
# Set up streaming event handling
|
||||||
def handle_event(event: SessionEvent):
|
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)
|
print(event.data.delta_content or "", end="", flush=True)
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
@@ -19,11 +19,11 @@ async def main():
|
|||||||
|
|
||||||
# Event handler
|
# Event handler
|
||||||
def handle_event(event: SessionEvent):
|
def handle_event(event: SessionEvent):
|
||||||
if event.type == SessionEventType.ASSISTANT_MESSAGE:
|
if event.type.value == "assistant.message":
|
||||||
print(f"\nCopilot: {event.data.content}")
|
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}")
|
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}")
|
print(f" ✓ Completed: {event.data.tool_call_id}")
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
from copilot import (
|
from copilot import (
|
||||||
CopilotClient, SessionConfig, MessageOptions,
|
CopilotClient, SessionConfig, MessageOptions,
|
||||||
SessionEvent, SessionEventType,
|
SessionEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -119,9 +119,9 @@ The current working directory is: {os.getcwd()}
|
|||||||
|
|
||||||
# Set up event handling
|
# Set up event handling
|
||||||
def handle_event(event: SessionEvent):
|
def handle_event(event: SessionEvent):
|
||||||
if event.type == SessionEventType.ASSISTANT_MESSAGE:
|
if event.type.value == "assistant.message":
|
||||||
print(f"\n🤖 {event.data.content}\n")
|
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}")
|
print(f" ⚙️ {event.data.tool_name}")
|
||||||
elif event.type.value == "session.idle":
|
elif event.type.value == "session.idle":
|
||||||
done.set()
|
done.set()
|
||||||
|
|||||||
Reference in New Issue
Block a user