UNPKG

@artmate/chat

Version:

**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**

29 lines (28 loc) 663 B
import { ref as n, shallowRef as u } from "vue"; import c from "../artStream/index.js"; function m() { const r = n([]), t = n(null), l = n(!1), e = u(null); return { startStream: async (o) => { l.value = !0, t.value = null, r.value = [], e.value = c(o); try { for await (const a of e.value) r.value.push(a); } catch (a) { a instanceof Error && (t.value = a); } finally { l.value = !1, e.value = null; } }, cancel: () => { e.value && e.value.getReader().cancel(); }, // 新增中断方法 data: r, error: t, isLoading: l }; } export { m as useXStream };