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

aidoc-chat-ui-component

v0.1.1

Published

A Vue 3 chat interface component for LLM applications with streaming support

Readme

@aidoc/chat-ui

一个基于 Vue 3 的现代化聊天界面组件库,专为 LLM 应用设计,支持流式响应、对话历史、模型选择等完整功能。

✨ 特性

  • 🚀 开箱即用 - 提供完整的对话界面解决方案
  • 💬 流式响应 - 支持 SSE 流式消息接收
  • 📚 对话历史 - 完整的会话管理和历史记录
  • 🎨 主题定制 - 支持亮色/暗色主题及自定义样式
  • 🔧 高度可配置 - 灵活的配置选项和插槽系统
  • 📱 响应式设计 - 适配各种屏幕尺寸
  • 🌐 国际化 - 内置多语言支持
  • 性能优化 - 虚拟滚动和懒加载
  • 🔌 API 抽象 - 通过适配器模式支持不同后端

📦 安装

npm install aidoc-chat-ui-component
# 或
yarn add aidoc-chat-ui-component
# 或
pnpm add aidoc-chat-ui-component

🚀 快速开始

基础使用

<template>
  <div style="height: 600px;">
    <ChatInterface
      :config="chatConfig"
      :api-adapter="apiAdapter"
      :knowledge-base-id="knowledgeBaseId"
      @message-sent="handleMessageSent"
      @message-received="handleMessageReceived"
    />
  </div>
</template>

<script setup>
import { ChatInterface, createDefaultApiAdapter, createChatConfig } from '@aidoc/chat-ui'
import '@aidoc/chat-ui/dist/style.css'

// 创建配置
const chatConfig = createChatConfig({
  theme: 'light',
  enableHistory: true,
  enableModelSelection: true,
  placeholder: '请输入您的问题...'
})

// 创建 API 适配器
const apiAdapter = createDefaultApiAdapter({
  apiEndpoint: '/api/chat',
  headers: {
    Authorization: 'Bearer your-token'
  }
})

const knowledgeBaseId = ref(1)

const handleMessageSent = (message) => {
  console.log('发送消息:', message)
}

const handleMessageReceived = (message) => {
  console.log('收到回复:', message)
}
</script>

全局注册

import { createApp } from 'vue'
import AidocChatUI from 'aidoc-chat-ui-component'
import 'aidoc-chat-ui-component/dist/style.css'

const app = createApp(App)
app.use(AidocChatUI)
app.mount('#app')

📖 配置选项

ChatConfig

const config = createChatConfig({
  // API 配置
  apiEndpoint: '/api/chat',
  headers: {},

  // 功能开关
  enableHistory: true,
  enableSummary: false,
  enableModelSelection: true,
  enableMessageActions: true,

  // 界面配置
  theme: 'light', // 'light' | 'dark' | 'auto'
  locale: 'zh-CN',
  placeholder: '请输入您的问题...',

  // 行为配置
  maxHistoryItems: 50,
  autoScroll: true,
  showTimestamp: true,
  enableMarkdown: true,

  // 样式配置
  height: '600px',
  width: '100%',
  borderRadius: '8px'
})

API 适配器

// 使用默认适配器
const apiAdapter = createDefaultApiAdapter({
  apiEndpoint: '/api/chat',
  headers: {
    Authorization: 'Bearer token'
  }
})

// 或创建自定义适配器
class CustomApiAdapter {
  async createMessage(options) {
    // 实现创建消息逻辑
  }

  sendMessage(messageId, callbacks) {
    // 实现流式消息发送
    return cancelFunction
  }

  async getModels() {
    // 返回可用模型列表
  }

  // ... 其他方法
}

🎨 主题定制

预设主题

<ChatInterface :config="{ theme: 'dark' }" />

支持的主题:

  • light - 浅色主题
  • dark - 深色主题
  • auto - 自动跟随系统
  • blue - 蓝色主题
  • green - 绿色主题
  • purple - 紫色主题

自定义样式

.aidoc-chat {
  --chat-primary-color: #your-color;
  --chat-bg-color: #your-bg;
  --chat-text-color: #your-text;
  /* 更多 CSS 变量... */
}

🔧 高级用法

自定义插槽

<ChatInterface :config="config" :api-adapter="adapter">
  <template #title>
    <h3>我的智能助手</h3>
  </template>
  
  <template #header-actions>
    <button @click="customAction">自定义按钮</button>
  </template>
  
  <template #message-actions="{ message }">
    <button @click="customMessageAction(message)">
      自定义操作
    </button>
  </template>
</ChatInterface>

事件处理

<ChatInterface
  @message-sent="onMessageSent"
  @message-received="onMessageReceived"
  @session-changed="onSessionChanged"
  @model-changed="onModelChanged"
  @error="onError"
/>

📚 组件 API

ChatInterface Props

| 属性 | 类型 | 默认值 | 描述 | | --------------- | ------------- | ------ | -------------- | | config | Object | {} | 聊天配置对象 | | apiAdapter | Object | - | API 适配器实例 | | knowledgeBaseId | String/Number | null | 知识库 ID | | sessionId | String/Number | null | 会话 ID |

ChatInterface Events

| 事件 | 参数 | 描述 | | ---------------- | ------- | -------------- | | message-sent | message | 消息发送时触发 | | message-received | message | 收到消息时触发 | | session-changed | session | 会话切换时触发 | | model-changed | model | 模型切换时触发 | | error | error | 发生错误时触发 |

🛠️ 开发

# 克隆项目
git clone https://github.com/aidoc/chat-ui.git

# 安装依赖
cd chat-ui
npm install

# 开发模式
npm run dev

# 构建
npm run build

# 预览
npm run preview

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 支持

如有问题,请提交 Issue 或联系我们。