Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.09 KB

File metadata and controls

62 lines (46 loc) · 1.09 KB

Vue AI Stream Helper

English | 简体中文

一个轻量级的 Vue.js 插件,用于处理 AI 大模型的流式响应(SSE)。

特性

流式响应 - 完整的 SSE 支持
💬 实时更新 - 即时获取 AI 回复
🔄 请求管理 - 支持取消请求
🔐 自动认证 - 自动添加 Token
轻量高效 - 零依赖
🎯 易于使用 - 简洁的 API

安装

npm install vue-ai-stream-helper

快速开始

// main.js
import Vue from 'vue';
import AIStreamHelper from 'vue-ai-stream-helper';

Vue.use(AIStreamHelper, {
  baseURL: 'https://your-api.com',
  endpoint: '/api/chat',
  getToken: () => localStorage.getItem('token')
});

使用

<script>
export default {
  methods: {
    async chat() {
      await this.$aiChat.chat({
        content: '你好',
        onMessage: ({ fullContent }) => {
          console.log(fullContent);
        }
      });
    }
  }
}
</script>

文档

详细文档请查看 README.mdEXAMPLES.md

许可证

MIT