Spaces:
Paused
Paused
Update main.js
Browse files
main.js
CHANGED
|
@@ -1,24 +1,14 @@
|
|
| 1 |
-
//
|
| 2 |
-
const express = require("express");
|
| 3 |
const CharacterAI = require("node_characterai");
|
| 4 |
const characterAI = new CharacterAI();
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
const
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
const characterId = "smtV3Vyez6ODkwS8BErmBAdgGNj-1XWU73wIFVOY1hQ";
|
| 15 |
-
const chat = await characterAI.createOrContinueChat(characterId);
|
| 16 |
-
const response = await chat.sendAndAwaitResponse(encodeURIComponent(message), true);
|
| 17 |
-
|
| 18 |
-
res.json({ response: response.text });
|
| 19 |
-
} catch (error) {
|
| 20 |
-
res.status(500).json({ error: error.message });
|
| 21 |
-
}
|
| 22 |
-
});
|
| 23 |
-
|
| 24 |
-
app.listen(3000, () => console.log("CharacterAI microservice running on port 3000"));
|
|
|
|
| 1 |
+
// main.js
|
|
|
|
| 2 |
const CharacterAI = require("node_characterai");
|
| 3 |
const characterAI = new CharacterAI();
|
| 4 |
|
| 5 |
+
(async () => {
|
| 6 |
+
const input = process.argv[2] || "Default message";
|
| 7 |
|
| 8 |
+
await characterAI.authenticateWithToken("529e24b4173b29dbc3054fef02a380e1e5b41949");
|
| 9 |
+
const characterId = "smtV3Vyez6ODkwS8BErmBAdgGNj-1XWU73wIFVOY1hQ";
|
| 10 |
+
const chat = await characterAI.createOrContinueChat(characterId);
|
| 11 |
+
const response = await chat.sendAndAwaitResponse(input, true);
|
| 12 |
|
| 13 |
+
console.log(response); // This will be captured by Python's subprocess
|
| 14 |
+
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|