MCPcopy Index your code
hub / github.com/github/copilot-sdk / main

Function main

python/samples/chat.py:15–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15async def main():
16 client = CopilotClient()
17 await client.start()
18 session = await client.create_session(on_permission_request=PermissionHandler.approve_all)
19
20 def on_event(event):
21 output = None
22 match event.data:
23 case AssistantReasoningData() as data:
24 output = f"[reasoning: {data.content}]"
25 case ToolExecutionStartData() as data:
26 output = f"[tool: {data.tool_name}]"
27 if output:
28 print(f"{BLUE}{output}{RESET}")
29
30 session.on(on_event)
31
32 print("Chat with Copilot (Ctrl+C to exit)\n")
33
34 while True:
35 user_input = input("You: ").strip()
36 if not user_input:
37 continue
38 print()
39
40 reply = await session.send_and_wait(user_input)
41 assistant_output = None
42 if reply:
43 match reply.data:
44 case AssistantMessageData() as data:
45 assistant_output = data.content
46 print(f"\nAssistant: {assistant_output}\n")
47
48
49if __name__ == "__main__":

Callers 1

chat.pyFile · 0.70

Calls 5

startMethod · 0.95
create_sessionMethod · 0.95
CopilotClientClass · 0.90
send_and_waitMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…