Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new admin-operator flow #2

Merged
merged 12 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"files": ["*.js", "*.jsx", "*.cjs", "*.mjs"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
Expand Down
2 changes: 1 addition & 1 deletion administrator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ When a goal is too complex or you lack the requisite abilities for you to accomp

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.

End all responses with an <end /> tag.
Every response must conclude with an <end /> tag.

## Commands

Expand Down
90 changes: 90 additions & 0 deletions dummy-sse-app.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 8080;

const responseTextBase =
"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";

const responseText = `${responseTextBase}
<operator-api>
{
"method": "POST",
"path": "/operators",
"body": {
"id": "06f86c9a-1fe6-4c74-8939-30e64cb1edbb",
"name": "My First Operator"
}
}
</operator-api>

<operator-api>
{
"method": "POST",
"path": "/operators/06f86c9a-1fe6-4c74-8939-30e64cb1edbb/messages",
"body": {
"content": "Sign up for an account at the following website: https://www.example.com"
}
}
</operator-api>
<operator-message>When I tried to access the website, I got a 404 Not Found error.</operator-message>
`;

app.use(bodyParser.json());

app.post('/v1/chat/completions', async (req, res) => {
const parts = chooseBetween(40, 60);
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
});
countdown(res, parts, parts);
});

const chooseBetween = (min, max) =>
Math.floor(Math.random() * (max - min + 1)) + min;

function countdown(res, parts, count) {
const timeout = chooseBetween(50, 300);

const chunkSize = Math.ceil(responseText.length / parts);

res.write(
'data: ' +
JSON.stringify({
choices: [
{
delta: {
content: responseText.slice(
(parts - count) * chunkSize,
(parts - count + 1) * chunkSize
),
},
},
],
}) +
'\n\n'
);
if (count) setTimeout(() => countdown(res, parts, count - 1), timeout);
else res.end();
}

app.post('/embedding', async (req, res) => {
const dimensions = 5120;
res.writeHead(200, {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
});
res.write(
JSON.stringify({
embedding: new Array(dimensions).fill(0).map(() => Math.random()),
})
);
res.end();
});

app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
2 changes: 1 addition & 1 deletion node-red.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
docker run --rm -it -p 1880:1880 -v $(pwd)/packages/node-red-data:/data --name mynodered nodered/node-red:3.1.3-18
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
read -n 1 -s -r -p "Press any key to continue"
Loading