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 🙏

© 2026 – Pkg Stats / Ryan Hefner

chat-ai-plugin

v1.0.1

Published

A powerful chatAI plugin for any project with AI-powered Q&A, reporting, and chart generation

Readme

ChatAI Plugin

一个功能强大的聊天 AI 插件,支持 AI 问答、图表生成、报表生成和项目交互。

特性

  • 🤖 AI 驱动的智能问答
  • 📊 自动生成图表和报表
  • 🔄 与宿主项目交互(跳转、数据传递等)
  • 🎨 可自定义主题和样式
  • 📱 响应式设计,支持移动端
  • 🚀 基于 Vite + React + Ant Design 5

安装

npm install chat-ai-plugin

使用方法

基本用法

import React from "react";
import { ChatAIProvider, ChatAIPlugin } from "chat-ai-plugin";

function App() {
  return (
    <ChatAIProvider>
      <div>
        <h1>我的应用</h1>
        <ChatAIPlugin />
      </div>
    </ChatAIProvider>
  );
}

高级配置

import React from "react";
import { ChatAIProvider, ChatAIPlugin } from "chat-ai-plugin";

function App() {
  const config = {
    apiKey: "your-openai-api-key",
    apiEndpoint: "https://api.openai.com/v1/chat/completions",
    theme: "dark",
    position: "bottom-right",
    width: 450,
    height: 650,
    onMessage: message => {
      console.log("收到消息:", message);
    },
    onNavigate: path => {
      // 处理路由跳转
      window.location.href = path;
    },
    onGenerateChart: chartData => {
      // 处理图表生成
      console.log("生成图表:", chartData);
    },
    onGenerateReport: reportData => {
      // 处理报表生成
      console.log("生成报表:", reportData);
    },
  };

  return (
    <ChatAIProvider config={config}>
      <div>
        <h1>我的应用</h1>
        <ChatAIPlugin />
      </div>
    </ChatAIProvider>
  );
}

使用自定义 Hook

import React from "react";
import { useChatAI } from "chat-ai-plugin";

function MyComponent() {
  const { messages, sendMessage, toggleChat, isOpen } = useChatAI();

  const handleCustomAction = async () => {
    await sendMessage("请生成一个销售报表");
  };

  return (
    <div>
      <button onClick={handleCustomAction}>生成报表</button>
      <button onClick={toggleChat}>{isOpen ? "关闭聊天" : "打开聊天"}</button>
    </div>
  );
}

API 参考

ChatAIConfig

| 属性 | 类型 | 默认值 | 说明 | | ---------------- | ------------------------------------------------------------ | --------------- | --------------- | | apiKey | string | - | OpenAI API 密钥 | | apiEndpoint | string | OpenAI 默认端点 | AI 服务端点 | | theme | 'light' | 'dark' | 'light' | 主题 | | position | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-right' | 聊天窗口位置 | | width | number | 400 | 聊天窗口宽度 | | height | number | 600 | 聊天窗口高度 | | onMessage | function | - | 消息回调 | | onNavigate | function | - | 导航回调 | | onGenerateChart | function | - | 图表生成回调 | | onGenerateReport | function | - | 报表生成回调 |

useChatAI Hook

| 属性 | 类型 | 说明 | | ------------- | -------------- | ---------------- | | messages | ChatMessage[] | 聊天消息列表 | | isLoading | boolean | 是否正在加载 | | isOpen | boolean | 聊天窗口是否打开 | | config | ChatAIConfig | 当前配置 | | error | string | null | 错误信息 | | sendMessage | function | 发送消息 | | toggleChat | function | 切换聊天窗口 | | clearMessages | function | 清空消息 | | setConfig | function | 更新配置 |

开发

安装依赖

npm install

开发模式

npm run dev

构建

npm run build

类型检查

npm run type-check

许可证

MIT