fixes python invokation on *nix

This commit is contained in:
nai-degen
2023-06-03 22:11:43 -05:00
parent 367a541c9c
commit 5a2eab4771
2 changed files with 9 additions and 3 deletions
+9 -1
View File
@@ -112,7 +112,8 @@ function onMessage(requestId: Buffer, tokens: Buffer) {
async function launchTokenizer() {
return new Promise<ChildProcess>((resolve, reject) => {
let resolved = false;
const proc = spawn("python", [
const python = process.platform === "win32" ? "python" : "python3";
const proc = spawn(python, [
"-u",
join(__dirname, "tokenization", "claude-tokenizer.py"),
]);
@@ -125,6 +126,13 @@ async function launchTokenizer() {
proc.stderr!.on("data", (data) => {
pythonLog.error(data.toString());
});
proc.on("error", (err) => {
pythonLog.error({ err }, "Claude tokenizer error");
if (!resolved) {
resolved = true;
reject(err);
}
});
proc.on("close", (code) => {
pythonLog.info(`Claude tokenizer exited with code ${code}`);
socket?.close();
-2
View File
@@ -19,8 +19,6 @@ def init(socket):
while True:
message = socket.recv_multipart()
routing_id, command = message
print(f"claude-tokenizer.py: received message {message}")
print(f"claude-tokenizer.py: received command {command}")
if command == b"init":
print("claude-tokenizer.py: initialized")
socket.send_multipart([routing_id, b"ok"])