@zero-library/chat-copilot 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/dist/index.d.mts CHANGED
@@ -87,6 +87,7 @@ interface UserInputType {
87
87
  * @returns 聊天服务对象
88
88
  */
89
89
  declare const createChatService: (request: ReturnType<typeof createRequest>, config?: RequestConfig) => {
90
+ fetchModelList: () => Promise<R<ProviderModel[]>>;
90
91
  fetchAgentInfo: (agentId: string) => Promise<R<AgentInfo>>;
91
92
  createConversationId: (params: ConversationCreate) => Promise<R<string>>;
92
93
  fetchConversations: (params: ConversationsQuery) => Promise<R<ConversationType[]>>;
@@ -1323,6 +1324,23 @@ interface ChatProps {
1323
1324
  layout?: ChatLayout;
1324
1325
  services?: ChatServices;
1325
1326
  }
1327
+ interface Model {
1328
+ modelName: string;
1329
+ modelLabel: string;
1330
+ desc: string | null;
1331
+ tags: readonly string[] | null;
1332
+ providerId: string;
1333
+ providerName: string;
1334
+ providerLabel?: string;
1335
+ icon: string;
1336
+ }
1337
+ interface ProviderModel {
1338
+ providerName: string;
1339
+ providerLabel: string;
1340
+ iconUrl: string;
1341
+ icon?: string;
1342
+ models: Model[];
1343
+ }
1326
1344
 
1327
1345
  /**
1328
1346
  * 附件组件属性接口
package/dist/index.d.ts CHANGED
@@ -87,6 +87,7 @@ interface UserInputType {
87
87
  * @returns 聊天服务对象
88
88
  */
89
89
  declare const createChatService: (request: ReturnType<typeof createRequest>, config?: RequestConfig) => {
90
+ fetchModelList: () => Promise<R<ProviderModel[]>>;
90
91
  fetchAgentInfo: (agentId: string) => Promise<R<AgentInfo>>;
91
92
  createConversationId: (params: ConversationCreate) => Promise<R<string>>;
92
93
  fetchConversations: (params: ConversationsQuery) => Promise<R<ConversationType[]>>;
@@ -1323,6 +1324,23 @@ interface ChatProps {
1323
1324
  layout?: ChatLayout;
1324
1325
  services?: ChatServices;
1325
1326
  }
1327
+ interface Model {
1328
+ modelName: string;
1329
+ modelLabel: string;
1330
+ desc: string | null;
1331
+ tags: readonly string[] | null;
1332
+ providerId: string;
1333
+ providerName: string;
1334
+ providerLabel?: string;
1335
+ icon: string;
1336
+ }
1337
+ interface ProviderModel {
1338
+ providerName: string;
1339
+ providerLabel: string;
1340
+ iconUrl: string;
1341
+ icon?: string;
1342
+ models: Model[];
1343
+ }
1326
1344
 
1327
1345
  /**
1328
1346
  * 附件组件属性接口
package/dist/index.esm.js CHANGED
@@ -3094,6 +3094,9 @@ var BubbleListItems_default = ({
3094
3094
 
3095
3095
  // src/services/index.ts
3096
3096
  var createChatService = (request, config) => {
3097
+ const fetchModelList = () => {
3098
+ return request.get(`/providers/models/type/llm`);
3099
+ };
3097
3100
  const fetchAgentInfo = (agentId) => {
3098
3101
  return request.get(`/agents/${agentId}`);
3099
3102
  };
@@ -3137,6 +3140,7 @@ var createChatService = (request, config) => {
3137
3140
  return `${config?.baseURL}/agents/${agentId}/${conversationId}/files/download?path=${encodeURIComponent(path)}&${TOKEN_KEY}=${tokenManager.get()}`;
3138
3141
  };
3139
3142
  return {
3143
+ fetchModelList,
3140
3144
  fetchAgentInfo,
3141
3145
  createConversationId,
3142
3146
  fetchConversations,
@@ -3154,8 +3158,8 @@ var createChatService = (request, config) => {
3154
3158
 
3155
3159
  // src/stores/index.ts
3156
3160
  var defaultLayout = {
3157
- globalHeader: true,
3158
- conversationList: true,
3161
+ globalHeader: false,
3162
+ conversationList: false,
3159
3163
  preview: true,
3160
3164
  chatHeader: true,
3161
3165
  messageList: true,
@@ -3172,6 +3176,8 @@ function createChatStore() {
3172
3176
  /** HTTP请求实例 */
3173
3177
  request: {}
3174
3178
  },
3179
+ models: [],
3180
+ /** 钩子函数 */
3175
3181
  hooks: {},
3176
3182
  layout: {},
3177
3183
  loading: false,
@@ -3188,8 +3194,19 @@ function createChatStore() {
3188
3194
  }
3189
3195
  }
3190
3196
  });
3197
+ const getModels = async () => {
3198
+ const { data } = await config.services.request.fetchModelList();
3199
+ config.models = data;
3200
+ if (data?.length) {
3201
+ setAgentModel({
3202
+ providerName: data[0].providerName,
3203
+ modelName: data[0].models[0].modelName,
3204
+ reasoning: true
3205
+ });
3206
+ }
3207
+ };
3191
3208
  const setServices = ({ http, websocket } = {}) => {
3192
- const httpConfig = { baseURL: "/luya/api", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
3209
+ const httpConfig = { baseURL: "/luya/v1", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
3193
3210
  const request = createRequest(httpConfig);
3194
3211
  if (config.hooks?.onRequestInterceptor) {
3195
3212
  request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
@@ -3254,8 +3271,8 @@ function createChatStore() {
3254
3271
  /** 当前智能体 */
3255
3272
  agentInfo: {},
3256
3273
  model: {
3257
- modelName: "qwen3.5-plus",
3258
- providerName: "\u9AD8\u5C71\u4E91\u57FA",
3274
+ modelName: "",
3275
+ providerName: "",
3259
3276
  reasoning: true
3260
3277
  },
3261
3278
  /** 智能体加载状态 */
@@ -3973,6 +3990,8 @@ function createChatStore() {
3973
3990
  conversation.messages[conversation.active.id].loading = false;
3974
3991
  };
3975
3992
  return {
3993
+ /** 获取模型列表 */
3994
+ getModels,
3976
3995
  /** 全局配置对象 */
3977
3996
  config,
3978
3997
  /** 设置服务配置 */
@@ -4775,6 +4794,9 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
4775
4794
  useDeepEffect(() => {
4776
4795
  chatStore.setServices(services);
4777
4796
  }, [services]);
4797
+ useEffect(() => {
4798
+ chatStore.getModels();
4799
+ }, []);
4778
4800
  useDeepEffect(() => {
4779
4801
  if (agentState.agentInfo.id && isObject(config.agent?.spec)) {
4780
4802
  chatStore.setAgent({ ...agentState.agentInfo, spec: config.agent.spec || {} });