@lobehub/chat 1.45.2 → 1.45.4

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.
@@ -43,16 +43,16 @@ const useProviderCard = (): ProviderItem => {
43
43
  ) : (
44
44
  <Input.Password
45
45
  autoComplete={'new-password'}
46
- placeholder={t(`${providerKey}.personalAccessToken.placeholder`)}
46
+ placeholder={t(`github.personalAccessToken.placeholder`)}
47
47
  />
48
48
  ),
49
49
  desc: (
50
50
  <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
51
- {t(`${providerKey}.personalAccessToken.desc`)}
51
+ {t(`github.personalAccessToken.desc`)}
52
52
  </Markdown>
53
53
  ),
54
- label: t(`${providerKey}.personalAccessToken.title`),
55
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
54
+ label: t(`github.personalAccessToken.title`),
55
+ name: [KeyVaultsConfigKey, LLMProviderApiTokenKey],
56
56
  },
57
57
  ],
58
58
  };
@@ -43,16 +43,16 @@ const useProviderCard = (): ProviderItem => {
43
43
  ) : (
44
44
  <Input.Password
45
45
  autoComplete={'new-password'}
46
- placeholder={t(`${providerKey}.accessToken.placeholder`)}
46
+ placeholder={t(`huggingface.accessToken.placeholder`)}
47
47
  />
48
48
  ),
49
49
  desc: (
50
50
  <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
51
- {t(`${providerKey}.accessToken.desc`)}
51
+ {t(`huggingface.accessToken.desc`)}
52
52
  </Markdown>
53
53
  ),
54
- label: t(`${providerKey}.accessToken.title`),
55
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
54
+ label: t(`huggingface.accessToken.title`),
55
+ name: [KeyVaultsConfigKey, LLMProviderApiTokenKey],
56
56
  },
57
57
  ],
58
58
  };
@@ -81,13 +81,16 @@ export class AiInfraRepos {
81
81
  .map<EnabledAiModel & { enabled?: boolean | null }>((item) => {
82
82
  const user = allModels.find((m) => m.id === item.id && m.providerId === provider.id);
83
83
 
84
- const enabled = !!user ? user.enabled : item.enabled;
85
-
86
84
  return {
87
- ...item,
88
- abilities: item.abilities || {},
89
- enabled,
85
+ abilities: !!user ? user.abilities : item.abilities || {},
86
+ config: !!user ? user.config : item.config,
87
+ contextWindowTokens: !!user ? user.contextWindowTokens : item.contextWindowTokens,
88
+ displayName: user?.displayName || item.displayName,
89
+ enabled: !!user ? user.enabled : item.enabled,
90
+ id: item.id,
90
91
  providerId: provider.id,
92
+ sort: !!user ? user.sort : undefined,
93
+ type: item.type,
91
94
  };
92
95
  })
93
96
  .filter((i) => i.enabled);
@@ -248,7 +248,7 @@ describe('AiModelModel', () => {
248
248
 
249
249
  const allModels = await aiProviderModel.query();
250
250
  expect(allModels).toHaveLength(2);
251
- expect(allModels.find((m) => m.id === 'existing-model')?.displayName).toBe('Updated Name');
251
+ expect(allModels.find((m) => m.id === 'existing-model')?.displayName).toBe('Old Name');
252
252
  expect(allModels.find((m) => m.id === 'new-model')?.displayName).toBe('New Model');
253
253
  });
254
254
  });
@@ -1,5 +1,4 @@
1
1
  import { and, asc, desc, eq, inArray } from 'drizzle-orm/expressions';
2
- import pMap from 'p-map';
3
2
 
4
3
  import { LobeChatDatabase } from '@/database/type';
5
4
  import {
@@ -131,51 +130,21 @@ export class AiModelModel {
131
130
  };
132
131
 
133
132
  batchUpdateAiModels = async (providerId: string, models: AiProviderModelListItem[]) => {
134
- return this.db.transaction(async (trx) => {
135
- const records = models.map(({ id, ...model }) => ({
136
- ...model,
137
- id,
138
- providerId,
139
- updatedAt: new Date(),
140
- userId: this.userId,
141
- }));
133
+ const records = models.map(({ id, ...model }) => ({
134
+ ...model,
135
+ id,
136
+ providerId,
137
+ updatedAt: new Date(),
138
+ userId: this.userId,
139
+ }));
142
140
 
143
- // 第一步:尝试插入所有记录,忽略冲突
144
- const insertedRecords = await trx
145
- .insert(aiModels)
146
- .values(records)
147
- .onConflictDoNothing({
148
- target: [aiModels.id, aiModels.userId, aiModels.providerId],
149
- })
150
- .returning();
151
- // 第二步:找出需要更新的记录(即插入时发生冲突的记录)
152
- // 找出未能插入的记录(需要更新的记录)
153
- const insertedIds = new Set(insertedRecords.map((r) => r.id));
154
- const recordsToUpdate = records.filter((r) => !insertedIds.has(r.id));
155
-
156
- // 第三步:更新已存在的记录
157
- if (recordsToUpdate.length > 0) {
158
- await pMap(
159
- recordsToUpdate,
160
- async (record) => {
161
- await trx
162
- .update(aiModels)
163
- .set({
164
- ...record,
165
- updatedAt: new Date(),
166
- })
167
- .where(
168
- and(
169
- eq(aiModels.id, record.id),
170
- eq(aiModels.userId, this.userId),
171
- eq(aiModels.providerId, providerId),
172
- ),
173
- );
174
- },
175
- { concurrency: 10 }, // 限制并发数为 10
176
- );
177
- }
178
- });
141
+ return this.db
142
+ .insert(aiModels)
143
+ .values(records)
144
+ .onConflictDoNothing({
145
+ target: [aiModels.id, aiModels.userId, aiModels.providerId],
146
+ })
147
+ .returning();
179
148
  };
180
149
 
181
150
  batchToggleAiModels = async (providerId: string, models: string[], enabled: boolean) => {
@@ -1,4 +1,4 @@
1
- import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders';
1
+ import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels';
2
2
 
3
3
  const locales: {
4
4
  [key: string]: {
@@ -6,7 +6,7 @@ const locales: {
6
6
  };
7
7
  } = {};
8
8
 
9
- LOBE_DEFAULT_MODEL_LIST.flat().forEach((model) => {
9
+ LOBE_DEFAULT_MODEL_LIST.forEach((model) => {
10
10
  if (!model.description) return;
11
11
  locales[model.id] = {
12
12
  description: model.description,