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

@zhengxs/ai

v0.6.1

Published

llm sdk

Downloads

494

Readme

集成 百度文心一言,阿里通义千问,腾讯混元助手 和 讯飞星火认知 等国内大模型的 API,并且适配 OpenAI 的输入与输出。

Report Bug · Request Feature

TOC

✨ 功能特性

  • 🚀 快速开始: 简单易用,只需一次学习,即可快速接入各种大模型。
  • 💻 多模型集成: 集成了多种国内大模型,为用户提供丰富的对话模型选择,满足不同场景的需求。
  • 💎 体验友好: 无需深入学习,只需提供必要的 API Key,剩下的交给 SDK 处理。
  • 🔌 完美适配: 适配 OpenAI 的输入与输出格式,确保与其他模型的对话无缝对接。

📖 使用文档

📦 安装

要安装 @zhengxs/ai,请运行以下命令:

$ pnpm install @zhengxs/ai

👋 使用

在这里获取你的 accessToken 值。

import { ErnieAI } from '@zhengxs/ai';

const client = new ErnieAI({
  apiKey: 'My API Key', // defaults to process.env["EB_API_KEY"]
});

async function main() {
  const chatCompletion = await client.chat.completions.create({
    model: 'ernie-bot-turbo',
    messages: [{ role: 'user', content: 'Say this is a test' }],
  });
}

main();

支持流式

使用与 OpenAI 的 SDK 完全一致。

import { ErnieAI } from '@zhengxs/ai';

const client = new ErnieAI();

async function main() {
  const stream = await client.chat.completions.create({
    model: 'ernie-bot-turbo',
    messages: [{ role: 'user', content: 'Say this is a test' }],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
}

main();

⌨️ 本地开发

可以使用 GitHub Codespaces 进行在线开发:

或者使用以下命令进行本地开发:

$ git clone https://github.com/zhengxs2018/ai.git
$ cd ai
$ pnpm install
$ pnpm dev

🔗 更多工具

🤝 参与贡献

我们非常欢迎各种形式的贡献。如果你对贡献代码感兴趣,可以查看我们的 GitHub Issues 大展身手,向我们展示你的奇思妙想。

🕘 Star History

Star History Chart


📝 License

Copyright © 2023 zhengxs2018. This project is MIT licensed.