Skip to content

Commit 8d6b1e0

Browse files
authored
docs(dreamcode): mention interop functionality and show code how requset parsing and the event API will work (#35)
closes #19
1 parent 2e4c32f commit 8d6b1e0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { verifyRequestByKeyId } from "@copilot-extensions/preview-sdk";
1414
const payloadIsVerified = await verifyRequestByKeyId(
1515
request.body,
1616
signature,
17-
key,
17+
keyId,
1818
{
1919
token: process.env.GITHUB_TOKEN,
2020
}

dreamcode.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,30 @@ createServer(createNodeMiddleware(copilotExtension)).listen(3000);
7070
copilotExtension.log.info("Listening on http://localhost:3000");
7171
```
7272

73+
For other environments, these methods are available:
74+
75+
```js
76+
// verify the payload and call handlers
77+
await copilotExtension.verifyAndReceive({ payload, signature, keyId });
78+
// same, but skip verification
79+
await copilotExtension.receive({ payload });
80+
81+
// and if you don't want to use the event-based API
82+
const { isValidRequest, payload } = await copilotExtension.verifyAndParse(
83+
payload,
84+
signature,
85+
keyId
86+
);
87+
```
88+
7389
## Notes
7490

7591
Regarding the context passed to event handlers
7692

7793
- `message` / `confirmation` / etc are objects as received by the user
7894
- `octokit` is a pre-authenticated octokit instance
7995
- `prompt` is based on my work at https://github.com/github/gr2m-projects/blob/167/github-models/167-github-models/README.md. A simple API to interact with GitHub models. I assume we will default the prompt URL to `https://api.githubcopilot.com/chat/completions` and the model to `gpt-4o` (or whatever our CAPI name for that is?)
96+
- The `prompt` API will automatically apply interop transformations if the request is sent to an endpoint other than Copilot's chat complitions endpoint.
8097
- `respond` is an API to send different types of responses to the user
8198
- `log` is the logger as we use it in Octokit. See https://github.com/octokit/core.js?tab=readme-ov-file#logging
8299

0 commit comments

Comments
 (0)