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-ai-browser

v0.1.8

Published

基于科大讯飞「星火大模型」WEB 版本封装

Downloads

7

Readme

spark-ai-browser

基于科大讯飞「星火大模型」browser 版本封装

安装

安装步骤和依赖说明

 npm install spark-ai-browser
 pnpm add spark-ai-browser
 yarn add spark-ai-browser

使用

厂家平台配置: https://console.xfyun.cn/services/bm35

星火开发者文档示意图

// 代码示例
import { Spark } from 'spark-ai-browser';

interface OptionType {
  appId: string; // 配置
  apiSecret: string; // 配置
  apiKey: string; // 配置
  sendType:"step"|"all"; // step 每段消息都会通知更新监听函数, all 请求完毕才会更新监听函数
  version: '1.1' | '2.1' | '3.1' | '3.5'; //default: '1.1';
}
const spark = new Spark(option );

// 监听数据响应
spark.watchDataChange((text: string, ResultData:ResultData) => {
  // 业务处理
});

// 发送消息
spark.webSocketSend(body as SendBody);

interface SendBody {
  uuid?: string; // 可以用来标记发送消息人身份,默认系统随机数
  content: string;

  // payload 默认配置
  // {
  //     message: {
  //           text: [
  //             {
  //               role: 'user',
  //               content,
  //             },
  //           ],
  //         },
  // }

  payload?: {
    message: {
      text: {
        role: string,
        content: string,
      }[],
    },
  };

  // parameter 默认配置
  // {
  //     chat: {
  //           domain: this.option.modelDomain,
  //           temperature: 0.5,
  //           max_tokens: 1024,
  //         },
  // }
  parameter?: {
    chat: {
      domin: string,
      temperature: number,
      max_tokens: number,
    },
  };
}

interface ResultData {
  header: {
    code: number,
    message: string,
    sid: string,
    status: number,
  };
  payload: {
    choices: {
      seq: number,
      status: number,
      text: {
        content: string,
        index: number,
        role: 'assistant',
      }[],
      question_type: 'knowledge',
    },
  };
}


// 我只想获取 socket url 地址,我懒得搞加密那些动作,剩下的事,我自己做!
// OK 满足

const spark = new Spark(option );
spark.getOption().url  // socket url 完整地址,接下来就交给你自己了。

贡献

1. Fork该仓库
2. 创建一个新的分支 (`git checkout -b feature/awesome-feature`)
3. 提交你的修改 (`git commit -am 'Add some awesome feature'`)
4. 推送到分支 (`git push origin feature/awesome-feature`)
5. 提交一个拉取请求

联系方式

如果有任何问题或者反馈,可以通过以下方式联系作者:

邮箱:[email protected]

微信:nianyi778 ( 备注 spark-ai )

其他

项目背景

使用科大讯飞星火大模型 spark3.5 max 版本时,发现准备工作还是挺多的,去查了一下其他开发者开源方案,都不太符合需求。因此萌发了封装聚合的想法。 so spark-ai-browser 诞生了。 欢迎👏 PR

参考资料

星火认知大模型 Web API 文档