Skip to content

Commit 727b022

Browse files
committed
fix: apply pr review comments
1 parent 844493d commit 727b022

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

cookbook/python/pr-visualization.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import sys
4545

4646
from copilot import CopilotClient, SessionConfig
4747
from copilot.generated.session_events import SessionEvent, SessionEventType
48-
from copilot.types import CopilotClientOptions, MessageOptions, SystemMessageAppendConfig
48+
from copilot.types import CopilotClientOptions, MessageOptions
4949

5050
# ============================================================================
5151
# Git & GitHub Detection
@@ -126,17 +126,17 @@ async def main():
126126

127127
owner, repo_name = repo.split("/", 1)
128128

129-
options = CopilotClientOptions(
130-
log_level="info",
131-
)
129+
options: CopilotClientOptions = {
130+
"log_level": "info",
131+
}
132132
# Create Copilot client - no custom tools needed!
133133
client = CopilotClient(options=options)
134134
await client.start()
135135

136-
session_config = SessionConfig(
137-
model="gpt-5",
138-
system_message=SystemMessageAppendConfig(
139-
content=f"""
136+
session_config: SessionConfig = {
137+
"model": "gpt-5",
138+
"system_message": {
139+
"content": f"""
140140
<context>
141141
You are analyzing pull requests for the GitHub repository: {owner}/{repo_name}
142142
The current working directory is: {os.getcwd()}
@@ -149,8 +149,8 @@ The current working directory is: {os.getcwd()}
149149
- Be concise in your responses
150150
</instructions>
151151
"""
152-
),
153-
)
152+
},
153+
}
154154

155155
session = await client.create_session(config=session_config)
156156

@@ -166,16 +166,16 @@ The current working directory is: {os.getcwd()}
166166
# Initial prompt - let Copilot figure out the details
167167
print("\n📊 Starting analysis...\n")
168168

169-
message_options = MessageOptions(
170-
prompt=f"""
169+
message_options: MessageOptions = {
170+
"prompt": f"""
171171
Fetch the open pull requests for {owner}/{repo_name} from the last week.
172172
Calculate the age of each PR in days.
173173
Then generate a bar chart image showing the distribution of PR ages
174174
(group them into sensible buckets like <1 day, 1-3 days, etc.).
175175
Save the chart as "pr-age-chart.png" in the current directory.
176176
Finally, summarize the PR health - average age, oldest PR, and how many might be considered stale.
177-
""",
178-
)
177+
"""
178+
}
179179

180180
await session.send_and_wait(options=message_options, timeout=300.0)
181181

@@ -196,7 +196,7 @@ The current working directory is: {os.getcwd()}
196196
break
197197

198198
if user_input:
199-
message_options = MessageOptions(prompt=user_input)
199+
message_options: MessageOptions = {"prompt": user_input}
200200
await session.send_and_wait(options=message_options, timeout=300.0)
201201

202202
await session.destroy()

cookbook/python/recipe/pr_visualization.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from copilot import CopilotClient, SessionConfig
99
from copilot.generated.session_events import SessionEvent, SessionEventType
10-
from copilot.types import CopilotClientOptions, MessageOptions, SystemMessageAppendConfig
10+
from copilot.types import CopilotClientOptions, MessageOptions
1111

1212
# ============================================================================
1313
# Git & GitHub Detection
@@ -90,17 +90,17 @@ async def main():
9090

9191
owner, repo_name = repo.split("/", 1)
9292

93-
options = CopilotClientOptions(
94-
log_level="info",
95-
)
93+
options: CopilotClientOptions = {
94+
"log_level": "info",
95+
}
9696
# Create Copilot client - no custom tools needed!
9797
client = CopilotClient(options=options)
9898
await client.start()
9999

100-
session_config = SessionConfig(
101-
model="gpt-5",
102-
system_message=SystemMessageAppendConfig(
103-
content=f"""
100+
session_config: SessionConfig = {
101+
"model": "gpt-5",
102+
"system_message": {
103+
"content": f"""
104104
<context>
105105
You are analyzing pull requests for the GitHub repository: {owner}/{repo_name}
106106
The current working directory is: {os.getcwd()}
@@ -113,8 +113,8 @@ async def main():
113113
- Be concise in your responses
114114
</instructions>
115115
"""
116-
),
117-
)
116+
},
117+
}
118118

119119
session = await client.create_session(config=session_config)
120120

@@ -130,16 +130,16 @@ def handle_event(event: SessionEvent):
130130
# Initial prompt - let Copilot figure out the details
131131
print("\n📊 Starting analysis...\n")
132132

133-
message_options = MessageOptions(
134-
prompt=f"""
133+
message_options: MessageOptions = {
134+
"prompt": f"""
135135
Fetch the open pull requests for {owner}/{repo_name} from the last week.
136136
Calculate the age of each PR in days.
137137
Then generate a bar chart image showing the distribution of PR ages
138138
(group them into sensible buckets like <1 day, 1-3 days, etc.).
139139
Save the chart as "pr-age-chart.png" in the current directory.
140140
Finally, summarize the PR health - average age, oldest PR, and how many might be considered stale.
141141
"""
142-
)
142+
}
143143

144144
await session.send_and_wait(options=message_options, timeout=300.0)
145145

@@ -160,7 +160,7 @@ def handle_event(event: SessionEvent):
160160
break
161161

162162
if user_input:
163-
message_options = MessageOptions(prompt=user_input)
163+
message_options: MessageOptions = {"prompt": user_input}
164164
await session.send_and_wait(options=message_options, timeout=300.0)
165165

166166
await session.destroy()

0 commit comments

Comments
 (0)