-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
dfbdaa0
commit 136b83e
Showing
49 changed files
with
3,946 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Oops, something went wrong.