npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jacksontian/kimi

v1.2.1

Published

The Node.js library and CLI for Moonshot AI

Downloads

55

Readme

The Node.js library and CLI for Moonshot AI

Node.js CI codecov NPM version npm download

Installation/安装

npm i @jacksontian/kimi -g # for CLI
npm i @jacksontian/kimi # for scripting

Usage for CLI

Set API key

You can visit https://platform.moonshot.cn/console/api-keys to get api key.

When you use kimi or kimi-file first time, will prompt you to set api key.

$ kimi
? Please input your kimi api key(you can visit https://platform.moonshot.cn/console/api-keys to get api key): ***************************************************
Welcome to KIMI CLI(v1.0.0), type .help for more information.
Current model is moonshot-v1-32k.
What is your query: 

Or you can re-set it with .set_api_key command.

Chat with KIMI

$ kimi
Welcome to KIMI CLI(v1.0.0), type .help for more information.
Current model is moonshot-v1-128k.
What is your query: 写一首七言唐诗
春风拂面桃花开,
绿水青山共舞来。
鸟语花香满园中,
人间仙境难寻觅。

夕阳西下映江面,
渔舟唱晚共欢颜。
岁月匆匆莫虚度,
共赏繁华似锦年。
[Verbose] request id: chatcmpl-5cc0493c22fb4268b0772b08300886b1, usage tokens: 62

File helper

We support a tiny command to manage files.

$ kimi-file # list all files
| id                   | filename                       | purpose      | type | size       | created_at          | status |
| -------------------- | ------------------------------ | ------------ | ---- | ---------- | ------------------- | ------ |
| co6efvg3r07e3eepmxxx | 1906.08237.pdf                 | file-extract | file | 761790     | 2024-04-03 05:24:14 | ok     |
$ kimi-file upload ~/xxx/test.pdf   # upload file
$ kimi-file get the-file-id         # get file
$ kimi-file rm the-file-id          # delete file

You can use .add_file command to choose a uploaded file:

$ kimi
Welcome to KIMI CLI(v1.0.0), type .help for more information.
Current model is moonshot-v1-128k.
What is your query: .add_file
? Please select your file: (Use arrow keys)
? Please select your file: 1906.08237.pdf
The file 1906.08237.pdf is added into chat session.
What is your query: 请解读 1906.08237.pdf 文件内容

Switch model

You can use .set_model command to switch models:

$ kimi
Welcome to KIMI CLI(v1.0.0), type .help for more information.
Current model is moonshot-v1-128k.
What is your query: .set_model
? Please select your model: 
? Please select your model: moonshot-v1-32k
The model is switched to moonshot-v1-32k now.

Usage for scripting

import Kimi from '@jacksontian/kimi';

const client = new Kimi({
    // Do not hard code it here, read it from configuration or enviroment variables
    apiKey: 'The API key for moonshot AI'
});
const response = await client.models();

API

  • Chat

    • chat()
    • models()
    • estimateTokenCount()
  • Files

    • putFile()
    • putFileStream()
    • files()
    • getFile()
    • getFileContent()
    • deleteFile()
  • Others

    • getBalance()

The detail of parameters can be found at https://platform.moonshot.cn/docs/api-reference or test/kimi.test.js.

License

The MIT license.