@@ -129,13 +129,13 @@ Create `main.py`:
129129
130130``` python
131131import asyncio
132- from copilot import CopilotClient
132+ from copilot import CopilotClient, PermissionHandler
133133
134134async def main ():
135135 client = CopilotClient()
136136 await client.start()
137137
138- session = await client.create_session({ " model " : " gpt-4.1" } )
138+ session = await client.create_session(PermissionHandler.approve_all, " gpt-4.1" )
139139 response = await session.send_and_wait({" prompt" : " What is 2 + 2?" })
140140
141141 print (response.data.content)
@@ -274,17 +274,14 @@ Update `main.py`:
274274``` python
275275import asyncio
276276import sys
277- from copilot import CopilotClient
277+ from copilot import CopilotClient, PermissionHandler
278278from copilot.generated.session_events import SessionEventType
279279
280280async def main ():
281281 client = CopilotClient()
282282 await client.start()
283283
284- session = await client.create_session({
285- " model" : " gpt-4.1" ,
286- " streaming" : True ,
287- })
284+ session = await client.create_session(PermissionHandler.approve_all, " gpt-4.1" , streaming = True )
288285
289286 # Listen for response chunks
290287 def handle_event (event ):
@@ -565,7 +562,7 @@ Update `main.py`:
565562import asyncio
566563import random
567564import sys
568- from copilot import CopilotClient
565+ from copilot import CopilotClient, PermissionHandler
569566from copilot.tools import define_tool
570567from copilot.generated.session_events import SessionEventType
571568from pydantic import BaseModel, Field
@@ -588,11 +585,7 @@ async def main():
588585 client = CopilotClient()
589586 await client.start()
590587
591- session = await client.create_session({
592- " model" : " gpt-4.1" ,
593- " streaming" : True ,
594- " tools" : [get_weather],
595- })
588+ session = await client.create_session(PermissionHandler.approve_all, " gpt-4.1" , streaming = True , tools = [get_weather])
596589
597590 def handle_event (event ):
598591 if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA :
@@ -837,7 +830,7 @@ Create `weather_assistant.py`:
837830import asyncio
838831import random
839832import sys
840- from copilot import CopilotClient
833+ from copilot import CopilotClient, PermissionHandler
841834from copilot.tools import define_tool
842835from copilot.generated.session_events import SessionEventType
843836from pydantic import BaseModel, Field
@@ -857,11 +850,7 @@ async def main():
857850 client = CopilotClient()
858851 await client.start()
859852
860- session = await client.create_session({
861- " model" : " gpt-4.1" ,
862- " streaming" : True ,
863- " tools" : [get_weather],
864- })
853+ session = await client.create_session(PermissionHandler.approve_all, " gpt-4.1" , streaming = True , tools = [get_weather])
865854
866855 def handle_event (event ):
867856 if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA :
@@ -1218,7 +1207,7 @@ client = CopilotClient({
12181207await client.start()
12191208
12201209# Use the client normally
1221- session = await client.create_session({ " on_permission_request " : PermissionHandler.approve_all} )
1210+ session = await client.create_session(PermissionHandler.approve_all)
12221211# ...
12231212```
12241213
0 commit comments