Skip to content

Commit fecff98

Browse files
gr2mfrancisfuzz
andauthoredSep 17, 2024
docs(examples): hello-world-without-sdk (#96)
closes #95 Co-authored-by: francisfuzz <15894826+francisfuzz@users.noreply.github.com>
1 parent cf87d43 commit fecff98

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
 
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createServer } from "node:http";
2+
3+
const server = createServer((request, response) => {
4+
if (request.method === "GET") {
5+
return response.end("ok");
6+
}
7+
8+
const textObject = {
9+
choices: [
10+
{ index: 0, delta: { content: "Hello, world!", role: "assistant" } },
11+
],
12+
};
13+
14+
const endObject = {
15+
choices: [{ index: 0, finish_reason: "stop", delta: { content: null } }],
16+
};
17+
18+
// note the "\n\n"s, they are significant.
19+
response.write(`data: ${JSON.stringify(textObject)}\n\n`);
20+
response.end(`data: ${JSON.stringify(endObject)}\n\ndata: [DONE]\n\n`);
21+
});
22+
23+
const PORT = process.env.PORT || 3000;
24+
server.listen(PORT, () => {
25+
console.log(`Server is running on port ${PORT}`);
26+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"private": true,
3+
"type": "module",
4+
"scripts": {
5+
"start": "node index.js",
6+
"watch": "node --watch index.js"
7+
},
8+
"dependencies": {
9+
"@copilot-extensions/preview-sdk": "../../"
10+
}
11+
}

0 commit comments

Comments
 (0)
Failed to load comments.