@@ -52,7 +52,8 @@ | |||||
"dependencies": { | "dependencies": { | ||||
"@clack/core": "^0.3.2", | "@clack/core": "^0.3.2", | ||||
"esbuild-plugin-wasm": "^1.0.0", | "esbuild-plugin-wasm": "^1.0.0", | ||||
"yargs": "^17.7.1" | |||||
"yargs": "^17.7.1", | |||||
"@modal-sh/mio-ai": "link:../.." | |||||
}, | }, | ||||
"types": "./dist/types/index.d.ts", | "types": "./dist/types/index.d.ts", | ||||
"main": "./dist/cjs/production/index.js", | "main": "./dist/cjs/production/index.js", | ||||
@@ -42,12 +42,11 @@ const receiveData = ( | |||||
}); | }); | ||||
memory.push(assistantMessage as OpenAi.MessageObject); | memory.push(assistantMessage as OpenAi.MessageObject); | ||||
process.stdout.write('\n\n'); | process.stdout.write('\n\n'); | ||||
// const { length: promptTokens } = OpenAi.getPromptTokens( | |||||
// normalizedChatMessage, | |||||
// model, | |||||
// ); | |||||
// process.stdout.write(`info:\n${promptTokens} prompt tokens\n${completionTokens} completion tokens`); | |||||
process.stdout.write(`info:\n${completionTokens} completion tokens`); | |||||
const { length: promptTokens } = OpenAi.getPromptTokens( | |||||
normalizedChatMessage, | |||||
model, | |||||
); | |||||
process.stdout.write(`info:\n${promptTokens} prompt tokens\n${completionTokens} completion tokens`); | |||||
if (argv.memory) { | if (argv.memory) { | ||||
process.stdout.write(`\n${memory.length} memory items`); | process.stdout.write(`\n${memory.length} memory items`); | ||||
} | } | ||||
@@ -87,7 +86,7 @@ const receiveData = ( | |||||
}); | }); | ||||
}); | }); | ||||
const main = (argv: Argv) => new Promise<number>(async (resolve) => { | |||||
const main = async (argv: Argv) => { | |||||
let done = false; | let done = false; | ||||
let resolveResult = 0; | let resolveResult = 0; | ||||
const memory = [] as OpenAi.MessageObject[]; | const memory = [] as OpenAi.MessageObject[]; | ||||
@@ -111,6 +110,7 @@ const main = (argv: Argv) => new Promise<number>(async (resolve) => { | |||||
return `${OpenAi.MessageRole.USER}:\n${this.valueWithCursor ?? ''}`; | return `${OpenAi.MessageRole.USER}:\n${this.valueWithCursor ?? ''}`; | ||||
}, | }, | ||||
}); | }); | ||||
// eslint-disable-next-line no-await-in-loop | |||||
const contentRaw = await textPrompt.prompt(); | const contentRaw = await textPrompt.prompt(); | ||||
if (isCancel(contentRaw)) { | if (isCancel(contentRaw)) { | ||||
done = true; | done = true; | ||||
@@ -121,6 +121,7 @@ const main = (argv: Argv) => new Promise<number>(async (resolve) => { | |||||
break; | break; | ||||
} | } | ||||
process.stdout.write('\n'); | process.stdout.write('\n'); | ||||
// eslint-disable-next-line no-await-in-loop | |||||
await receiveData(aiClient, content, argv, memory); | await receiveData(aiClient, content, argv, memory); | ||||
} catch { | } catch { | ||||
resolveResult = -1; | resolveResult = -1; | ||||
@@ -129,8 +130,8 @@ const main = (argv: Argv) => new Promise<number>(async (resolve) => { | |||||
} while (!done); | } while (!done); | ||||
process.stdout.write('\ninfo:\nUser exited loop\n\n'); | process.stdout.write('\ninfo:\nUser exited loop\n\n'); | ||||
resolve(resolveResult); | |||||
}); | |||||
return resolveResult; | |||||
}; | |||||
main( | main( | ||||
yargs(hideBin(process.argv)) | yargs(hideBin(process.argv)) | ||||
@@ -160,7 +161,9 @@ main( | |||||
.then((result) => { | .then((result) => { | ||||
process.exit(result); | process.exit(result); | ||||
}) | }) | ||||
.catch((error) => { | |||||
console.error(error); | |||||
.catch((errRaw) => { | |||||
const error = errRaw as Error; | |||||
process.stderr.write(error.message); | |||||
process.stderr.write('\n'); | |||||
process.exit(-1); | process.exit(-1); | ||||
}); | }); |
@@ -16,9 +16,6 @@ | |||||
"moduleResolution": "node", | "moduleResolution": "node", | ||||
"jsx": "react", | "jsx": "react", | ||||
"esModuleInterop": true, | "esModuleInterop": true, | ||||
"target": "es2018", | |||||
"paths": { | |||||
"@modal-sh/mio-ai": ["./src/packages/@modal-sh/mio-ai"] | |||||
} | |||||
"target": "esnext" | |||||
} | } | ||||
} | } |
@@ -16,9 +16,6 @@ | |||||
"moduleResolution": "node", | "moduleResolution": "node", | ||||
"jsx": "react", | "jsx": "react", | ||||
"esModuleInterop": true, | "esModuleInterop": true, | ||||
"target": "esnext", | |||||
"paths": { | |||||
"@modal-sh/mio-ai": ["./src/packages/@modal-sh/mio-ai/src/index.ts"], | |||||
} | |||||
"target": "esnext" | |||||
} | } | ||||
} | } |
@@ -241,6 +241,11 @@ | |||||
picocolors "^1.0.0" | picocolors "^1.0.0" | ||||
sisteransi "^1.0.5" | sisteransi "^1.0.5" | ||||
"@dqbd/tiktoken@^1.0.6": | |||||
version "1.0.6" | |||||
resolved "https://js.pack.modal.sh/@dqbd%2ftiktoken/-/tiktoken-1.0.6.tgz#96bfd0a4909726c61551a8c783493f01841bd163" | |||||
integrity sha512-umSdeZTy/SbPPKVuZKV/XKyFPmXSN145CcM3iHjBbmhlohBJg7vaDp4cPCW+xNlWL6L2U1sp7T2BD+di2sUKdA== | |||||
"@esbuild/android-arm64@0.17.17": | "@esbuild/android-arm64@0.17.17": | ||||
version "0.17.17" | version "0.17.17" | ||||
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.17.tgz#164b054d58551f8856285f386e1a8f45d9ba3a31" | resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.17.tgz#164b054d58551f8856285f386e1a8f45d9ba3a31" | ||||
@@ -444,6 +449,10 @@ | |||||
resolved "https://registry.yarnpkg.com/@mdn/browser-compat-data/-/browser-compat-data-5.2.50.tgz#f83a9a97f50e06402b8b633bf6bd3247baed1302" | resolved "https://registry.yarnpkg.com/@mdn/browser-compat-data/-/browser-compat-data-5.2.50.tgz#f83a9a97f50e06402b8b633bf6bd3247baed1302" | ||||
integrity sha512-3qGRdT2lrIloY8xotSRTW7k3oIRJAO7WSsJymTLN1sqeB1qiWPcbQdAiDG/IQWCA2QCVQewTeT2kfZf/you94w== | integrity sha512-3qGRdT2lrIloY8xotSRTW7k3oIRJAO7WSsJymTLN1sqeB1qiWPcbQdAiDG/IQWCA2QCVQewTeT2kfZf/you94w== | ||||
"@modal-sh/mio-ai@link:../..": | |||||
version "0.0.0" | |||||
uid "" | |||||
"@next/eslint-plugin-next@^13.2.4": | "@next/eslint-plugin-next@^13.2.4": | ||||
version "13.3.0" | version "13.3.0" | ||||
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.3.0.tgz#3a4742b0817575cc0dd4d152cb10363584c215ac" | resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.3.0.tgz#3a4742b0817575cc0dd4d152cb10363584c215ac" | ||||