gimc-ai-agent 1.0.0 → 1.0.2

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
@@ -39,28 +39,22 @@ app.mount('#app')
39
39
 
40
40
  ```vue
41
41
  <template>
42
- <!-- 建议配合登录状态控制显示 -->
43
- <GimcAiAgent
42
+ <!-- 需要配合登录状态控制显示 -->
43
+ <gimc-ai-agent
44
44
  v-if="isLoggedIn"
45
- ref="agentRef"
46
45
  :rag-knowledge-id="1"
47
- :token="userToken"
48
- title="智能客服"
49
- @send="onSend"
50
- @feedback="onFeedback"
51
- @satisfaction="onSatisfaction"
46
+ :token="token"
52
47
  />
53
48
  </template>
54
49
 
55
50
  <script setup lang="ts">
56
51
  import { ref, computed } from 'vue'
57
52
  import { GimcAiAgent } from 'gimc-ai-agent'
58
- import type { FeedbackData } from 'gimc-ai-agent'
59
53
 
60
54
  const agentRef = ref()
61
55
 
62
56
  // 登录状态判断(根据实际业务修改)
63
- const userToken = computed(() => localStorage.getItem('token') || '')
57
+ const token = computed(() => localStorage.getItem('token') || '')
64
58
  const isLoggedIn = computed(() => !!userToken.value)
65
59
 
66
60
  // 事件监听
@@ -84,37 +78,16 @@ const clearMessages = () => agentRef.value?.clearMessages()
84
78
  </script>
85
79
  ```
86
80
 
87
- ## 完整安装步骤总结
88
-
89
- ```bash
90
- # 1. 安装组件和依赖
91
- npm install gimc-ai-agent element-plus @element-plus/icons-vue
92
-
93
- # 2. 在 main.ts 中配置
94
- # - 引入 ElementPlus 并 use
95
- # - 引入 'element-plus/dist/index.css'
96
- # - 引入 'gimc-ai-agent/dist/style.css'
97
-
98
- # 3. 在需要的页面中引入组件使用
99
- # import { GimcAiAgent } from 'gimc-ai-agent'
100
- ```
101
-
102
81
  ## Props
103
82
 
104
83
  | 属性 | 类型 | 默认值 | 必填 | 说明 |
105
84
  |------|------|--------|------|------|
106
85
  | `ragKnowledgeId` | `number` | - | ✅ | RAG 知识库 ID |
107
- | `token` | `string` | - | - | 外部系统传入的认证 token(优先级高于 localStorage) |
86
+ | `token` | `string` | - | | 外部系统传入的认证 token(优先级高于 localStorage) |
108
87
  | `title` | `string` | `'灵犀AI小助手'` | - | 标题 |
109
- | `avatar` | `string` | 内置图标 | - | 头像 URL |
110
- | `floatIcon` | `string` | 内置图标 | - | 悬浮按钮图标 URL |
111
- | `position` | `{ right?: number; bottom?: number }` | `{ right: 8, bottom: 24 }` | - | 位置配置(单位:px) |
112
- | `width` | `number` | `560` | - | 弹窗宽度(单位:px) |
113
88
  | `welcomeText` | `string` | `'有任何问题,随时问我~'` | - | 欢迎语 |
114
89
  | `idleTimeout` | `number` | `180000` | - | 空闲超时时间(ms) |
115
90
  | `typingSpeed` | `number` | `30` | - | 打字机速度(ms) |
116
- | `showSatisfaction` | `boolean` | `true` | - | 是否显示满意度评价 |
117
- | `showFeedback` | `boolean` | `true` | - | 是否显示反馈功能 |
118
91
 
119
92
  ## Events
120
93
 
@@ -146,44 +119,6 @@ npm install gimc-ai-agent element-plus @element-plus/icons-vue
146
119
  | `clearMessages()` | 清空消息记录 |
147
120
  | `sendMessage(content: string)` | 主动发送消息 |
148
121
 
149
- ## 类型定义
150
-
151
- ```typescript
152
- interface Message {
153
- role: 'user' | 'assistant'
154
- content: string
155
- timestamp?: string
156
- showFeedback?: boolean
157
- feedback?: 'resolved' | 'unresolved' | null
158
- suggestions?: string[]
159
- isTyping?: boolean
160
- }
161
-
162
- interface Article {
163
- title: string
164
- url: string
165
- }
166
-
167
- interface QuickAction {
168
- label: string
169
- icon?: string
170
- onClick?: () => void
171
- url?: string
172
- }
173
-
174
- interface FeedbackData {
175
- messageId: string
176
- type: string
177
- resolved: boolean
178
- detail?: string
179
- }
180
-
181
- interface Position {
182
- right?: number
183
- bottom?: number
184
- }
185
- ```
186
-
187
122
  ## 登录状态控制
188
123
 
189
124
  组件本身不包含登录校验逻辑,建议在业务系统中通过 `v-if` 控制显示:
@@ -191,14 +126,14 @@ interface Position {
191
126
  ```vue
192
127
  <template>
193
128
  <!-- 方式1:使用 Pinia store -->
194
- <GimcAiAgent
129
+ <gimc-ai-agent
195
130
  v-if="userStore.isLoggedIn"
196
131
  :rag-knowledge-id="1"
197
132
  :token="userStore.token"
198
133
  />
199
134
 
200
135
  <!-- 方式2:使用 computed token 判断 -->
201
- <GimcAiAgent
136
+ <gimc-ai-agent
202
137
  v-if="!!token"
203
138
  :rag-knowledge-id="1"
204
139
  :token="token"
@@ -224,9 +159,10 @@ const token = computed(() => localStorage.getItem('token'))
224
159
 
225
160
  ```vue
226
161
  <template>
227
- <GimcAiAgent
162
+ <gimc-ai-agent
163
+ v-if="token"
228
164
  :rag-knowledge-id="1"
229
- :token="externalToken"
165
+ :token="token"
230
166
  />
231
167
  </template>
232
168
 
@@ -264,7 +200,7 @@ localStorage.setItem('gimc-ai-agent-token', 'your-token-here')
264
200
  ## 自定义插槽示例
265
201
 
266
202
  ```vue
267
- <GimcAiAgent :rag-knowledge-id="1" :token="token">
203
+ <gimc-ai-agent v-if="token" :rag-knowledge-id="1" :token="token">
268
204
  <template #float-button>
269
205
  <div class="custom-button">
270
206
  <img src="/custom-icon.png" />
@@ -277,23 +213,9 @@ localStorage.setItem('gimc-ai-agent-token', 'your-token-here')
277
213
  <p>我可以帮你解答各种问题</p>
278
214
  </div>
279
215
  </template>
280
- </GimcAiAgent>
216
+ </gimc-ai-agent>
281
217
  ```
282
218
 
283
- ## 后端接口要求
284
-
285
- 组件会调用以下后端接口(基于配置的 API 地址):
286
-
287
- - `POST /api/rag-knowledge/answer/stream` - 流式问答接口
288
- - `GET /api/rag-knowledge/session/list` - 获取会话列表
289
- - `GET /api/rag-knowledge/session/messages` - 获取历史消息
290
- - `GET /api/rag-knowledge/questions/suggested` - 获取推荐问题
291
- - `GET /api/rag-knowledge/questions/recommended` - 获取相关问题
292
- - `POST /api/rag-knowledge/feedback` - 提交反馈
293
- - `PUT /api/rag-knowledge/feedback` - 更新反馈
294
- - `DELETE /api/rag-knowledge/feedback/{id}` - 删除反馈
295
- - `POST /api/rag-knowledge/stop` - 停止生成
296
-
297
219
  ## License
298
220
 
299
221
  MIT
@@ -61,10 +61,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
61
61
  "onSession-end"?: (() => any) | undefined;
62
62
  }>, {
63
63
  title: string;
64
- position: {
65
- right?: number;
66
- bottom?: number;
67
- };
68
64
  width: number;
69
65
  welcomeText: string;
70
66
  idleTimeout: number;