Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balance #15

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add balance information when boot the kimi CLI
  • Loading branch information
JacksonTian committed Apr 24, 2024
commit 7ff549f8b5a0ed78f4e1dd39f871243e96c6d561
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const response = await client.models();
- `getFileContent()`
- `deleteFile()`
- `estimateTokenCount()`
- `getBalance()`

The detail of parameters can be found at <https://platform.moonshot.cn/docs/api-reference> or [`test/kimi.test.js`](./test/kimi.test.js).

Expand Down
4 changes: 4 additions & 0 deletions bin/kimi.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const pkg = loadJSONSync(path.join(__dirname, '../package.json'));
console.log(`Welcome to KIMI CLI(v${pkg.version}), type ${chalk.bgGray('.help')} for more information.`);
console.log(`Current model is ${chalk.bgGreen(config.model)}.`);

const balance = await kimi.getBalance();
const {available_balance, cash_balance, voucher_balance } = balance.data;
console.log(`Current balance: ¥${available_balance}(Cash: ¥${cash_balance}, Voucher: ¥${voucher_balance}}).`);

// eslint-disable-next-line no-constant-condition
while (true) {
const answer = await rl.question('What is your query: ');
Expand Down
Loading