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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dao3fun/siliconflow-chat

v1.0.3

Published

在神岛中调用硅基流动平台对话相关AI

Downloads

14

Readme

神岛 AI 对话服务

为 Box3 游戏引擎打造的智能对话解决方案,基于硅流平台 AI 能力。

简介

这是一个专为神岛(Box3)创作者设计的 AI 对话服务封装包,让你能够轻松地在游戏中集成智能对话功能。通过简单的 API 调用,即可实现与 AI 助手的自然交互。

🔗 还没有硅流平台账号?点击这里快速注册

安装

npm install @dao3fun/siliconflow-chat

快速开始

import { SiliconflowChat } from "@dao3fun/siliconflow-chat";

// 初始化聊天服务
const chatService = new SiliconflowChat({
  apiKey: "your-api-key-here",
});

// 在 Box3 中使用
world.onPlayerJoin(async ({ entity }) => {
  const response = await chatService.create({
    model: "deepseek-ai/DeepSeek-V3",
    messages: [
      {
        role: "user",
        content: `你好,我是${entity.player.name},很高兴见到你!`,
      },
    ],
  });

  entity.player.dialog({
    type: GameDialogType.TEXT,
    title: "AI 助手",
    content: response?.choices?.[0]?.message?.content || "服务暂不可用",
  });
});

API 文档

SiliconflowChat

主要的服务类,用于处理与硅流平台的通信。

构造函数

constructor(config: { apiKey: string })
  • config.apiKey: 硅流平台的 API 密钥

方法

create(prop: ISiliconflowFormat): Promise<ISiliconflowResult | null>

创建一个新的对话请求。

参数:

  • prop: 请求参数对象
    • model: 模型名称
    • messages: 对话消息数组
    • stream: 流式输出(Box3 暂不支持,固定为 false)

返回值:

  • 成功时返回响应结果对象
  • 失败时返回 null

类型定义

ISiliconflowFormat

请求参数格式接口。

🔗 硅流平台 API 参数一览

interface ISiliconflowFormat {
  model: string;
  messages: {
    role: "system" | "user" | "assistant";
    content: string;
  }[];
  stream?: false;
  [key: string]: any;
}

ISiliconflowResult

响应结果格式接口。

interface ISiliconflowResult {
  id: string;
  choices: Array<{
    message: {
      role: "assistant";
      content: string;
      reasoning_content: string;
    };
    finish_reason: "stop";
  }>;
  usage: {
    prompt_tokens: number;
    completion_tokens: number;
    total_tokens: number;
  };
  created: number;
  model: string;
  object: "chat.completion";
}

注意事项

  1. Box3 引擎目前不支持流式输出
  2. 请确保在使用前配置正确的 API 密钥
  3. 建议实现错误处理机制
  4. 注意控制对话频率,避免超出 API 限制