@gis_victory/ai-chat 1.0.0 → 1.0.1
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
CHANGED
|
@@ -5,7 +5,7 @@ Vue 3 AI 聊天面板组件,支持流式对话、历史记录管理、多技
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install
|
|
8
|
+
npm install @gis_victory/ai-chat
|
|
9
9
|
npm install tdesign-vue-next @tdesign-vue-next/chat
|
|
10
10
|
```
|
|
11
11
|
|
|
@@ -19,6 +19,7 @@ npm install tdesign-vue-next @tdesign-vue-next/chat
|
|
|
19
19
|
v-model:open="isOpen"
|
|
20
20
|
mode="popup"
|
|
21
21
|
:skills="skills"
|
|
22
|
+
:base-url="baseURL"
|
|
22
23
|
:on-send="handleSend"
|
|
23
24
|
/>
|
|
24
25
|
</template>
|
|
@@ -41,6 +42,8 @@ const skills = ref([
|
|
|
41
42
|
{ id: 'image', label: '图像生成', icon: '🎨' }
|
|
42
43
|
])
|
|
43
44
|
|
|
45
|
+
const baseURL = 'https://api.example.com/AiServer/Chat'
|
|
46
|
+
|
|
44
47
|
const handleSend = async (message, skill, conversationId) => {
|
|
45
48
|
// 调用你的 AI 接口
|
|
46
49
|
const response = await fetch('your-api-endpoint', {
|
|
@@ -104,7 +107,7 @@ const handleSend = async (message, skill, conversationId) => {
|
|
|
104
107
|
| `persistent` | `boolean` | `true` | 是否持久化对话记录到 localStorage |
|
|
105
108
|
| `storageKey` | `string` | `'ai-chat-panel'` | localStorage 存储键 |
|
|
106
109
|
| `maxHistory` | `number` | `50` | 最大历史对话数量 |
|
|
107
|
-
| `baseURL` | `string` | - | API 基础 URL |
|
|
110
|
+
| `baseURL` | `string` | - | **必需** - API 基础 URL(如 `https://api.example.com/AiServer/Chat`) |
|
|
108
111
|
| `token` | `string` | - | 认证 token |
|
|
109
112
|
| `appId` | `string` | - | 应用 ID |
|
|
110
113
|
|
|
@@ -18153,22 +18153,6 @@ async function generateWord(data) {
|
|
|
18153
18153
|
console.log("[WordGenerator] Done! Blob size:", blob.size, "bytes");
|
|
18154
18154
|
return blob;
|
|
18155
18155
|
}
|
|
18156
|
-
const Server_BaseUrl = "https://www.gisx.work/gismap-server";
|
|
18157
|
-
const __vite_import_meta_env__ = {};
|
|
18158
|
-
const getApiBase = () => {
|
|
18159
|
-
var _a;
|
|
18160
|
-
if (typeof window !== "undefined" && ((_a = window.GisVictoryAiChart) == null ? void 0 : _a.apiBase)) {
|
|
18161
|
-
return window.GisVictoryAiChart.apiBase;
|
|
18162
|
-
}
|
|
18163
|
-
if (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_API_BASE) {
|
|
18164
|
-
return void 0;
|
|
18165
|
-
}
|
|
18166
|
-
return `${Server_BaseUrl}/AiServer/Chat`;
|
|
18167
|
-
};
|
|
18168
|
-
const apiConfig = {
|
|
18169
|
-
/** Chat API 基础路径(不含具体子路径) */
|
|
18170
|
-
apiBase: getApiBase()
|
|
18171
|
-
};
|
|
18172
18156
|
const _hoisted_1 = {
|
|
18173
18157
|
key: 0,
|
|
18174
18158
|
class: "fab-icon",
|
|
@@ -18551,9 +18535,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18551
18535
|
abortController = new AbortController();
|
|
18552
18536
|
let baseURL = "";
|
|
18553
18537
|
if (currentSkill.value === "enterprise_profile") {
|
|
18554
|
-
baseURL =
|
|
18538
|
+
baseURL = props.baseURL + "/NoStream";
|
|
18555
18539
|
} else {
|
|
18556
|
-
baseURL = props.baseURL
|
|
18540
|
+
baseURL = props.baseURL + "/Sse";
|
|
18557
18541
|
}
|
|
18558
18542
|
if (!baseURL) {
|
|
18559
18543
|
loadingMsg.content = "未配置 API 地址,请设置 baseURL 参数";
|
|
@@ -18770,7 +18754,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18770
18754
|
conv.messages.push(loadingMsg);
|
|
18771
18755
|
conv.updatedAt = Date.now();
|
|
18772
18756
|
abortController = new AbortController();
|
|
18773
|
-
const baseURL =
|
|
18757
|
+
const baseURL = props.baseURL + "/NoStream";
|
|
18774
18758
|
const headers = { "Content-Type": "application/json" };
|
|
18775
18759
|
const token = props.token;
|
|
18776
18760
|
if (token) headers["Authorization"] = token;
|
|
@@ -18913,7 +18897,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18913
18897
|
async function callDeleteChatLogs(sessionIds) {
|
|
18914
18898
|
if (sessionIds.length === 0) return;
|
|
18915
18899
|
try {
|
|
18916
|
-
const base = props.baseURL
|
|
18900
|
+
const base = props.baseURL + "/Sse";
|
|
18917
18901
|
const idx = base.lastIndexOf("/");
|
|
18918
18902
|
const deleteUrl = base.substring(0, idx) + "/deleteChatLogs";
|
|
18919
18903
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -18965,7 +18949,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18965
18949
|
return `${date.getMonth() + 1}月${date.getDate()}日 ${hh}:${mm}`;
|
|
18966
18950
|
}
|
|
18967
18951
|
function getChatApiBase() {
|
|
18968
|
-
const baseURL =
|
|
18952
|
+
const baseURL = props.baseURL + "/Sse";
|
|
18969
18953
|
return baseURL.substring(0, baseURL.lastIndexOf("/"));
|
|
18970
18954
|
}
|
|
18971
18955
|
async function fetchChatLogs(sessionId) {
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gis_victory/ai-chat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "AI Chat Panel component for Vue 3",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"module": "./dist/
|
|
6
|
+
"main": "./dist/ai-chat.mjs",
|
|
7
|
+
"module": "./dist/ai-chat.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"private": false,
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"import": "./dist/
|
|
12
|
+
"import": "./dist/ai-chat.mjs",
|
|
13
13
|
"types": "./dist/index.d.ts"
|
|
14
14
|
},
|
|
15
|
-
"./style.css": "./dist/
|
|
15
|
+
"./style.css": "./dist/ai-chat.css"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
File without changes
|