Akane710 commited on
Commit
349d3d8
·
verified ·
1 Parent(s): fbe3c17

Update main.js

Browse files
Files changed (1) hide show
  1. main.js +9 -19
main.js CHANGED
@@ -1,24 +1,14 @@
1
- // character_ai_server.js
2
- const express = require("express");
3
  const CharacterAI = require("node_characterai");
4
  const characterAI = new CharacterAI();
5
 
6
- const app = express();
7
- app.use(express.json());
8
 
9
- app.get("/character-chat", async (req, res) => {
10
- const { message } = req.body;
 
 
11
 
12
- try {
13
- await characterAI.authenticateWithToken("529e24b4173b29dbc3054fef02a380e1e5b41949");
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
+ })();