Skip to content

Commit 136b83e

Browse files
Create new admin-operator flow (#2)
* Create new admin-operator flow * Move ui-builder/admin-operator from old data directory to new packages/node-red-data * Format dummy-sse-app.js * Rename dummy-sse-app.js to dummy-sse-app.cjs * Install express and body-parser dev dependencies * Archive March session of experimenting with ubuntu commands * Update dummy-see-app response with tags for testing admin-op * Add host.docker.internal.local domain name that points to process IP address * Update flows.json with bug fixes for the admin-op flow, currently working
1 parent dfbdaa0 commit 136b83e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3946
-247
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"rules": {}
2424
},
2525
{
26-
"files": ["*.js", "*.jsx"],
26+
"files": ["*.js", "*.jsx", "*.cjs", "*.mjs"],
2727
"extends": ["plugin:@nx/javascript"],
2828
"rules": {}
2929
},

administrator.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ When a goal is too complex or you lack the requisite abilities for you to accomp
88

99
In addition to requests from the User, Operators may also send you messages or requests. Unlike requests from the User, you may choose whether and how to respond to messages and requests from Operators.
1010

11-
End all responses with an <end /> tag.
11+
Every response must conclude with an <end /> tag.
1212

1313
## Commands
1414

dummy-sse-app.cjs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
const express = require('express');
2+
const bodyParser = require('body-parser');
3+
const app = express();
4+
const port = process.env.PORT || 8080;
5+
6+
const responseTextBase =
7+
"To elicit a more detailed and specific response from BigStar, you could alter Lilly's prompt as follows:\n\n<prompt>I have $10,000 in savings currently in an investment account. My goal is to earn a passive income of $10,000 per month within the next 6-12 months. Please provide a comprehensive step-by-step plan that outlines clear actions and resources for meeting this goal. The plan should include information on high-yield savings accounts, their interest rates, minimum balance requirements, and any other relevant details. Additionally, please consider providing examples of other investment strategies or financial products that could help me achieve my goal.</prompt>\n\nThis prompt is more detailed and specific, which would encourage BigStar to provide a more thorough response with actionable steps and resources for achieving Lilly's goal";
8+
9+
const responseText = `${responseTextBase}
10+
<operator-api>
11+
{
12+
"method": "POST",
13+
"path": "/operators",
14+
"body": {
15+
"id": "06f86c9a-1fe6-4c74-8939-30e64cb1edbb",
16+
"name": "My First Operator"
17+
}
18+
}
19+
</operator-api>
20+
21+
<operator-api>
22+
{
23+
"method": "POST",
24+
"path": "/operators/06f86c9a-1fe6-4c74-8939-30e64cb1edbb/messages",
25+
"body": {
26+
"content": "Sign up for an account at the following website: https://www.example.com"
27+
}
28+
}
29+
</operator-api>
30+
<operator-message>When I tried to access the website, I got a 404 Not Found error.</operator-message>
31+
`;
32+
33+
app.use(bodyParser.json());
34+
35+
app.post('/v1/chat/completions', async (req, res) => {
36+
const parts = chooseBetween(40, 60);
37+
res.writeHead(200, {
38+
'Content-Type': 'text/event-stream',
39+
'Cache-Control': 'no-cache',
40+
Connection: 'keep-alive',
41+
});
42+
countdown(res, parts, parts);
43+
});
44+
45+
const chooseBetween = (min, max) =>
46+
Math.floor(Math.random() * (max - min + 1)) + min;
47+
48+
function countdown(res, parts, count) {
49+
const timeout = chooseBetween(50, 300);
50+
51+
const chunkSize = Math.ceil(responseText.length / parts);
52+
53+
res.write(
54+
'data: ' +
55+
JSON.stringify({
56+
choices: [
57+
{
58+
delta: {
59+
content: responseText.slice(
60+
(parts - count) * chunkSize,
61+
(parts - count + 1) * chunkSize
62+
),
63+
},
64+
},
65+
],
66+
}) +
67+
'\n\n'
68+
);
69+
if (count) setTimeout(() => countdown(res, parts, count - 1), timeout);
70+
else res.end();
71+
}
72+
73+
app.post('/embedding', async (req, res) => {
74+
const dimensions = 5120;
75+
res.writeHead(200, {
76+
'Content-Type': 'application/json',
77+
'Cache-Control': 'no-cache',
78+
Connection: 'keep-alive',
79+
});
80+
res.write(
81+
JSON.stringify({
82+
embedding: new Array(dimensions).fill(0).map(() => Math.random()),
83+
})
84+
);
85+
res.end();
86+
});
87+
88+
app.listen(port, () => {
89+
console.log(`Server listening on port ${port}`);
90+
});

node-red.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
docker run --rm -it -p 1880:1880 -v $(pwd)/packages/node-red-data:/data --name mynodered nodered/node-red:3.1.3-18
2+
docker run --rm -it --add-host host.docker.internal.local=$(hostname -I | awk '{print $1}') -p 1880:1880 -v $(pwd)/packages/node-red-data:/data --name mynodered nodered/node-red:3.1.3-18
33
read -n 1 -s -r -p "Press any key to continue"

0 commit comments

Comments
 (0)