Skip to content

Commit 6a7da24

Browse files
committed
remove terminal chat
1 parent a8aa112 commit 6a7da24

File tree

1 file changed

+3
-65
lines changed

1 file changed

+3
-65
lines changed

agent/src/index.ts

+3-65
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ async function startAgent(
595595
const startAgents = async () => {
596596
const directClient = new DirectClient();
597597
const serverPort = parseInt(settings.SERVER_PORT || "3000");
598-
directClient.start(serverPort);
599598
const args = parseArguments();
600599

601600
let charactersArg = args.characters || args.character;
@@ -614,74 +613,13 @@ const startAgents = async () => {
614613
elizaLogger.error("Error starting agents:", error);
615614
}
616615

617-
async function handleUserInput(input, agentId) {
618-
elizaLogger.log("handleUserInput", input, agentId);
619-
if (input.toLowerCase() === "exit") {
620-
gracefulExit();
621-
}
622-
623-
try {
624-
const serverPort = parseInt(settings.SERVER_PORT || "3000");
625-
626-
const response = await fetch(
627-
`http://localhost:${serverPort}/${agentId}/message`,
628-
{
629-
method: "POST",
630-
headers: { "Content-Type": "application/json" },
631-
body: JSON.stringify({
632-
text: input,
633-
userId: "user",
634-
userName: "User",
635-
}),
636-
}
637-
);
638-
639-
const data = await response.json();
640-
elizaLogger.log("data: ", data);
641-
data.forEach((message) =>
642-
elizaLogger.log(`${"Agent"}: ${message.text}`)
643-
);
644-
} catch (error) {
645-
elizaLogger.error("Error fetching response:", error);
646-
}
647-
}
648-
649-
function chat() {
650-
elizaLogger.log("chat");
651-
const agentId = characters[0].name ?? "Agent";
652-
elizaLogger.log("agentId: ", agentId);
653-
rl.question("You: ", async (input) => {
654-
elizaLogger.log("input: ", input);
655-
await handleUserInput(input, agentId);
656-
if (input.toLowerCase() !== "exit") {
657-
chat(); // Loop back to ask another question
658-
}
659-
});
660-
}
616+
directClient.start(serverPort);
661617

662-
if (!args["non-interactive"]) {
663-
elizaLogger.log("Chat started. Type 'exit' to quit.");
664-
// log an empty line
665-
elizaLogger.log("");
666-
chat();
667-
}
618+
elizaLogger.log("Visit the following URL to chat with your agents:");
619+
elizaLogger.log(`http://localhost:5173`);
668620
};
669621

670622
startAgents().catch((error) => {
671623
elizaLogger.error("Unhandled error in startAgents:", error);
672624
process.exit(1); // Exit the process after logging
673625
});
674-
675-
const rl = readline.createInterface({
676-
input: process.stdin,
677-
output: process.stdout,
678-
});
679-
680-
async function gracefulExit() {
681-
elizaLogger.log("Terminating and cleaning up resources...");
682-
rl.close();
683-
process.exit(0);
684-
}
685-
686-
rl.on("SIGINT", gracefulExit);
687-
rl.on("SIGTERM", gracefulExit);

0 commit comments

Comments
 (0)