@lobehub/chat 0.135.1 → 0.135.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.135.2](https://github.com/lobehub/lobe-chat/compare/v0.135.1...v0.135.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-03-14**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Upgrade plugin db schema.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Upgrade plugin db schema, closes [#1571](https://github.com/lobehub/lobe-chat/issues/1571) ([757574a](https://github.com/lobehub/lobe-chat/commit/757574a))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.135.1](https://github.com/lobehub/lobe-chat/compare/v0.135.0...v0.135.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-03-14**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.135.
|
|
3
|
+
"version": "0.135.2",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
package/src/database/core/db.ts
CHANGED
|
@@ -10,7 +10,15 @@ import { DB_User } from '@/database/schemas/user';
|
|
|
10
10
|
import { uuid } from '@/utils/uuid';
|
|
11
11
|
|
|
12
12
|
import { migrateSettingsToUser } from './migrations/migrateSettingsToUser';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
dbSchemaV1,
|
|
15
|
+
dbSchemaV2,
|
|
16
|
+
dbSchemaV3,
|
|
17
|
+
dbSchemaV4,
|
|
18
|
+
dbSchemaV5,
|
|
19
|
+
dbSchemaV6,
|
|
20
|
+
dbSchemaV7,
|
|
21
|
+
} from './schemas';
|
|
14
22
|
import { DBModel, LOBE_CHAT_LOCAL_DB_NAME } from './types/db';
|
|
15
23
|
|
|
16
24
|
interface LobeDBSchemaMap {
|
|
@@ -50,6 +58,10 @@ export class LocalDB extends Dexie {
|
|
|
50
58
|
.stores(dbSchemaV6)
|
|
51
59
|
.upgrade((trans) => this.upgradeToV6(trans));
|
|
52
60
|
|
|
61
|
+
this.version(7)
|
|
62
|
+
.stores(dbSchemaV7)
|
|
63
|
+
.upgrade((trans) => this.upgradeToV7(trans));
|
|
64
|
+
|
|
53
65
|
this.files = this.table('files');
|
|
54
66
|
this.sessions = this.table('sessions');
|
|
55
67
|
this.messages = this.table('messages');
|
|
@@ -115,6 +127,18 @@ export class LocalDB extends Dexie {
|
|
|
115
127
|
if (!user.uuid) user.uuid = uuid();
|
|
116
128
|
});
|
|
117
129
|
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 2024.03.14
|
|
133
|
+
* add `id` in plugins
|
|
134
|
+
*/
|
|
135
|
+
upgradeToV7 = async (trans: Transaction) => {
|
|
136
|
+
const plugins = trans.table('plugins');
|
|
137
|
+
|
|
138
|
+
await plugins.toCollection().modify((plugin: DB_Plugin) => {
|
|
139
|
+
plugin.id = plugin.identifier;
|
|
140
|
+
});
|
|
141
|
+
};
|
|
118
142
|
}
|
|
119
143
|
|
|
120
144
|
export const LocalDBInstance = new LocalDB();
|
|
@@ -66,3 +66,13 @@ export const dbSchemaV6 = {
|
|
|
66
66
|
'&id, role, content, fromModel, favorite, plugin.identifier, plugin.apiName, translate.content, createdAt, updatedAt, sessionId, topicId, quotaId, parentId, [sessionId+topicId], traceId',
|
|
67
67
|
users: '++id, uuid',
|
|
68
68
|
};
|
|
69
|
+
|
|
70
|
+
// ************************************** //
|
|
71
|
+
// ******* Version 7 - 2024-03-14 ******* //
|
|
72
|
+
// ************************************** //
|
|
73
|
+
// - Added id to `plugins` table
|
|
74
|
+
export const dbSchemaV7 = {
|
|
75
|
+
...dbSchemaV6,
|
|
76
|
+
plugins:
|
|
77
|
+
'&identifier, id, type, manifest.type, manifest.meta.title, manifest.meta.description, manifest.meta.author, createdAt, updatedAt',
|
|
78
|
+
};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
|
2
|
+
|
|
1
3
|
import { BaseModel } from '@/database/core';
|
|
4
|
+
import { LobeTool } from '@/types/tool';
|
|
2
5
|
import { merge } from '@/utils/merge';
|
|
3
6
|
|
|
4
7
|
import { DB_Plugin, DB_PluginSchema } from '../schemas/plugin';
|
|
5
8
|
|
|
9
|
+
export interface InstallPluginParams {
|
|
10
|
+
identifier: string;
|
|
11
|
+
manifest?: LobeChatPluginManifest;
|
|
12
|
+
type: 'plugin' | 'customPlugin';
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
class _PluginModel extends BaseModel {
|
|
7
16
|
constructor() {
|
|
8
17
|
super('plugins', DB_PluginSchema);
|
|
@@ -15,14 +24,17 @@ class _PluginModel extends BaseModel {
|
|
|
15
24
|
|
|
16
25
|
// **************** Create *************** //
|
|
17
26
|
|
|
18
|
-
create = async (plugin:
|
|
27
|
+
create = async (plugin: InstallPluginParams) => {
|
|
19
28
|
const old = await this.table.get(plugin.identifier);
|
|
29
|
+
const dbPlugin = this.mapToDBPlugin(plugin);
|
|
20
30
|
|
|
21
|
-
return this.table.put(merge(old,
|
|
31
|
+
return this.table.put(merge(old, dbPlugin), plugin.identifier);
|
|
22
32
|
};
|
|
23
33
|
|
|
24
|
-
batchCreate = async (plugins:
|
|
25
|
-
|
|
34
|
+
batchCreate = async (plugins: LobeTool[]) => {
|
|
35
|
+
const dbPlugins = plugins.map((item) => this.mapToDBPlugin(item));
|
|
36
|
+
|
|
37
|
+
return this._batchAdd(dbPlugins);
|
|
26
38
|
};
|
|
27
39
|
// **************** Delete *************** //
|
|
28
40
|
|
|
@@ -38,6 +50,12 @@ class _PluginModel extends BaseModel {
|
|
|
38
50
|
update: (id: string, value: Partial<DB_Plugin>) => Promise<number> = async (id, value) => {
|
|
39
51
|
return this.table.update(id, value);
|
|
40
52
|
};
|
|
53
|
+
|
|
54
|
+
// **************** Helper *************** //
|
|
55
|
+
|
|
56
|
+
mapToDBPlugin(plugin: LobeTool) {
|
|
57
|
+
return { ...plugin, id: plugin.identifier } as DB_Plugin;
|
|
58
|
+
}
|
|
41
59
|
}
|
|
42
60
|
|
|
43
61
|
export const PluginModel = new _PluginModel();
|