-
Notifications
You must be signed in to change notification settings - Fork 634
chore: update PR visualization example to work with latest sdk #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Someone is already working on this at #127 However, this updates the documentation too. I will rebase my branch after their change is merged and fix the missing stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request modernizes the Python PR visualization example to use the latest asynchronous Copilot SDK APIs. The changes update both the recipe script and its documentation to demonstrate proper async/await patterns, typed event handling, and modern SDK configuration options.
Changes:
- Migrated from synchronous to asynchronous API patterns using
async def main()andasyncio.run() - Updated SDK client and session creation to use modern configuration types (
CopilotClientOptions,SessionConfig,SystemMessageAppendConfig,MessageOptions) - Refactored event handling to use typed
SessionEventandSessionEventTypeenums - Replaced
session.send()+session.wait_for_idle()with the more convenientsession.send_and_wait()method
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| cookbook/python/recipe/pr_visualization.py | Updated recipe script to use async APIs, typed events, and modern SDK configuration patterns |
| cookbook/python/pr-visualization.md | Updated documentation to reflect the async API changes and modern SDK usage patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request refactors and modernizes the Python PR visualization example, updating both the documentation (
pr-visualization.md) and the recipe script (pr_visualization.py). The main improvements are the migration to an asynchronous workflow, enhanced event handling, and better type safety using the Copilot SDK's generated types. These changes make the code more robust, easier to maintain, and provide clearer guidance for users.Migration to async/await and improved SDK usage:
Converted the main application logic to use
async def main()and replaced synchronous client/session methods with their asynchronous counterparts (await client.start(),await client.create_session(),await session.send_and_wait(),await session.destroy(),await client.stop()). This ensures proper handling of asynchronous operations and resource cleanup. [1] [2] [3] [4]Updated event handling to use the Copilot SDK's generated types (
SessionEvent,SessionEventType) for safer and more readable code, replacing dictionary access with attribute access. [1] [2]Type safety and configuration improvements:
CopilotClientOptions,MessageOptions,SessionConfig) and updated client/session instantiation to use these types, improving clarity and reducing errors. [1] [2]Documentation and usability enhancements:
Updated documentation and example script names from
pr_breakdown.pytopr_visualization.pyfor consistency and clarity. Also improved sample command usage and user prompts.Improved user interaction prompts and examples for follow-up questions, making them clearer and more consistent. [1] [2]
These changes collectively modernize the PR visualization example, making it a better reference for users and developers integrating with the Copilot SDK.