@blueking/chat-helper 0.0.12-beta.2 → 0.0.12-beta.20

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
@@ -324,6 +324,17 @@ http.message; // Message API
324
324
 
325
325
  一般情况下,您不需要直接使用 `http` 模块,因为 `agent`、`session` 和 `message` 模块已经封装了常用的业务逻辑。
326
326
 
327
+ **`http.message.getMessages`(可单独使用)**:
328
+
329
+ ```typescript
330
+ // (sessionCode: string, limit?: number, config?: IRequestConfig, fuzzy?: string) => Promise<IMessage[]>
331
+ // GET session_content/content/ — 支持可选 fuzzy 模糊检索
332
+ const messages = await http.message.getMessages(sessionCode);
333
+ const filtered = await http.message.getMessages(sessionCode, undefined, undefined, '关键词');
334
+ ```
335
+
336
+ > 业务层 `message.getMessages(sessionCode)` 未透传 `fuzzy`。需要模糊检索时请直接调用 `http.message.getMessages`。`fuzzy` 位于参数末尾,不影响既有 `limit` / `config` 调用。
337
+
327
338
  ## 配置选项
328
339
 
329
340
  ### requestData(必需)
@@ -416,7 +427,6 @@ useChatHelper({
416
427
  **拦截器使用场景**:
417
428
 
418
429
  1. **请求拦截器**:
419
-
420
430
  - 添加认证 token
421
431
  - 添加请求时间戳
422
432
  - 添加请求 ID
@@ -994,8 +1004,8 @@ class SafeProtocol extends AGUIProtocol {
994
1004
  mode.value === 'creative'
995
1005
  ? 'chat_completion_creative/'
996
1006
  : mode.value === 'precise'
997
- ? 'chat_completion_precise/'
998
- : undefined;
1007
+ ? 'chat_completion_precise/'
1008
+ : undefined;
999
1009
 
1000
1010
  // 自定义请求参数
1001
1011
  agent.chat(userInput.value, session.current.sessionCode, endpoint, {
@@ -1555,13 +1565,11 @@ interface IToolMessage {
1555
1565
  **参数:**
1556
1566
 
1557
1567
  - `options.requestData` (必需)
1558
-
1559
1568
  - `urlPrefix: string` - API 基础路径
1560
1569
  - `data?: Record<string, unknown> | (() => Record<string, unknown>)` - 额外的请求数据
1561
1570
  - `headers?: Record<string, string> | (() => Record<string, string>)` - 额外的请求头
1562
1571
 
1563
1572
  - `options.interceptors` (可选)
1564
-
1565
1573
  - `request?: (config: IRequestConfig) => IRequestConfig` - 请求拦截器
1566
1574
  - `response?: (response: IResponse) => IResponse` - 响应拦截器
1567
1575
 
@@ -1885,13 +1893,19 @@ A: 使用 `agent.chat` 的 `url` 和 `config` 参数:
1885
1893
  // 使用不同的端点
1886
1894
  agent.chat(userInput, sessionCode, 'custom_chat/');
1887
1895
 
1888
- // 添加自定义参数
1896
+ // 添加自定义请求参数(如 temperature)
1889
1897
  agent.chat(userInput, sessionCode, undefined, {
1890
1898
  data: {
1891
1899
  temperature: 0.8,
1892
- model: 'gpt-4',
1893
1900
  },
1894
1901
  });
1902
+
1903
+ // 模型热切换:传入第 6 个参数 model(值为 llm_code,需在 GET llms/ 列表内)
1904
+ agent.chat(userInput, sessionCode, undefined, undefined, property, 'hy3-preview');
1905
+
1906
+ // 拉取可用模型列表
1907
+ const llmList = await agent.getLlms({ llm_type: 'chat.completion' });
1908
+ // agent.models 同步更新
1895
1909
  ```
1896
1910
 
1897
1911
  ### Q: 消息列表如何实现自动滚动到底部?
@@ -126,3 +126,72 @@ export interface IAgentResources {
126
126
  mcp?: IAgentResourceItem[];
127
127
  tool?: IAgentResourceItem[];
128
128
  }
129
+ /** 模型能力属性(后端 property 字段) */
130
+ export interface ILlmProperty {
131
+ agent_type?: string;
132
+ default?: boolean;
133
+ is_self_host?: boolean;
134
+ max_model_len?: number;
135
+ support_summary?: boolean;
136
+ support_thinking?: boolean;
137
+ support_thinking_quick?: boolean;
138
+ support_tools?: boolean;
139
+ support_vision?: boolean;
140
+ support_window?: boolean;
141
+ }
142
+ /** 可用模型列表查询参数 */
143
+ export interface ILlmListQuery {
144
+ /** 模糊搜索关键词,按 llm_name / description / base_model 匹配 */
145
+ fuzzy?: string;
146
+ /** 模型类型,不传时默认 chat.completion */
147
+ llm_type?: string;
148
+ /** 按模型支持的功能过滤,逗号分隔,如 tool_call,vision */
149
+ supports?: string;
150
+ }
151
+ /**
152
+ * 可用模型项(对齐 plugin_api/llms/ 与 chat-x IModelOption)
153
+ * 字段以 snake_case 与后端保持一致,便于直接透传给 ModelSelector
154
+ */
155
+ export interface ILlmItem {
156
+ /** 基础模型标识,如 hunyuan */
157
+ base_model?: string;
158
+ /** 模型描述 */
159
+ description?: string;
160
+ /** 是否禁用(前端扩展字段) */
161
+ disabled?: boolean;
162
+ /** 模型图标地址 */
163
+ icon?: string;
164
+ /** 模型主键 id */
165
+ id: number;
166
+ /** 模型编码(chat_completion 热切换传此值) */
167
+ llm_code: string;
168
+ /** 模型展示名(ModelSelector v-model 选中值) */
169
+ llm_name: string;
170
+ /** 模型类型,如 chat.completion */
171
+ llm_type: string;
172
+ /** 最大 token 数 */
173
+ max_token_size: number;
174
+ /** 模型能力属性 */
175
+ property: ILlmProperty;
176
+ /** 空间维度鉴权模式 */
177
+ space_auth_mode: string;
178
+ /** 标签名列表 */
179
+ tag_names?: string[];
180
+ /** 用户维度鉴权模式 */
181
+ user_auth_mode: string;
182
+ }
183
+ /** 后端 llms/ 原始响应项(字段可能缺省) */
184
+ export interface ILlmItemApi {
185
+ base_model?: string;
186
+ description?: string;
187
+ icon?: string;
188
+ id?: number;
189
+ llm_code: string;
190
+ llm_name: string;
191
+ llm_type?: string;
192
+ max_token_size?: number;
193
+ property?: ILlmProperty | null;
194
+ space_auth_mode?: string;
195
+ tag_names?: string[];
196
+ user_auth_mode?: string;
197
+ }
@@ -22,4 +22,4 @@
22
22
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
23
  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
24
  * IN THE SOFTWARE.
25
- */ /** @deprecated 后端已改为扁平列表 IAgentResourceItem[],不再使用分组结构 */ export { };
25
+ */ /** 后端 llms/ 原始响应项(字段可能缺省) */ export { };