@seer-ai/seer-vue 0.1.0-beta.1 → 0.1.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -3
- package/dist/client.d.ts +29 -0
- package/dist/components/SeerChat.vue.d.ts +11 -3
- package/dist/content.d.ts +24 -0
- package/dist/index.css +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +628 -263
- package/dist/plugin.d.ts +4 -0
- package/dist/useSeerChat.d.ts +21 -1
- package/package.json +14 -7
package/README.md
CHANGED
|
@@ -13,11 +13,14 @@ npm install @seer-ai/seer-vue@beta
|
|
|
13
13
|
```ts
|
|
14
14
|
import { createApp } from 'vue'
|
|
15
15
|
import { SeerChatPlugin } from '@seer-ai/seer-vue'
|
|
16
|
+
import '@seer-ai/seer-vue/style.css' // 必须:链接的蓝色/下划线样式来自这里
|
|
16
17
|
import App from './App.vue'
|
|
17
18
|
|
|
18
19
|
createApp(App)
|
|
19
20
|
.use(SeerChatPlugin, {
|
|
20
|
-
|
|
21
|
+
sessionEndpoint: 'https://seer.example.com/v1/browser/session',
|
|
22
|
+
endpoint: 'https://seer.example.com/v1/browser/chat/completions',
|
|
23
|
+
transcriptionEndpoint: 'https://seer.example.com/v1/browser/audio/transcriptions',
|
|
21
24
|
model: 'seer',
|
|
22
25
|
stream: false,
|
|
23
26
|
})
|
|
@@ -34,12 +37,39 @@ import { SeerChat } from '@seer-ai/seer-vue'
|
|
|
34
37
|
</template>
|
|
35
38
|
```
|
|
36
39
|
|
|
40
|
+
支持 MediaRecorder 的 HTTPS/localhost 页面会显示话筒。用户点击开始、再次点击停止,最长录音
|
|
41
|
+
60 秒;SenseVoice 转写结果只回填输入框,不会自动发送。标准 browser chat endpoint 会自动
|
|
42
|
+
推导 transcription endpoint,也可显式配置;传 `voiceEnabled: false` 可关闭话筒。
|
|
43
|
+
|
|
44
|
+
输入框旁的回形针按钮用来上传附件(下单模板 xlsx/xls/csv、图片、PDF),上传地址同样按 endpoint 推导成
|
|
45
|
+
`/v1/browser/files`,也可用 `uploadEndpoint` 显式配置;传 `uploadEnabled: false` 隐藏按钮。自定义 UI 用
|
|
46
|
+
`useSeerChat()` 的 `attach(file)` / `removeAttachment(fileId)` / `attachments`,`send(text)` 会带上待发送的附件。
|
|
47
|
+
|
|
48
|
+
## Logged-in customer (`orgOwner`)
|
|
49
|
+
|
|
50
|
+
传入已登录用户的多发货 `orgOwner`,询价时 seer 直接用它当客户编码,不再追问。登录态会变时传函数;
|
|
51
|
+
值变化后插件自动重新建会话。也可以用组件 prop:`<SeerChat :org-owner="user?.orgOwner" />`。
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
app.use(SeerChatPlugin, {
|
|
55
|
+
sessionEndpoint: 'https://seer.example.com/v1/browser/session',
|
|
56
|
+
endpoint: 'https://seer.example.com/v1/browser/chat/completions',
|
|
57
|
+
orgOwner: () => currentUser.value?.orgOwner,
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
插件在建会话时发 `X-Seer-Org-Owner`。seer 不校验这个值,只用于补报价客户编码,不参与订单归属。
|
|
62
|
+
|
|
37
63
|
## Use custom UI
|
|
38
64
|
|
|
65
|
+
自定义 UI 时**不要**直接把 `message.content` 当纯文本渲染——回复里的下载/截图链接是裸
|
|
66
|
+
URL 文本,会原样显示成一长串 url。用导出的 `toContentLines` 把它切成可点链接(这正是
|
|
67
|
+
`<SeerChat>` 内部用的逻辑):
|
|
68
|
+
|
|
39
69
|
```vue
|
|
40
70
|
<script setup lang="ts">
|
|
41
71
|
import { ref } from 'vue'
|
|
42
|
-
import { useSeerChat } from '@seer-ai/seer-vue'
|
|
72
|
+
import { toContentLines, useSeerChat } from '@seer-ai/seer-vue'
|
|
43
73
|
|
|
44
74
|
const input = ref('')
|
|
45
75
|
const chat = useSeerChat()
|
|
@@ -51,8 +81,25 @@ async function submit() {
|
|
|
51
81
|
await chat.send(content)
|
|
52
82
|
}
|
|
53
83
|
</script>
|
|
84
|
+
|
|
85
|
+
<template>
|
|
86
|
+
<div v-for="(message, i) in chat.messages.value" :key="i">
|
|
87
|
+
<p v-for="(line, li) in toContentLines(message.content)" :key="li">
|
|
88
|
+
<template v-for="(seg, si) in line" :key="si">
|
|
89
|
+
<a v-if="seg.kind === 'link'" :href="seg.href" target="_blank" rel="noopener noreferrer">{{
|
|
90
|
+
seg.label
|
|
91
|
+
}}</a>
|
|
92
|
+
<img v-else-if="seg.kind === 'image'" :src="seg.href" :alt="seg.alt" loading="lazy" />
|
|
93
|
+
<span v-else>{{ seg.value }}</span>
|
|
94
|
+
</template>
|
|
95
|
+
</p>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
54
98
|
```
|
|
55
99
|
|
|
56
100
|
## Security
|
|
57
101
|
|
|
58
|
-
Do not put long-lived seer API keys in browser code or `VITE_*` variables. Browser code should call
|
|
102
|
+
Do not put long-lived seer API keys in browser code or `VITE_*` variables. Browser code should call
|
|
103
|
+
seer's browser session endpoint, receive a short-lived token, and use that token for
|
|
104
|
+
`/v1/browser/chat/completions` and `/v1/browser/audio/transcriptions`. Raw audio is uploaded only for
|
|
105
|
+
the current transcription and must not be persisted.
|
package/dist/client.d.ts
CHANGED
|
@@ -4,10 +4,19 @@ export interface SeerChatMessage {
|
|
|
4
4
|
content: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
|
+
export type SeerOrgOwner = string | (() => string | undefined);
|
|
7
8
|
export interface SeerClientOptions {
|
|
8
9
|
endpoint: string;
|
|
10
|
+
sessionEndpoint?: string;
|
|
11
|
+
transcriptionEndpoint?: string;
|
|
12
|
+
/** 附件上传地址;不传时按 endpoint 推成同域的 /v1/browser/files,传空字符串关闭上传。 */
|
|
13
|
+
uploadEndpoint?: string;
|
|
14
|
+
challengeTokenProvider?: () => Promise<string>;
|
|
15
|
+
/** 已登录用户的多发货 orgOwner;报价时自动当作客户编码。登录态会变时传函数。 */
|
|
16
|
+
orgOwner?: SeerOrgOwner;
|
|
9
17
|
model?: string;
|
|
10
18
|
fetcher?: typeof fetch;
|
|
19
|
+
now?: () => number;
|
|
11
20
|
}
|
|
12
21
|
export interface SeerChatRequest {
|
|
13
22
|
messages: SeerChatMessage[];
|
|
@@ -15,11 +24,26 @@ export interface SeerChatRequest {
|
|
|
15
24
|
stream?: boolean;
|
|
16
25
|
conversationId?: string;
|
|
17
26
|
metadata?: Record<string, unknown>;
|
|
27
|
+
/** 先 upload() 拿到的 fileId,随这条消息一起提交。 */
|
|
28
|
+
attachments?: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface SeerUploadedFile {
|
|
31
|
+
fileId: string;
|
|
32
|
+
filename: string;
|
|
33
|
+
kind: 'spreadsheet' | 'image' | 'document' | string;
|
|
34
|
+
contentType: string;
|
|
35
|
+
size: number;
|
|
18
36
|
}
|
|
19
37
|
export interface SeerChatCallbacks {
|
|
20
38
|
signal?: AbortSignal;
|
|
21
39
|
onDelta?: (delta: string) => void;
|
|
22
40
|
}
|
|
41
|
+
export interface SeerTranscriptionCallbacks {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}
|
|
44
|
+
export interface SeerTranscriptionResult {
|
|
45
|
+
text: string;
|
|
46
|
+
}
|
|
23
47
|
export interface SeerChatResult {
|
|
24
48
|
content: string;
|
|
25
49
|
conversationId?: string;
|
|
@@ -28,6 +52,11 @@ export interface SeerChatResult {
|
|
|
28
52
|
finishReason?: string;
|
|
29
53
|
}
|
|
30
54
|
export interface SeerClient {
|
|
55
|
+
transcriptionEnabled: boolean;
|
|
56
|
+
uploadEnabled: boolean;
|
|
31
57
|
chat(request: SeerChatRequest, callbacks?: SeerChatCallbacks): Promise<SeerChatResult>;
|
|
58
|
+
transcribe(audio: Blob, filename: string, callbacks?: SeerTranscriptionCallbacks): Promise<SeerTranscriptionResult>;
|
|
59
|
+
upload(file: Blob, filename: string, callbacks?: SeerTranscriptionCallbacks): Promise<SeerUploadedFile>;
|
|
32
60
|
}
|
|
33
61
|
export declare function createSeerClient(options: SeerClientOptions): SeerClient;
|
|
62
|
+
export declare function resolveOrgOwner(orgOwner: SeerOrgOwner | undefined): string | undefined;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type { SeerClientOptions } from
|
|
1
|
+
import type { SeerClientOptions } from "../client";
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
endpoint?: string;
|
|
4
|
+
sessionEndpoint?: string;
|
|
5
|
+
transcriptionEndpoint?: string;
|
|
6
|
+
uploadEndpoint?: string;
|
|
7
|
+
uploadEnabled?: boolean;
|
|
8
|
+
orgOwner?: string;
|
|
4
9
|
model?: string;
|
|
5
10
|
stream?: boolean;
|
|
6
|
-
fetcher?: SeerClientOptions[
|
|
11
|
+
fetcher?: SeerClientOptions["fetcher"];
|
|
7
12
|
title?: string;
|
|
8
13
|
placeholder?: string;
|
|
14
|
+
voiceEnabled?: boolean;
|
|
15
|
+
maxRecordingSeconds?: number;
|
|
9
16
|
};
|
|
10
17
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
11
18
|
stream: boolean;
|
|
12
19
|
title: string;
|
|
13
20
|
placeholder: string;
|
|
14
|
-
|
|
21
|
+
voiceEnabled: boolean;
|
|
22
|
+
uploadEnabled: boolean;
|
|
15
23
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
24
|
declare const _default: typeof __VLS_export;
|
|
17
25
|
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ContentSegment = {
|
|
2
|
+
kind: 'text';
|
|
3
|
+
value: string;
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'link';
|
|
6
|
+
href: string;
|
|
7
|
+
label: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'image';
|
|
10
|
+
href: string;
|
|
11
|
+
alt: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'price';
|
|
14
|
+
value: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'strong';
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
export interface ContentOptions {
|
|
20
|
+
complete?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function linkAnchorLabel(prefix: string): string | null;
|
|
23
|
+
export declare function toContentSegments(content: string, options?: ContentOptions): ContentSegment[];
|
|
24
|
+
export declare function toContentLines(content: string, options?: ContentOptions): ContentSegment[][];
|
package/dist/index.css
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
.seer-chat[data-v-
|
|
1
|
+
.seer-chat[data-v-adaeb672]{color:#18212f;background:radial-gradient(circle at 18% 0,#476aff24,#0000 32%),linear-gradient(#fff 0%,#f7f9fd 100%);border:1px solid #7f8faa47;border-radius:28px;gap:18px;max-width:720px;min-height:640px;padding:0;display:grid;overflow:hidden;box-shadow:0 24px 70px #151f3429}.seer-chat__header[data-v-adaeb672]{color:#fff;background:linear-gradient(135deg,#141f34f5,#243f76f0),#172033;justify-content:space-between;align-items:flex-start;gap:16px;padding:22px 22px 18px;display:flex}.seer-chat__header h2[data-v-adaeb672]{letter-spacing:-.03em;margin:0;font-size:22px}.seer-chat__header p[data-v-adaeb672],.seer-chat__empty[data-v-adaeb672],.seer-chat__status[data-v-adaeb672]{color:#5f6f89;margin:4px 0 0;font-size:14px}.seer-chat__header p[data-v-adaeb672]{color:#ffffffb8;max-width:34ch}.seer-chat__messages[data-v-adaeb672]{align-content:start;gap:12px;min-height:330px;max-height:470px;padding:18px 18px 4px;display:grid;overflow-y:auto}.seer-chat__empty[data-v-adaeb672]{color:#66748a;text-align:center;background:#ffffff9e;border:1px dashed #7f8faa61;border-radius:22px;place-items:center;min-height:260px;padding:0 28px;display:grid}.seer-chat__message[data-v-adaeb672]{background:#ffffffe0;border:1px solid #7f8faa29;border-radius:18px 18px 18px 6px;gap:6px;max-width:min(86%,520px);padding:13px 15px;display:grid;box-shadow:0 12px 28px #151f3414}.seer-chat__message--user[data-v-adaeb672]{color:#fff;background:linear-gradient(135deg,#285cff,#1d45c9);border-color:#0000;border-radius:18px 18px 6px;justify-self:end;box-shadow:0 14px 30px #1f5eff3d}.seer-chat__role[data-v-adaeb672]{opacity:.75;font-size:12px;font-weight:700}.seer-chat__body[data-v-adaeb672]{flex-direction:column;display:flex}.seer-chat__line[data-v-adaeb672]{white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.seer-chat__line[data-v-adaeb672]:not(:last-child){margin-bottom:5px}.seer-chat__line[data-v-adaeb672]:empty{height:7px}.seer-chat__strong[data-v-adaeb672]{font-weight:700}.seer-chat__price[data-v-adaeb672]{color:#e0331d;font-weight:600}.seer-chat__message--user .seer-chat__price[data-v-adaeb672]{color:#ffe2dc}.seer-chat__link[data-v-adaeb672]{color:#1f5eff;text-underline-offset:2px;overflow-wrap:anywhere;font-weight:600;text-decoration:underline}.seer-chat__link[data-v-adaeb672]:hover{color:#173fb3}.seer-chat__message--user .seer-chat__link[data-v-adaeb672]{color:#fff}.seer-chat__image-button[data-v-adaeb672]{cursor:zoom-in;background:0 0;border:0;padding:0;display:block}.seer-chat__image-button[data-v-adaeb672]:not(:disabled):hover{transform:none}.seer-chat__image[data-v-adaeb672]{border:1px solid #7f8faa38;border-radius:12px;max-width:100%;margin:6px 0;transition:filter .16s;display:block}.seer-chat__image-button:hover .seer-chat__image[data-v-adaeb672]{filter:brightness(.96)}.seer-chat__lightbox[data-v-adaeb672]{z-index:1000;cursor:zoom-out;background:#0a0f1ad1;place-items:center;padding:32px;animation:.14s seer-chat__fade-in-adaeb672;display:grid;position:fixed;inset:0}.seer-chat__lightbox-image[data-v-adaeb672]{object-fit:contain;border-radius:12px;max-width:min(92vw,1200px);max-height:90vh;box-shadow:0 30px 80px #00000080}.seer-chat__lightbox-close[data-v-adaeb672]{color:#fff;background:#ffffff24;border-radius:50%;place-items:center;width:40px;height:40px;font-size:26px;line-height:1;display:grid;position:fixed;top:18px;right:22px}.seer-chat__lightbox-close[data-v-adaeb672]:not(:disabled):hover{background:#ffffff3d}@keyframes seer-chat__fade-in-adaeb672{0%{opacity:0}to{opacity:1}}.seer-chat__error[data-v-adaeb672],.seer-chat__handoff[data-v-adaeb672]{border-radius:14px;margin:0 18px;padding:10px 12px}.seer-chat__error[data-v-adaeb672]{color:#8a1f11;background:#fff0ed}.seer-chat__handoff[data-v-adaeb672]{color:#704600;background:#fff7db}.seer-chat__form[data-v-adaeb672]{background:#fff;border:1px solid #7f8faa42;border-radius:22px;gap:11px;margin:0 18px 18px;padding:14px;display:grid;box-shadow:0 18px 38px #151f3417}.seer-chat__label[data-v-adaeb672]{font-size:13px;font-weight:700}.seer-chat textarea[data-v-adaeb672]{box-sizing:border-box;width:100%;min-height:92px;color:inherit;resize:vertical;background:#f8fafd;border:1px solid #0000;border-radius:16px;outline:none;padding:14px;line-height:1.55;transition:background .16s,border-color .16s,box-shadow .16s}.seer-chat button[data-v-adaeb672]{color:inherit;cursor:pointer;border:0;font-weight:700;transition:transform .16s,box-shadow .16s,opacity .16s}.seer-chat button[data-v-adaeb672]:not(:disabled):hover{transform:translateY(-1px)}.seer-chat button[data-v-adaeb672]:disabled{cursor:not-allowed;opacity:.5}.seer-chat button[data-v-adaeb672]:focus-visible,.seer-chat textarea[data-v-adaeb672]:focus-visible{border-color:#1f5eff6b;box-shadow:0 0 0 4px #1f5eff21}.seer-chat__clear-button[data-v-adaeb672]{color:#ffffffc7;background:0 0;border-radius:12px;flex:none;padding:8px 11px;font-size:12px;border:1px solid #ffffff2e!important}.seer-chat__clear-button[data-v-adaeb672]:not(:disabled):hover{color:#fff;box-shadow:none;background:#ffffff1a}.seer-chat__stop-button[data-v-adaeb672]{color:#6c3b12;background:#fff1df;border-radius:12px;padding:8px 11px;font-size:12px}.seer-chat__mic-button[data-v-adaeb672],.seer-chat__attach-button[data-v-adaeb672]{color:#285cff;background:#edf2ff;border-radius:50%;flex:none;place-items:center;width:40px;height:40px;padding:0;display:grid}.seer-chat__mic-button[data-v-adaeb672]:not(:disabled):hover,.seer-chat__attach-button[data-v-adaeb672]:not(:disabled):hover{background:#dfe8ff}.seer-chat__file-input[data-v-adaeb672]{display:none}.seer-chat__attachments[data-v-adaeb672]{flex-wrap:wrap;gap:6px;margin:0 0 8px;padding:0;list-style:none;display:flex}.seer-chat__attachment[data-v-adaeb672]{color:#1f2a44;background:#edf2ff;border-radius:999px;align-items:center;gap:4px;max-width:100%;padding:4px 6px 4px 10px;font-size:13px;display:inline-flex}.seer-chat__attachment-name[data-v-adaeb672]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.seer-chat__attachment-remove[data-v-adaeb672]{color:#4b5878;background:0 0;border-radius:50%;width:20px;height:20px;padding:0;line-height:1}.seer-chat__attachment-remove[data-v-adaeb672]:hover{background:#dfe8ff}.seer-chat__mic-button--recording[data-v-adaeb672]{color:#fff;background:#d9342b;animation:1.4s ease-in-out infinite seer-chat__recording-pulse-adaeb672;box-shadow:0 0 0 5px #d9342b24}.seer-chat__mic-button--recording[data-v-adaeb672]:not(:disabled):hover{background:#bd271f}.seer-chat__stop-icon[data-v-adaeb672]{background:currentColor;border-radius:3px;width:12px;height:12px}@keyframes seer-chat__recording-pulse-adaeb672{50%{box-shadow:0 0 0 9px #d9342b14}}.seer-chat__send-button[data-v-adaeb672]{color:#fff;background:linear-gradient(135deg,#1f5eff,#173fb3);border-radius:14px;justify-content:center;align-items:center;gap:8px;min-width:86px;padding:10px 14px;display:inline-flex;box-shadow:0 12px 24px #1f5eff38}.seer-chat__send-button[data-v-adaeb672]:not(:disabled):hover{box-shadow:0 14px 28px #1f5eff47}.seer-chat__hint[data-v-adaeb672]{color:#7a879a;margin-right:auto;font-size:12px}.seer-chat__composer-footer[data-v-adaeb672]{justify-content:flex-end;align-items:center;gap:8px;display:flex}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { createSeerClient } from './client';
|
|
2
|
+
export { linkAnchorLabel, toContentLines, toContentSegments, type ContentOptions, type ContentSegment, } from './content';
|
|
2
3
|
export { SeerChatPlugin } from './plugin';
|
|
3
4
|
export { useSeerChat } from './useSeerChat';
|
|
4
5
|
export { default as SeerChat } from './components/SeerChat.vue';
|
|
5
|
-
export type { SeerChatCallbacks, SeerChatMessage, SeerChatRequest, SeerChatResult, SeerChatRole, SeerClient, SeerClientOptions, } from './client';
|
|
6
|
+
export type { SeerChatCallbacks, SeerChatMessage, SeerChatRequest, SeerChatResult, SeerChatRole, SeerClient, SeerClientOptions, SeerTranscriptionCallbacks, SeerTranscriptionResult, SeerUploadedFile, } from './client';
|
|
6
7
|
export type { SeerChatPluginOptions } from './plugin';
|
|
7
8
|
export type { UseSeerChatOptions } from './useSeerChat';
|
package/dist/index.js
CHANGED
|
@@ -1,269 +1,634 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, hasInjectionContext as o, inject as s, normalizeClass as c, onBeforeUnmount as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, unref as m, vModelText as h, withDirectives as g, withKeys as _, withModifiers as v } from "vue";
|
|
2
|
+
// src/client.ts
|
|
3
|
+
function y(e) {
|
|
4
|
+
let t = e.fetcher ?? fetch, n = e.model ?? "seer", r = x(e.endpoint, e.transcriptionEndpoint, "/v1/browser/audio/transcriptions"), i = x(e.endpoint, e.uploadEndpoint, "/v1/browser/files"), a = e.now ?? (() => Math.floor(Date.now() / 1e3)), o, s = 0, c;
|
|
5
|
+
return {
|
|
6
|
+
transcriptionEnabled: !!r,
|
|
7
|
+
uploadEnabled: !!i,
|
|
8
|
+
async chat(r, i = {}) {
|
|
9
|
+
let a = r.stream ?? !1, o = await l(), s = { "Content-Type": "application/json" };
|
|
10
|
+
o && (s.Authorization = `Bearer ${o}`);
|
|
11
|
+
let c = await t(e.endpoint, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: s,
|
|
14
|
+
signal: i.signal,
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
model: r.model ?? n,
|
|
17
|
+
messages: r.messages,
|
|
18
|
+
stream: a,
|
|
19
|
+
conversation_id: r.conversationId,
|
|
20
|
+
metadata: r.metadata,
|
|
21
|
+
...r.attachments?.length ? { attachments: r.attachments } : {}
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
if (!c.ok) throw Error(await T(c));
|
|
25
|
+
return a ? C(c, i.onDelta) : S(await c.json());
|
|
26
|
+
},
|
|
27
|
+
async transcribe(e, n, i = {}) {
|
|
28
|
+
if (!r) throw Error("Seer audio transcription endpoint is not configured");
|
|
29
|
+
let a = await l(), o = {};
|
|
30
|
+
a && (o.Authorization = `Bearer ${a}`);
|
|
31
|
+
let s = new FormData();
|
|
32
|
+
s.append("file", e, n);
|
|
33
|
+
let c = await t(r, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: o,
|
|
36
|
+
signal: i.signal,
|
|
37
|
+
body: s
|
|
38
|
+
});
|
|
39
|
+
if (!c.ok) throw Error(await T(c));
|
|
40
|
+
let u = await c.json(), d = typeof u.text == "string" ? u.text.trim() : "";
|
|
41
|
+
if (!d) throw Error("Seer audio transcription returned empty text");
|
|
42
|
+
return { text: d };
|
|
43
|
+
},
|
|
44
|
+
async upload(e, n, r = {}) {
|
|
45
|
+
if (!i) throw Error("Seer file upload endpoint is not configured");
|
|
46
|
+
let a = await l(), o = {};
|
|
47
|
+
a && (o.Authorization = `Bearer ${a}`);
|
|
48
|
+
let s = new FormData();
|
|
49
|
+
s.append("file", e, n);
|
|
50
|
+
let c = await t(i, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: o,
|
|
53
|
+
signal: r.signal,
|
|
54
|
+
body: s
|
|
55
|
+
});
|
|
56
|
+
if (!c.ok) throw Error(await T(c));
|
|
57
|
+
let u = await c.json();
|
|
58
|
+
if (!u.file_id) throw Error("Seer file upload returned no file_id");
|
|
59
|
+
return {
|
|
60
|
+
fileId: u.file_id,
|
|
61
|
+
filename: u.filename ?? n,
|
|
62
|
+
kind: u.kind ?? "document",
|
|
63
|
+
contentType: u.content_type ?? "",
|
|
64
|
+
size: u.size ?? e.size
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
async function l() {
|
|
69
|
+
if (!e.sessionEndpoint) return;
|
|
70
|
+
let n = a(), r = b(e.orgOwner);
|
|
71
|
+
if (o && c === r && s - 30 > n) return o;
|
|
72
|
+
let i = await t(e.sessionEndpoint, {
|
|
73
|
+
method: "GET",
|
|
74
|
+
headers: await u(r)
|
|
75
|
+
});
|
|
76
|
+
if (!i.ok) throw Error(await T(i));
|
|
77
|
+
let l = await i.json();
|
|
78
|
+
return o = l.token, s = l.expires_at, c = r, o;
|
|
79
|
+
}
|
|
80
|
+
async function u(t) {
|
|
81
|
+
let n = {};
|
|
82
|
+
return e.challengeTokenProvider && (n["X-Seer-Challenge-Token"] = await e.challengeTokenProvider()), t && (n["X-Seer-Org-Owner"] = t), n;
|
|
83
|
+
}
|
|
28
84
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
const t = (e = n.choices) == null ? void 0 : e[0];
|
|
32
|
-
return {
|
|
33
|
-
content: ((s = t == null ? void 0 : t.message) == null ? void 0 : s.content) ?? ((i = t == null ? void 0 : t.delta) == null ? void 0 : i.content) ?? "",
|
|
34
|
-
conversationId: n.conversation_id,
|
|
35
|
-
citations: n.citations ?? [],
|
|
36
|
-
handoffRequested: n.handoff_requested ?? !1,
|
|
37
|
-
finishReason: t == null ? void 0 : t.finish_reason
|
|
38
|
-
};
|
|
85
|
+
function b(e) {
|
|
86
|
+
return (typeof e == "function" ? e() : e)?.trim() || void 0;
|
|
39
87
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return E({});
|
|
44
|
-
const e = n.body.getReader(), s = new TextDecoder();
|
|
45
|
-
let i = "", r = "", c, a = [], o = !1, m;
|
|
46
|
-
for (; ; ) {
|
|
47
|
-
const { done: x, value: O } = await e.read();
|
|
48
|
-
if (x)
|
|
49
|
-
break;
|
|
50
|
-
i += s.decode(O, { stream: !0 });
|
|
51
|
-
const k = i.split(`
|
|
52
|
-
|
|
53
|
-
`);
|
|
54
|
-
i = k.pop() ?? "";
|
|
55
|
-
for (const I of k) {
|
|
56
|
-
const w = J(I);
|
|
57
|
-
if (!w || w === "[DONE]")
|
|
58
|
-
continue;
|
|
59
|
-
const p = JSON.parse(w), l = (y = p.choices) == null ? void 0 : y[0], _ = ((v = l == null ? void 0 : l.delta) == null ? void 0 : v.content) ?? ((C = l == null ? void 0 : l.message) == null ? void 0 : C.content) ?? "";
|
|
60
|
-
_ && (r += _, t == null || t(_)), c = p.conversation_id ?? c, a = p.citations ?? a, o = p.handoff_requested ?? o, m = (l == null ? void 0 : l.finish_reason) ?? m;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
content: r,
|
|
65
|
-
conversationId: c,
|
|
66
|
-
citations: a,
|
|
67
|
-
handoffRequested: o,
|
|
68
|
-
finishReason: m
|
|
69
|
-
};
|
|
88
|
+
function x(e, t, n) {
|
|
89
|
+
if (t !== void 0) return t || void 0;
|
|
90
|
+
if (e.endsWith("/v1/browser/chat/completions")) return `${e.slice(0, -28)}${n}`;
|
|
70
91
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
function S(e) {
|
|
93
|
+
let t = e.choices?.[0];
|
|
94
|
+
return {
|
|
95
|
+
content: t?.message?.content ?? t?.delta?.content ?? "",
|
|
96
|
+
conversationId: e.conversation_id,
|
|
97
|
+
citations: e.citations ?? [],
|
|
98
|
+
handoffRequested: e.handoff_requested ?? !1,
|
|
99
|
+
finishReason: t?.finish_reason
|
|
100
|
+
};
|
|
76
101
|
}
|
|
77
|
-
async function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
async function C(e, t) {
|
|
103
|
+
if (!e.body) return S({});
|
|
104
|
+
let n = e.body.getReader(), r = new TextDecoder(), i = "", a = "", o, s = [], c = !1, l, u = !1;
|
|
105
|
+
for (;;) {
|
|
106
|
+
let { done: e, value: d } = await n.read();
|
|
107
|
+
if (e) break;
|
|
108
|
+
i += r.decode(d, { stream: !0 });
|
|
109
|
+
let f = i.split("\n\n");
|
|
110
|
+
i = f.pop() ?? "";
|
|
111
|
+
for (let e of f) {
|
|
112
|
+
let n = w(e);
|
|
113
|
+
if (!n) continue;
|
|
114
|
+
if (n === "[DONE]") {
|
|
115
|
+
u = !0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
let r = JSON.parse(n), i = r.choices?.[0], d = i?.delta?.content ?? i?.message?.content ?? "";
|
|
119
|
+
d && (a += d, t?.(d)), o = r.conversation_id ?? o, s = r.citations ?? s, c = r.handoff_requested ?? c, l = i?.finish_reason ?? l;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!u) throw Error("seer chat stream ended before [DONE]");
|
|
123
|
+
return {
|
|
124
|
+
content: a,
|
|
125
|
+
conversationId: o,
|
|
126
|
+
citations: s,
|
|
127
|
+
handoffRequested: c,
|
|
128
|
+
finishReason: l
|
|
129
|
+
};
|
|
87
130
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
function z(n = {}) {
|
|
94
|
-
const e = { ...q() ? A($, void 0) : void 0, ...n };
|
|
95
|
-
if (!e.endpoint)
|
|
96
|
-
throw new Error("Seer chat endpoint is required. Pass it to app.use() or useSeerChat().");
|
|
97
|
-
const s = {
|
|
98
|
-
endpoint: e.endpoint,
|
|
99
|
-
model: e.model,
|
|
100
|
-
fetcher: e.fetcher
|
|
101
|
-
}, i = V(s), r = g([]), c = g(!1), a = g(null), o = g(), m = g([]), y = g(!1);
|
|
102
|
-
let v = null;
|
|
103
|
-
async function C(k) {
|
|
104
|
-
const I = k.trim();
|
|
105
|
-
if (!I || c.value)
|
|
106
|
-
return;
|
|
107
|
-
const w = { role: "user", content: I };
|
|
108
|
-
r.value = [...r.value, w], c.value = !0, a.value = null, v = new AbortController();
|
|
109
|
-
const p = { role: "assistant", content: "" };
|
|
110
|
-
e.stream && (r.value = [...r.value, p]);
|
|
111
|
-
try {
|
|
112
|
-
const l = await i.chat(
|
|
113
|
-
{
|
|
114
|
-
messages: r.value.filter((_) => _.content),
|
|
115
|
-
stream: e.stream ?? !1,
|
|
116
|
-
conversationId: o.value
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
signal: v.signal,
|
|
120
|
-
onDelta(_) {
|
|
121
|
-
p.content += _, r.value = [...r.value];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
e.stream || (r.value = [...r.value, { role: "assistant", content: l.content }]), o.value = l.conversationId, m.value = l.citations, y.value = l.handoffRequested;
|
|
126
|
-
} catch (l) {
|
|
127
|
-
l.name !== "AbortError" && (a.value = l instanceof Error ? l.message : String(l));
|
|
128
|
-
} finally {
|
|
129
|
-
c.value = !1, v = null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function x() {
|
|
133
|
-
r.value = [], a.value = null, o.value = void 0, m.value = [], y.value = !1;
|
|
134
|
-
}
|
|
135
|
-
function O() {
|
|
136
|
-
v == null || v.abort();
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
messages: r,
|
|
140
|
-
loading: c,
|
|
141
|
-
error: a,
|
|
142
|
-
conversationId: o,
|
|
143
|
-
citations: m,
|
|
144
|
-
handoffRequested: y,
|
|
145
|
-
send: C,
|
|
146
|
-
reset: x,
|
|
147
|
-
abort: O
|
|
148
|
-
};
|
|
131
|
+
function w(e) {
|
|
132
|
+
let t = e.split("\n").map((e) => e.trim()).filter((e) => e.startsWith("data:")).map((e) => e.slice(5).trim());
|
|
133
|
+
return t.length === 0 ? null : t.join("\n");
|
|
149
134
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
};
|
|
135
|
+
async function T(e) {
|
|
136
|
+
let t = e.statusText || "unknown error";
|
|
137
|
+
try {
|
|
138
|
+
let n = await e.json();
|
|
139
|
+
typeof n?.detail == "string" ? t = n.detail : typeof n?.error == "string" && (t = n.error);
|
|
140
|
+
} catch {
|
|
141
|
+
let n = await e.text().catch(() => "");
|
|
142
|
+
n && (t = n);
|
|
143
|
+
}
|
|
144
|
+
return `seer chat request failed with status ${e.status}: ${t}`;
|
|
145
|
+
}
|
|
146
|
+
// src/content.ts
|
|
147
|
+
var E = /https?:\/\/[^\s)\u3000-\u303f\u4e00-\u9fff\uff00-\uffef]+/g, D = /\.(png|jpe?g|gif|webp|bmp|svg)$/i, O = "链接生成中…", k = "图片加载中…", A = /* @__PURE__ */ RegExp("(单价\\s*\\d[\\d.]*\\s*[A-Za-z]+\\/(?:kg|方))|(按当前信息为您筛选出[^\\n:]*推荐方案[^\\n:]*:)|(方案PK|时效最快|价格最低)", "g");
|
|
148
|
+
function j(e) {
|
|
149
|
+
let t = [];
|
|
150
|
+
A.lastIndex = 0;
|
|
151
|
+
let n = 0, r;
|
|
152
|
+
for (; (r = A.exec(e)) !== null;) {
|
|
153
|
+
r.index > n && t.push({
|
|
154
|
+
kind: "text",
|
|
155
|
+
value: e.slice(n, r.index)
|
|
156
|
+
});
|
|
157
|
+
let i = r[0];
|
|
158
|
+
t.push(r[1] ? {
|
|
159
|
+
kind: "price",
|
|
160
|
+
value: i
|
|
161
|
+
} : {
|
|
162
|
+
kind: "strong",
|
|
163
|
+
value: i
|
|
164
|
+
}), n = r.index + i.length;
|
|
165
|
+
}
|
|
166
|
+
return n < e.length && t.push({
|
|
167
|
+
kind: "text",
|
|
168
|
+
value: e.slice(n)
|
|
169
|
+
}), t;
|
|
170
|
+
}
|
|
171
|
+
var M = /标签|箱唛|唛头|入库单|交接单|入仓单|面单|下载/;
|
|
172
|
+
function N(e, t) {
|
|
173
|
+
if (/方案|截图|报价图|效果图|示意图|图片/.test(t)) return !0;
|
|
174
|
+
if (M.test(t)) return !1;
|
|
175
|
+
let n = e.split(/[?#]/)[0];
|
|
176
|
+
return D.test(n);
|
|
177
|
+
}
|
|
178
|
+
function P(e) {
|
|
179
|
+
return /方案|报价|截图|PK/.test(e) ? "方案PK" : "图片";
|
|
180
|
+
}
|
|
181
|
+
function F(e) {
|
|
182
|
+
return /标签|箱唛/.test(e) ? "点击下载箱唛" : /入库单|交接单/.test(e) ? "点击下载入库单" : /面单/.test(e) ? "点击下载面单" : /截图|方案/.test(e) ? "点击查看方案PK" : /下载链接|labelUrl|下载/.test(e) ? "点击下载" : /链接/.test(e) ? "点击查看" : null;
|
|
183
|
+
}
|
|
184
|
+
function I(e, t = {}) {
|
|
185
|
+
let n = [];
|
|
186
|
+
E.lastIndex = 0;
|
|
187
|
+
let r = 0, i;
|
|
188
|
+
for (; (i = E.exec(e)) !== null;) {
|
|
189
|
+
let a = i[0], o = i.index, s = e.lastIndexOf("\n", o - 1) + 1, c = e.slice(s, o), l = N(a, c), u = !t.complete && o + a.length === e.length;
|
|
190
|
+
if (o > r) {
|
|
191
|
+
let t = e.slice(r, o);
|
|
192
|
+
l && (t = t.replace(/链接([::])\s*$/, "$1")), n.push(...j(t));
|
|
193
|
+
}
|
|
194
|
+
u ? n.push({
|
|
195
|
+
kind: "text",
|
|
196
|
+
value: l ? k : O
|
|
197
|
+
}) : l ? n.push({
|
|
198
|
+
kind: "image",
|
|
199
|
+
href: a,
|
|
200
|
+
alt: P(c)
|
|
201
|
+
}) : n.push({
|
|
202
|
+
kind: "link",
|
|
203
|
+
href: a,
|
|
204
|
+
label: F(c) ?? a
|
|
205
|
+
}), r = o + a.length;
|
|
206
|
+
}
|
|
207
|
+
return r < e.length && n.push(...j(e.slice(r))), n;
|
|
208
|
+
}
|
|
209
|
+
function L(e, t = {}) {
|
|
210
|
+
let n = e.split("\n");
|
|
211
|
+
return n.map((e, r) => I(e, { complete: t.complete || r < n.length - 1 }));
|
|
212
|
+
}
|
|
213
|
+
// src/plugin.ts
|
|
214
|
+
var R = Symbol("seer-chat-options"), z = { install(e, t) {
|
|
215
|
+
e.provide(R, t);
|
|
216
|
+
} };
|
|
217
|
+
// src/useSeerChat.ts
|
|
218
|
+
function B(e = {}) {
|
|
219
|
+
let t = o() ? s(R, void 0) : void 0, n = Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0)), r = {
|
|
220
|
+
...t,
|
|
221
|
+
...n
|
|
222
|
+
};
|
|
223
|
+
if (!r.endpoint) throw Error("Seer chat endpoint is required. Pass it to app.use() or useSeerChat().");
|
|
224
|
+
let i = y({
|
|
225
|
+
endpoint: r.endpoint,
|
|
226
|
+
sessionEndpoint: r.sessionEndpoint,
|
|
227
|
+
transcriptionEndpoint: r.transcriptionEndpoint,
|
|
228
|
+
uploadEndpoint: r.uploadEndpoint,
|
|
229
|
+
challengeTokenProvider: r.challengeTokenProvider,
|
|
230
|
+
orgOwner: () => b(e.orgOwner) ?? b(t?.orgOwner),
|
|
231
|
+
model: r.model,
|
|
232
|
+
fetcher: r.fetcher
|
|
233
|
+
}), a = d([]), c = d(!1), l = d(null), u = d(), f = d([]), p = d(!1), m = r.voiceEnabled !== !1 && i.transcriptionEnabled, h = r.uploadEnabled !== !1 && i.uploadEnabled, g = r.maxRecordingSeconds ?? 60, _ = d([]), v = d(!1), x = null;
|
|
234
|
+
async function S(e) {
|
|
235
|
+
v.value = !0, l.value = null;
|
|
236
|
+
try {
|
|
237
|
+
let t = await i.upload(e, e.name);
|
|
238
|
+
_.value = [..._.value, t];
|
|
239
|
+
} catch (e) {
|
|
240
|
+
l.value = e instanceof Error ? e.message : String(e);
|
|
241
|
+
} finally {
|
|
242
|
+
v.value = !1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function C(e) {
|
|
246
|
+
_.value = _.value.filter((t) => t.fileId !== e);
|
|
247
|
+
}
|
|
248
|
+
async function w(e) {
|
|
249
|
+
let t = e.trim(), n = _.value;
|
|
250
|
+
if (!t && n.length === 0 || c.value || v.value) return;
|
|
251
|
+
let o = {
|
|
252
|
+
role: "user",
|
|
253
|
+
content: [t, n.map((e) => `[附件:${e.filename}]`).join("\n")].filter(Boolean).join("\n")
|
|
254
|
+
};
|
|
255
|
+
_.value = [], a.value = [...a.value, o], c.value = !0, l.value = null, x = new AbortController();
|
|
256
|
+
let s = {
|
|
257
|
+
role: "assistant",
|
|
258
|
+
content: ""
|
|
259
|
+
};
|
|
260
|
+
r.stream && (a.value = [...a.value, s]);
|
|
261
|
+
try {
|
|
262
|
+
let e = await i.chat({
|
|
263
|
+
messages: a.value.filter((e) => e.content),
|
|
264
|
+
stream: r.stream ?? !1,
|
|
265
|
+
conversationId: u.value,
|
|
266
|
+
attachments: n.map((e) => e.fileId)
|
|
267
|
+
}, {
|
|
268
|
+
signal: x.signal,
|
|
269
|
+
onDelta(e) {
|
|
270
|
+
s.content += e, a.value = [...a.value];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
r.stream || (a.value = [...a.value, {
|
|
274
|
+
role: "assistant",
|
|
275
|
+
content: e.content
|
|
276
|
+
}]), u.value = e.conversationId, f.value = e.citations, p.value = e.handoffRequested;
|
|
277
|
+
} catch (e) {
|
|
278
|
+
e.name !== "AbortError" && (l.value = e instanceof Error ? e.message : String(e));
|
|
279
|
+
} finally {
|
|
280
|
+
c.value = !1, x = null;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function T() {
|
|
284
|
+
a.value = [], _.value = [], l.value = null, u.value = void 0, f.value = [], p.value = !1;
|
|
285
|
+
}
|
|
286
|
+
function E() {
|
|
287
|
+
x?.abort();
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
messages: a,
|
|
291
|
+
loading: c,
|
|
292
|
+
error: l,
|
|
293
|
+
conversationId: u,
|
|
294
|
+
citations: f,
|
|
295
|
+
handoffRequested: p,
|
|
296
|
+
transcriptionEnabled: m,
|
|
297
|
+
maxRecordingSeconds: g,
|
|
298
|
+
transcribe: i.transcribe,
|
|
299
|
+
uploadEnabled: h,
|
|
300
|
+
attachments: _,
|
|
301
|
+
uploading: v,
|
|
302
|
+
attach: S,
|
|
303
|
+
removeAttachment: C,
|
|
304
|
+
send: w,
|
|
305
|
+
reset: T,
|
|
306
|
+
abort: E
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
// src/components/SeerChat.vue?vue&type=script&setup=true&lang.ts
|
|
310
|
+
var ee = {
|
|
311
|
+
class: "seer-chat",
|
|
312
|
+
"aria-label": "多发货 AI 客服聊天"
|
|
313
|
+
}, te = { class: "seer-chat__header" }, ne = {
|
|
314
|
+
class: "seer-chat__messages",
|
|
315
|
+
"aria-live": "polite"
|
|
316
|
+
}, re = {
|
|
317
|
+
key: 0,
|
|
318
|
+
class: "seer-chat__empty"
|
|
319
|
+
}, V = { class: "seer-chat__role" }, H = { class: "seer-chat__body" }, U = ["href"], W = ["aria-label", "onClick"], G = ["src", "alt"], K = {
|
|
320
|
+
key: 2,
|
|
321
|
+
class: "seer-chat__strong"
|
|
322
|
+
}, q = {
|
|
323
|
+
key: 3,
|
|
324
|
+
class: "seer-chat__price"
|
|
325
|
+
}, J = { key: 4 }, Y = {
|
|
326
|
+
key: 0,
|
|
327
|
+
class: "seer-chat__status"
|
|
328
|
+
}, ie = {
|
|
329
|
+
key: 1,
|
|
330
|
+
class: "seer-chat__error",
|
|
331
|
+
role: "alert"
|
|
332
|
+
}, ae = {
|
|
333
|
+
key: 2,
|
|
334
|
+
class: "seer-chat__handoff"
|
|
335
|
+
}, oe = {
|
|
336
|
+
key: 0,
|
|
337
|
+
class: "seer-chat__attachments",
|
|
338
|
+
"aria-label": "待发送的附件"
|
|
339
|
+
}, se = { class: "seer-chat__attachment-name" }, ce = ["aria-label", "onClick"], le = [
|
|
340
|
+
"placeholder",
|
|
341
|
+
"disabled",
|
|
342
|
+
"onKeydown"
|
|
343
|
+
], ue = { class: "seer-chat__composer-footer" }, de = {
|
|
344
|
+
class: "seer-chat__hint",
|
|
345
|
+
"aria-live": "polite"
|
|
346
|
+
}, fe = ["disabled"], pe = [
|
|
347
|
+
"disabled",
|
|
348
|
+
"aria-label",
|
|
349
|
+
"title"
|
|
350
|
+
], me = {
|
|
351
|
+
key: 0,
|
|
352
|
+
class: "seer-chat__stop-icon",
|
|
353
|
+
"aria-hidden": "true"
|
|
354
|
+
}, he = {
|
|
355
|
+
key: 1,
|
|
356
|
+
viewBox: "0 0 24 24",
|
|
357
|
+
width: "20",
|
|
358
|
+
height: "20",
|
|
359
|
+
"aria-hidden": "true"
|
|
360
|
+
}, ge = ["disabled"], X = ["aria-label"], _e = ["src", "alt"], ve = ".xlsx,.xls,.csv,.png,.jpg,.jpeg,.webp,.pdf", Z = /*#__PURE__*/ ((e, t) => {
|
|
361
|
+
let n = e.__vccOpts || e;
|
|
362
|
+
for (let [e, r] of t) n[e] = r;
|
|
363
|
+
return n;
|
|
364
|
+
})(/* @__PURE__ */ a({
|
|
365
|
+
__name: "SeerChat",
|
|
366
|
+
props: {
|
|
367
|
+
endpoint: {},
|
|
368
|
+
sessionEndpoint: {},
|
|
369
|
+
transcriptionEndpoint: {},
|
|
370
|
+
uploadEndpoint: {},
|
|
371
|
+
uploadEnabled: {
|
|
372
|
+
type: Boolean,
|
|
373
|
+
default: void 0
|
|
374
|
+
},
|
|
375
|
+
orgOwner: {},
|
|
376
|
+
model: {},
|
|
377
|
+
stream: {
|
|
378
|
+
type: Boolean,
|
|
379
|
+
default: void 0
|
|
380
|
+
},
|
|
381
|
+
fetcher: {},
|
|
382
|
+
title: { default: "多发货 AI 客服" },
|
|
383
|
+
placeholder: { default: "输入你的问题,例如:美国海派怎么报价?" },
|
|
384
|
+
voiceEnabled: {
|
|
385
|
+
type: Boolean,
|
|
386
|
+
default: void 0
|
|
387
|
+
},
|
|
388
|
+
maxRecordingSeconds: {}
|
|
389
|
+
},
|
|
390
|
+
setup(a) {
|
|
391
|
+
let o = a, s = d(""), y = d(!1), b = d(!1), x = d(null), S = B({
|
|
392
|
+
endpoint: o.endpoint,
|
|
393
|
+
sessionEndpoint: o.sessionEndpoint,
|
|
394
|
+
transcriptionEndpoint: o.transcriptionEndpoint,
|
|
395
|
+
uploadEndpoint: o.uploadEndpoint,
|
|
396
|
+
uploadEnabled: o.uploadEnabled,
|
|
397
|
+
orgOwner: () => o.orgOwner,
|
|
398
|
+
model: o.model,
|
|
399
|
+
stream: o.stream,
|
|
400
|
+
fetcher: o.fetcher,
|
|
401
|
+
voiceEnabled: o.voiceEnabled,
|
|
402
|
+
maxRecordingSeconds: o.maxRecordingSeconds
|
|
403
|
+
}), C = d(null), w = t(() => (s.value.trim().length > 0 || S.attachments.value.length > 0) && !S.loading.value && !S.uploading.value && !y.value && !b.value);
|
|
404
|
+
async function T(e) {
|
|
405
|
+
let t = e.target, n = Array.from(t.files ?? []);
|
|
406
|
+
t.value = "";
|
|
407
|
+
for (let e of n) await S.attach(e);
|
|
408
|
+
}
|
|
409
|
+
let E = t(() => S.transcriptionEnabled && typeof navigator < "u" && typeof navigator.mediaDevices?.getUserMedia == "function" && typeof MediaRecorder < "u"), D = null, O = null, k = [], A, j = !1, M = d(null);
|
|
410
|
+
function N(e) {
|
|
411
|
+
e.key === "Escape" && F();
|
|
412
|
+
}
|
|
413
|
+
function P(e, t) {
|
|
414
|
+
M.value = {
|
|
415
|
+
src: e,
|
|
416
|
+
alt: t
|
|
417
|
+
}, window.addEventListener("keydown", N);
|
|
418
|
+
}
|
|
419
|
+
function F() {
|
|
420
|
+
M.value = null, window.removeEventListener("keydown", N);
|
|
421
|
+
}
|
|
422
|
+
l(() => {
|
|
423
|
+
j = !0, window.removeEventListener("keydown", N), Q(), D && D.state !== "inactive" && (D.ondataavailable = null, D.onstop = null, D.onerror = null, D.stop()), $();
|
|
424
|
+
});
|
|
425
|
+
async function I() {
|
|
426
|
+
if (!w.value) return;
|
|
427
|
+
let e = s.value;
|
|
428
|
+
s.value = "", await S.send(e);
|
|
429
|
+
}
|
|
430
|
+
async function R() {
|
|
431
|
+
y.value ? Z() : await z();
|
|
432
|
+
}
|
|
433
|
+
async function z() {
|
|
434
|
+
if (!(!E.value || b.value || S.loading.value)) {
|
|
435
|
+
x.value = null;
|
|
436
|
+
try {
|
|
437
|
+
if (O = await navigator.mediaDevices.getUserMedia({
|
|
438
|
+
audio: {
|
|
439
|
+
echoCancellation: !0,
|
|
440
|
+
noiseSuppression: !0
|
|
441
|
+
},
|
|
442
|
+
video: !1
|
|
443
|
+
}), j) {
|
|
444
|
+
$();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
let e = be();
|
|
448
|
+
D = e ? new MediaRecorder(O, {
|
|
449
|
+
mimeType: e,
|
|
450
|
+
audioBitsPerSecond: 64e3
|
|
451
|
+
}) : new MediaRecorder(O), k = [], D.ondataavailable = (e) => {
|
|
452
|
+
e.data.size > 0 && k.push(e.data);
|
|
453
|
+
}, D.onstop = () => {
|
|
454
|
+
ye(D?.mimeType || e || "audio/webm");
|
|
455
|
+
}, D.onerror = () => {
|
|
456
|
+
x.value = "录音失败,请重试或用文字输入。", y.value = !1, b.value = !1, Q(), $();
|
|
457
|
+
}, D.start(), y.value = !0, A = setTimeout(Z, Math.max(1, S.maxRecordingSeconds) * 1e3);
|
|
458
|
+
} catch (e) {
|
|
459
|
+
x.value = Se(e), $();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function Z() {
|
|
464
|
+
D && D.state !== "inactive" && (y.value = !1, b.value = !0, Q(), D.stop());
|
|
465
|
+
}
|
|
466
|
+
async function ye(e) {
|
|
467
|
+
Q(), $();
|
|
468
|
+
let t = k;
|
|
469
|
+
if (k = [], D = null, j) return;
|
|
470
|
+
let n = new Blob(t, { type: e });
|
|
471
|
+
if (n.size === 0) x.value = "没有录到声音,请重试。", b.value = !1;
|
|
472
|
+
else try {
|
|
473
|
+
let t = await S.transcribe(n, xe(e));
|
|
474
|
+
s.value = s.value.trim() ? `${s.value.trim()} ${t.text}` : t.text;
|
|
475
|
+
} catch {
|
|
476
|
+
x.value = "语音识别失败,请重试或用文字输入。";
|
|
477
|
+
} finally {
|
|
478
|
+
b.value = !1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function be() {
|
|
482
|
+
if (typeof MediaRecorder.isTypeSupported == "function") return [
|
|
483
|
+
"audio/webm;codecs=opus",
|
|
484
|
+
"audio/mp4",
|
|
485
|
+
"audio/ogg;codecs=opus",
|
|
486
|
+
"audio/webm"
|
|
487
|
+
].find((e) => MediaRecorder.isTypeSupported(e));
|
|
488
|
+
}
|
|
489
|
+
function xe(e) {
|
|
490
|
+
return `recording.${{
|
|
491
|
+
"audio/mp4": "m4a",
|
|
492
|
+
"audio/ogg": "ogg",
|
|
493
|
+
"audio/webm": "webm"
|
|
494
|
+
}[e.split(";", 1)[0].toLowerCase()] || "webm"}`;
|
|
495
|
+
}
|
|
496
|
+
function Se(e) {
|
|
497
|
+
return e instanceof DOMException && e.name === "NotAllowedError" ? "请允许浏览器使用麦克风。" : e instanceof DOMException && e.name === "NotFoundError" ? "未检测到可用的麦克风。" : "无法启动麦克风,请重试或用文字输入。";
|
|
498
|
+
}
|
|
499
|
+
function Q() {
|
|
500
|
+
A !== void 0 && (clearTimeout(A), A = void 0);
|
|
501
|
+
}
|
|
502
|
+
function $() {
|
|
503
|
+
O?.getTracks().forEach((e) => e.stop()), O = null;
|
|
504
|
+
}
|
|
505
|
+
return (t, o) => (u(), r("section", ee, [
|
|
506
|
+
i("header", te, [i("div", null, [i("h2", null, p(a.title), 1), o[4] ||= i("p", null, "可咨询渠道报价、时效、下单资料、入仓和售后问题。", -1)]), i("button", {
|
|
507
|
+
type: "button",
|
|
508
|
+
class: "seer-chat__clear-button",
|
|
509
|
+
onClick: o[0] ||= (e) => m(S).reset()
|
|
510
|
+
}, " 清空对话 ")]),
|
|
511
|
+
i("div", ne, [m(S).messages.value.length === 0 ? (u(), r("p", re, " 直接输入问题即可,复杂查单或赔付问题会提示转人工。 ")) : n("", !0), (u(!0), r(e, null, f(m(S).messages.value, (t, n) => (u(), r("article", {
|
|
512
|
+
key: `${t.role}-${n}`,
|
|
513
|
+
class: c(["seer-chat__message", `seer-chat__message--${t.role}`])
|
|
514
|
+
}, [i("span", V, p(t.role === "user" ? "你" : "AI 客服"), 1), i("div", H, [(u(!0), r(e, null, f(m(L)(t.content, { complete: !(m(S).loading.value && n === m(S).messages.value.length - 1) }), (t, n) => (u(), r("p", {
|
|
515
|
+
key: n,
|
|
516
|
+
class: "seer-chat__line"
|
|
517
|
+
}, [(u(!0), r(e, null, f(t, (t, n) => (u(), r(e, { key: n }, [t.kind === "link" ? (u(), r("a", {
|
|
518
|
+
key: 0,
|
|
519
|
+
class: "seer-chat__link",
|
|
520
|
+
href: t.href,
|
|
521
|
+
target: "_blank",
|
|
522
|
+
rel: "noopener noreferrer"
|
|
523
|
+
}, p(t.label), 9, U)) : t.kind === "image" ? (u(), r("button", {
|
|
524
|
+
key: 1,
|
|
525
|
+
type: "button",
|
|
526
|
+
class: "seer-chat__image-button",
|
|
527
|
+
"aria-label": `放大查看${t.alt}`,
|
|
528
|
+
onClick: (e) => P(t.href, t.alt)
|
|
529
|
+
}, [i("img", {
|
|
530
|
+
class: "seer-chat__image",
|
|
531
|
+
src: t.href,
|
|
532
|
+
alt: t.alt,
|
|
533
|
+
loading: "lazy"
|
|
534
|
+
}, null, 8, G)], 8, W)) : t.kind === "strong" ? (u(), r("strong", K, p(t.value), 1)) : t.kind === "price" ? (u(), r("span", q, p(t.value), 1)) : (u(), r("span", J, p(t.value), 1))], 64))), 128))]))), 128))])], 2))), 128))]),
|
|
535
|
+
m(S).loading.value ? (u(), r("p", Y, "正在回复...")) : n("", !0),
|
|
536
|
+
m(S).error.value || x.value ? (u(), r("p", ie, p(x.value || m(S).error.value), 1)) : n("", !0),
|
|
537
|
+
m(S).handoffRequested.value ? (u(), r("p", ae, " 建议转人工:请留下联系方式或等待客服接入。 ")) : n("", !0),
|
|
538
|
+
i("form", {
|
|
539
|
+
class: "seer-chat__form",
|
|
540
|
+
onSubmit: v(I, ["prevent"])
|
|
541
|
+
}, [
|
|
542
|
+
o[8] ||= i("label", {
|
|
543
|
+
class: "seer-chat__label",
|
|
544
|
+
for: "seer-chat-input"
|
|
545
|
+
}, "问题", -1),
|
|
546
|
+
m(S).attachments.value.length > 0 ? (u(), r("ul", oe, [(u(!0), r(e, null, f(m(S).attachments.value, (e) => (u(), r("li", {
|
|
547
|
+
key: e.fileId,
|
|
548
|
+
class: "seer-chat__attachment"
|
|
549
|
+
}, [i("span", se, p(e.filename), 1), i("button", {
|
|
550
|
+
type: "button",
|
|
551
|
+
class: "seer-chat__attachment-remove",
|
|
552
|
+
"aria-label": `移除附件${e.filename}`,
|
|
553
|
+
onClick: (t) => m(S).removeAttachment(e.fileId)
|
|
554
|
+
}, " × ", 8, ce)]))), 128))])) : n("", !0),
|
|
555
|
+
g(i("textarea", {
|
|
556
|
+
id: "seer-chat-input",
|
|
557
|
+
"onUpdate:modelValue": o[1] ||= (e) => s.value = e,
|
|
558
|
+
placeholder: a.placeholder,
|
|
559
|
+
disabled: m(S).loading.value || b.value,
|
|
560
|
+
rows: "3",
|
|
561
|
+
onKeydown: _(v(I, ["exact", "prevent"]), ["enter"])
|
|
562
|
+
}, null, 40, le), [[h, s.value]]),
|
|
563
|
+
i("div", ue, [
|
|
564
|
+
i("span", de, p(y.value ? `正在录音,最长 ${m(S).maxRecordingSeconds} 秒` : b.value ? "正在识别语音..." : m(S).uploading.value ? "正在上传附件..." : "Enter 发送 · Shift+Enter 换行"), 1),
|
|
565
|
+
m(S).uploadEnabled ? (u(), r(e, { key: 0 }, [i("input", {
|
|
566
|
+
ref_key: "fileInput",
|
|
567
|
+
ref: C,
|
|
568
|
+
class: "seer-chat__file-input",
|
|
569
|
+
type: "file",
|
|
570
|
+
multiple: "",
|
|
571
|
+
accept: ve,
|
|
572
|
+
onChange: T
|
|
573
|
+
}, null, 544), i("button", {
|
|
574
|
+
type: "button",
|
|
575
|
+
class: "seer-chat__attach-button",
|
|
576
|
+
disabled: m(S).loading.value || m(S).uploading.value,
|
|
577
|
+
"aria-label": "上传附件",
|
|
578
|
+
title: "上传下单模板、实物图片等",
|
|
579
|
+
onClick: o[2] ||= (e) => C.value?.click()
|
|
580
|
+
}, [...o[5] ||= [i("svg", {
|
|
581
|
+
viewBox: "0 0 24 24",
|
|
582
|
+
width: "20",
|
|
583
|
+
height: "20",
|
|
584
|
+
"aria-hidden": "true"
|
|
585
|
+
}, [i("path", {
|
|
586
|
+
fill: "currentColor",
|
|
587
|
+
d: "M16.5 6.5v10a4.5 4.5 0 0 1-9 0V5a3 3 0 0 1 6 0v10.5a1.5 1.5 0 0 1-3 0V6.5H9v9a3 3 0 0 0 6 0V5a4.5 4.5 0 0 0-9 0v11.5a6 6 0 0 0 12 0v-10h-1.5Z"
|
|
588
|
+
})], -1)]], 8, fe)], 64)) : n("", !0),
|
|
589
|
+
E.value ? (u(), r("button", {
|
|
590
|
+
key: 1,
|
|
591
|
+
type: "button",
|
|
592
|
+
class: c(["seer-chat__mic-button", { "seer-chat__mic-button--recording": y.value }]),
|
|
593
|
+
disabled: b.value || m(S).loading.value && !y.value,
|
|
594
|
+
"aria-label": y.value ? "停止录音" : "开始语音输入",
|
|
595
|
+
title: y.value ? "停止录音" : "语音输入",
|
|
596
|
+
onClick: R
|
|
597
|
+
}, [y.value ? (u(), r("span", me)) : (u(), r("svg", he, [...o[6] ||= [i("path", {
|
|
598
|
+
fill: "currentColor",
|
|
599
|
+
d: "M12 14a3 3 0 0 0 3-3V5a3 3 0 1 0-6 0v6a3 3 0 0 0 3 3Zm5-3a1 1 0 1 1 2 0 7 7 0 0 1-6 6.93V20h3a1 1 0 1 1 0 2H8a1 1 0 1 1 0-2h3v-2.07A7 7 0 0 1 5 11a1 1 0 1 1 2 0 5 5 0 0 0 10 0Z"
|
|
600
|
+
}, null, -1)]]))], 10, pe)) : n("", !0),
|
|
601
|
+
m(S).loading.value ? (u(), r("button", {
|
|
602
|
+
key: 2,
|
|
603
|
+
type: "button",
|
|
604
|
+
class: "seer-chat__stop-button",
|
|
605
|
+
onClick: o[3] ||= (e) => m(S).abort()
|
|
606
|
+
}, " 停止 ")) : n("", !0),
|
|
607
|
+
i("button", {
|
|
608
|
+
class: "seer-chat__send-button",
|
|
609
|
+
type: "submit",
|
|
610
|
+
disabled: !w.value
|
|
611
|
+
}, [...o[7] ||= [i("span", null, "发送", -1), i("span", { "aria-hidden": "true" }, "↵", -1)]], 8, ge)
|
|
612
|
+
])
|
|
613
|
+
], 32),
|
|
614
|
+
M.value ? (u(), r("div", {
|
|
615
|
+
key: 3,
|
|
616
|
+
class: "seer-chat__lightbox",
|
|
617
|
+
role: "dialog",
|
|
618
|
+
"aria-modal": "true",
|
|
619
|
+
"aria-label": M.value.alt,
|
|
620
|
+
onClick: F
|
|
621
|
+
}, [i("button", {
|
|
622
|
+
type: "button",
|
|
623
|
+
class: "seer-chat__lightbox-close",
|
|
624
|
+
"aria-label": "关闭",
|
|
625
|
+
onClick: F
|
|
626
|
+
}, " × "), i("img", {
|
|
627
|
+
class: "seer-chat__lightbox-image",
|
|
628
|
+
src: M.value.src,
|
|
629
|
+
alt: M.value.alt
|
|
630
|
+
}, null, 8, _e)], 8, X)) : n("", !0)
|
|
631
|
+
]));
|
|
632
|
+
}
|
|
633
|
+
}), [["__scopeId", "data-v-adaeb672"]]);
|
|
634
|
+
export { Z as SeerChat, z as SeerChatPlugin, y as createSeerClient, F as linkAnchorLabel, L as toContentLines, I as toContentSegments, B as useSeerChat };
|
package/dist/plugin.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type { App, InjectionKey } from 'vue';
|
|
|
2
2
|
import type { SeerClientOptions } from './client';
|
|
3
3
|
export interface SeerChatPluginOptions extends SeerClientOptions {
|
|
4
4
|
stream?: boolean;
|
|
5
|
+
voiceEnabled?: boolean;
|
|
6
|
+
maxRecordingSeconds?: number;
|
|
7
|
+
/** 显示附件按钮(下单模板、实物图片等);默认跟随 uploadEndpoint 是否可用。 */
|
|
8
|
+
uploadEnabled?: boolean;
|
|
5
9
|
}
|
|
6
10
|
export declare const seerChatOptionsKey: InjectionKey<SeerChatPluginOptions>;
|
|
7
11
|
export declare const SeerChatPlugin: {
|
package/dist/useSeerChat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SeerChatMessage } from './client';
|
|
1
|
+
import { type SeerChatMessage, type SeerUploadedFile } from './client';
|
|
2
2
|
import { type SeerChatPluginOptions } from './plugin';
|
|
3
3
|
export interface UseSeerChatOptions extends Partial<SeerChatPluginOptions> {
|
|
4
4
|
endpoint?: string;
|
|
@@ -18,6 +18,26 @@ export declare function useSeerChat(localOptions?: UseSeerChatOptions): {
|
|
|
18
18
|
conversationId: import("vue").Ref<string | undefined, string | undefined>;
|
|
19
19
|
citations: import("vue").Ref<string[], string[]>;
|
|
20
20
|
handoffRequested: import("vue").Ref<boolean, boolean>;
|
|
21
|
+
transcriptionEnabled: boolean;
|
|
22
|
+
maxRecordingSeconds: number;
|
|
23
|
+
transcribe: (audio: Blob, filename: string, callbacks?: import("./client").SeerTranscriptionCallbacks) => Promise<import("./client").SeerTranscriptionResult>;
|
|
24
|
+
uploadEnabled: boolean;
|
|
25
|
+
attachments: import("vue").Ref<{
|
|
26
|
+
fileId: string;
|
|
27
|
+
filename: string;
|
|
28
|
+
kind: "spreadsheet" | "image" | "document" | string;
|
|
29
|
+
contentType: string;
|
|
30
|
+
size: number;
|
|
31
|
+
}[], SeerUploadedFile[] | {
|
|
32
|
+
fileId: string;
|
|
33
|
+
filename: string;
|
|
34
|
+
kind: "spreadsheet" | "image" | "document" | string;
|
|
35
|
+
contentType: string;
|
|
36
|
+
size: number;
|
|
37
|
+
}[]>;
|
|
38
|
+
uploading: import("vue").Ref<boolean, boolean>;
|
|
39
|
+
attach: (file: File) => Promise<void>;
|
|
40
|
+
removeAttachment: (fileId: string) => void;
|
|
21
41
|
send: (content: string) => Promise<void>;
|
|
22
42
|
reset: () => void;
|
|
23
43
|
abort: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seer-ai/seer-vue",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.11",
|
|
4
4
|
"description": "Vue chat plugin for the seer OpenAI-compatible API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,19 +22,26 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "vitest run",
|
|
24
24
|
"typecheck": "vue-tsc --noEmit",
|
|
25
|
-
"build": "vite build && vue-tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --outDir dist"
|
|
25
|
+
"build": "vite build && vue-tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --outDir dist",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"vue": "^3.5.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@vitejs/plugin-vue": "^
|
|
32
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
32
33
|
"@vue/test-utils": "^2.4.10",
|
|
33
|
-
"happy-dom": "^
|
|
34
|
+
"happy-dom": "^21.0.4",
|
|
34
35
|
"typescript": "^6.0.3",
|
|
35
|
-
"vite": "^
|
|
36
|
-
"vitest": "^
|
|
37
|
-
"vue": "^3.5.
|
|
36
|
+
"vite": "^8.1.3",
|
|
37
|
+
"vitest": "^5.0.5",
|
|
38
|
+
"vue": "^3.5.44",
|
|
38
39
|
"vue-tsc": "^3.3.2"
|
|
40
|
+
},
|
|
41
|
+
"overrides": {
|
|
42
|
+
"js-beautify": {
|
|
43
|
+
"glob": "^14.0.2",
|
|
44
|
+
"minimatch": "^11.0.1"
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
}
|