Moving the copilot-sdk cookbook content in here

This commit is contained in:
Aaron Powell
2026-01-29 14:29:36 +11:00
parent ccdfd66cc2
commit f59e0b4080
53 changed files with 5385 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python3
from copilot import CopilotClient
client = CopilotClient()
try:
client.start()
session = client.create_session(model="gpt-5")
response = None
def handle_message(event):
nonlocal response
if event["type"] == "assistant.message":
response = event["data"]["content"]
session.on(handle_message)
session.send(prompt="Hello!")
session.wait_for_idle()
if response:
print(response)
session.destroy()
except Exception as e:
print(f"Error: {e}")
finally:
client.stop()