mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
All 5 Python recipes and their markdown docs used a synchronous, kwargs-based API that doesn't match the real github-copilot-sdk: - client.start() -> await client.start() (all methods are async) - create_session(model=...) -> create_session(SessionConfig(model=...)) - session.send(prompt=...) -> session.send(MessageOptions(prompt=...)) - session.wait_for_idle() -> session.send_and_wait() (wait_for_idle doesn't exist) - event['type']/event['data']['content'] -> event.type/event.data.content - All code wrapped in async def main() + asyncio.run(main()) Verified all imports resolve against github-copilot-sdk.
26 lines
593 B
Python
26 lines
593 B
Python
#!/usr/bin/env python3
|
|
|
|
import asyncio
|
|
from copilot import CopilotClient, SessionConfig, MessageOptions
|
|
|
|
async def main():
|
|
client = CopilotClient()
|
|
|
|
try:
|
|
await client.start()
|
|
session = await client.create_session(SessionConfig(model="gpt-5"))
|
|
|
|
response = await session.send_and_wait(MessageOptions(prompt="Hello!"))
|
|
|
|
if response:
|
|
print(response.data.content)
|
|
|
|
await session.destroy()
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
finally:
|
|
await client.stop()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|