mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-23 11:55:12 +00:00
Moving the copilot-sdk cookbook content in here
This commit is contained in:
17
cookbook/copilot-sdk/nodejs/recipe/error-handling.ts
Normal file
17
cookbook/copilot-sdk/nodejs/recipe/error-handling.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { CopilotClient } from "@github/copilot-sdk";
|
||||
|
||||
const client = new CopilotClient();
|
||||
|
||||
try {
|
||||
await client.start();
|
||||
const session = await client.createSession({ model: "gpt-5" });
|
||||
|
||||
const response = await session.sendAndWait({ prompt: "Hello!" });
|
||||
console.log(response?.data.content);
|
||||
|
||||
await session.destroy();
|
||||
} catch (error: any) {
|
||||
console.error("Error:", error.message);
|
||||
} finally {
|
||||
await client.stop();
|
||||
}
|
||||
Reference in New Issue
Block a user