-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.mjs
More file actions
21 lines (17 loc) · 886 Bytes
/
Copy pathclient.mjs
File metadata and controls
21 lines (17 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { createPeer } from "psionic";
// create a peer, with the description we want to send when we connect.
// could be anything, in this case, just the model we want the server to use.
const peer = createPeer({ description: { model: process.argv[3] || 'gpt-5.2' } });
// connect to the local socket
import { createConnection } from "net";
import { createNodeSocketAdapter } from "psionic/adapters/socket";
await peer.connect(createNodeSocketAdapter(createConnection({ port: 1234 })));
// pass the argument from the command line to the server's prompt function
for await (const chunk of peer.remote.prompt(process.argv[2])) {
// and stream the response back to the console as it comes in!
if (chunk.type === 'response.output_text.delta')
process.stdout.write(String(chunk.delta));
}
// close the connection so that the process exits
peer.close();
console.log('');