@frost1994/agentic-vue

AI 助手 Vue3 组件 + Pinia + SDK 入口
2,995
Install
npm install @frost1994/agentic-vue
Latest Version:1.0.21
Vue:3
License:Apache-2.0
Last Updated:Oct 16, 2026
Links: Gitee  ·  npm
Maintainer: frost1994

@frost1994/agentic-vue

设备排程系统 AI 助手 —— Vue3 组件 + Pinia + 一行接入的 SDK。

主入口包。提供悬浮窗 / 侧边抽屉 / 全屏工作区 / 聚焦模态等交互形态,内置 DSH typed-event 流式对话、evidence-bound 问数结果、工具调用面板与 Action Center 二次确认。

安装

pnpm add @frost1994/agentic-vue

peer 依赖(由宿主提供)

依赖 版本
vue ^3.4
element-plus ^2.6
pinia ^2.1
echarts ^5.5

用法

一行接入(推荐)

import { createApp } from 'vue'
import { installAiAssistant } from '@frost1994/agentic-vue'
import '@frost1994/agentic-vue/style.css'

const app = createApp(App)

installAiAssistant(app, {
  systemCode: 'equipment-scheduler',
  apiBaseUrl: '/api/ai',
  // 可选:把当前页面上下文喂给助手
  contextProvider: () => ({ pageCode: 'dashboard', routePath: location.pathname }),
  // 可选:登录用户与数据范围(注入鉴权头)
  userProvider: () => ({ userId: 'u1', orgId: 'org-1', dataScope: 'workshop-A' }),
})

app.mount('#app')

命令式控制

import { createAiAssistant } from '@frost1994/agentic-vue'

const assistant = createAiAssistant({ systemCode: 'equipment-scheduler', apiBaseUrl: '/api/ai' })
assistant.install(app)

assistant.open()
await assistant.send('上周 A 车间各设备的产量是多少?')
assistant.switchMode('drawer') // launcher | floating | drawer | fullscreen

暗色主题

暗色 token 已内置于 style.css,无需额外引样式。通过初始化选项或运行时切换即可:

installAiAssistant(app, { systemCode, apiBaseUrl, theme: { mode: 'dark' } })
// 或运行时:useThemeStore().mode = 'dark'   // 'light' | 'dark' | 'system'

语音输入(语音转文字)

输入框自带一个麦克风按钮,点击即可把语音实时转写进输入框,转写完成后由用户检查再发送(不自动发送)。 基于浏览器原生 Web Speech API(SpeechRecognition),无需后端、不上传音频;默认中文识别(zh-CN)。

// 默认开启;如需关闭:
installAiAssistant(app, { systemCode, apiBaseUrl, features: { enableVoice: false } })

环境要求与降级:

  • 需要安全上下文(HTTPS 或 localhost)且浏览器支持该 API(Chrome / Edge)。不满足时麦克风按钮自动置灰并提示「当前浏览器不支持语音输入」。
  • 首次点击会请求麦克风权限;被拒绝 / 无设备 / 网络异常等会在输入框下方给出简短中文提示。

如需在自有组件里复用识别逻辑,可直接使用导出的 composable:

import { useSpeechRecognition } from '@frost1994/agentic-vue'

const speech = useSpeechRecognition({
  lang: 'zh-CN',
  onResult: chunk => {
    /* 追加到你的输入框 */
  },
})
if (speech.isSupported) speech.toggle() // start / stop

导出

组件(AiAssistantRoot / AiFloatingWindow / AiSideDrawer / 各类结果卡片)、 Pinia stores、composables(useAiAssistant / renderMarkdown / useSpeechRecognition)、指令 (vDraggable / vResizable / vFocusTrap)与全部类型声明均已具名导出,可按需引用。

License

Apache-2.0 © frost1994

Related Packages

gimc-ai-agent

GIMC 智能客服(Vue3版)

4,456
kd-chatbot-ui

智能体会话 UI。请求由宿主传入 request,组件库不写死鉴权与 baseURL。

375
@142vip/vue

基于Vue3框架进行封装

4,792
@leatop/ai-agent

Leatop CDP AI Agent - Vue 3 智能对话组件库

3,781

Version History

Version Released Vue License
1.0.21 ^3.4.0 Apache-2.0
1.0.20 ^3.4.0 Apache-2.0
1.0.19 ^3.4.0 Apache-2.0
1.0.16 ^3.4.0 Apache-2.0
1.0.15 ^3.4.0 Apache-2.0