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

spark-desk

v1.2.0

Published

这是一个采用 nodejs 驱动的,使用 web 方式调用 讯飞星火认知大模型 的js库。

Downloads

19

Readme

spark-desk

这是一个采用 nodejs 驱动的,使用 web 方式调用 讯飞星火认知大模型 的js库。 可以将其全局安装,然后通过 cli 的方式使用。 也可以进行局部安装,然后在你的 nodejs 项目里使用。

  1. 使用 typescript
  2. 支持 cjs 和 esm
  3. 在命令行中使用
  4. 面向对象
  5. 支持 V1.5、V2、V3接口

简单尝试

你需要在讯飞开放平台中申请星火大模型的使用

npm i spark-desk -g

在安装后,运行 spark-desk 命令,会让你输入 APPIDAPISecretAPIKey; 之后,这些信息将保存到你的用户目录下的 .spark-desk 文件中,以 json 的方式。

你可以手动编辑 .spark-desk 文件,以达到改变配置文件的目的

程序默认使用的版本是 V3

在程序启动后,你可以通过命令行与AI交互。

C:\Users\user>spark-desk
spark-desk > 你好
你好!有什么我可以帮忙的吗?[10/9/19]
spark-desk >

其中 [10/9/19] 表示每次回答 token 的消耗,具体对应着 [prompt_tokens/completion_tokens/total_tokens],参考文档

比较有意思的是,你可已通过 -u 参数指定用户名称,也就是指定 请求参数中的 uid 字段,同时,命令行前缀也将显示成 uid 。

spark-desk -u demo
demo > 

程序也会读取配置文件中的 uid 字段,但是命令行中指定的优先级更高。

关于历史消息

提问时,可以将之前的历史消息发送一起发送,以获得良好的上下文体验,但这样通常会消耗大量的 token 。

你可以通过 -l 参数指定文本内容的长度.

是字母 L 的小写, length 的首字母。

默认情况下,任何历史消息都不会发送,也就是 -l = 0

使用样例

C:\Users\user>spark-desk -l 20
spark-desk > 我叫 spark-desk
[13/21/34] 你好,spark-desk!很高兴为你提供帮助。请问有什么问题我可以帮您解答吗?
spark-desk > 我叫什么?
[25/16/41] 很抱歉,我不知道你叫什么。请问有什么我可以帮助你的吗?
spark-desk > 我叫什么?
[25/13/38] 您的名字是“spark-desk”,这是一个虚构的名字。

回答有概率问题,但是AI大概率会告诉你 你叫 spark-desk , 因为有上下文。 如果不指定 -l 参数,AI 基本上不会回答出你的名字。 因为上下文没有一起发送。

在您的项目里一起使用

cjs 方式
// index.js
const {SparkDesk} = require("spark-desk")
// 根据实际情况填写
const sparkDesk = new SparkDesk({
    APPID: "a5fxxxxxx",
    APISecret: "MGIxNTcwNDI4MGY1YjUxM2Mxxxxxxx",
    APIKey: "aa5fbf57f7818bd1cec61dexxxxxxxx",
    version: 3
});

const user = sparkDesk.createUser("demo");

user.speak("你好!很高兴认识你。").then(res => console.log(res.getAllContent()))

输出

node .\index.js
你好!很高兴认识你。请问有什么问题我可以帮您解答吗?
esm 方式

只需要将第一行换成下面的代码即可。

// index.mjs
import {SparkDesk} from "spark-desk"

本项目开发环境

| 名称 | 版本 | |----------|---------------------------------------------------| | nodejs | v16.20.2 | | npm | 8.19.4 | | OS | Windows Feature Experience Pack 1000.22659.1000.0 | | webstorm | Build #WS-232.8660.143, built on July 21, 2023 |