Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from lobehub:main #119

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Changelog

### [Version 1.36.12](https://github.com/lobehub/lobe-chat/compare/v1.36.11...v1.36.12)

<sup>Released on **2024-12-11**</sup>

#### ♻ Code Refactoring

- **misc**: Update sql and types.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Update sql and types, closes [#4979](https://github.com/lobehub/lobe-chat/issues/4979) ([8243f01](https://github.com/lobehub/lobe-chat/commit/8243f01))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.36.11](https://github.com/lobehub/lobe-chat/compare/v1.36.10...v1.36.11)

<sup>Released on **2024-12-11**</sup>
Expand Down
7 changes: 7 additions & 0 deletions changelog/v1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"children": {
"improvements": ["Update sql and types."]
},
"date": "2024-12-11",
"version": "1.36.12"
},
{
"children": {
"improvements": ["Refactor data importer to repos."]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.36.11",
"version": "1.36.12",
"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.",
"keywords": [
"framework",
Expand Down
2 changes: 1 addition & 1 deletion src/database/migrations/0006_add_knowledge_base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CREATE TABLE IF NOT EXISTS "unstructured_chunks" (
"file_id" varchar
);
--> statement-breakpoint
ALTER TABLE "files_to_messages" RENAME TO "messages_files";
ALTER TABLE "files_to_messages" RENAME TO "messages_files";--> statement-breakpoint
DROP TABLE "files_to_agents";--> statement-breakpoint
ALTER TABLE "files" ADD COLUMN "file_hash" varchar(64);--> statement-breakpoint
ALTER TABLE "files" ADD COLUMN "chunk_task_id" uuid;--> statement-breakpoint
Expand Down
4 changes: 4 additions & 0 deletions src/database/migrations/0007_fix_embedding_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ CREATE TEMP TABLE embeddings_temp AS
SELECT DISTINCT ON (chunk_id) *
FROM embeddings
ORDER BY chunk_id, random();
--> statement-breakpoint

-- step 2: delete all rows from the original table
DELETE FROM embeddings;
--> statement-breakpoint

-- step 3: insert the rows we want to keep back into the original table
INSERT INTO embeddings
SELECT * FROM embeddings_temp;
--> statement-breakpoint

-- step 4: drop the temporary table
DROP TABLE embeddings_temp;
--> statement-breakpoint

-- step 5: now it's safe to add the unique constraint
ALTER TABLE "embeddings" ADD CONSTRAINT "embeddings_chunk_id_unique" UNIQUE("chunk_id");
2 changes: 1 addition & 1 deletion src/database/server/models/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Column, count, inArray, sql } from 'drizzle-orm';
import { and, desc, eq, exists, isNull, like, or } from 'drizzle-orm/expressions';

import { LobeChatDatabase } from '@/database/type';
import { idGenerator } from '@/database/utils/idGenerator';

import { NewMessage, TopicItem, messages, topics } from '../../schemas';
import { idGenerator } from '@/database/utils/idGenerator';

export interface CreateTopicParams {
favorite?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/services/import/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ClientService {
}

if (sessionGroups.length > 0) {
const res = await SessionGroupModel.batchCreate(sessionGroups);
const res = await SessionGroupModel.batchCreate(sessionGroups as any);
sessionGroupResult = this.mapImportResult(res);
}

Expand Down
12 changes: 10 additions & 2 deletions src/types/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
MessageRoleType,
} from '@/types/message';
import { MetaData } from '@/types/meta';
import { SessionGroupId, SessionGroupItem } from '@/types/session';
import { SessionGroupId } from '@/types/session';
import { ChatTopic } from '@/types/topic';

interface ImportSession {
Expand Down Expand Up @@ -64,9 +64,17 @@ interface ImportMessage {
updatedAt: number;
}

interface ImportSessionGroup {
createdAt: number;
id: string;
name: string;
sort?: number | null;
updatedAt: number;
}

export interface ImporterEntryData {
messages?: ImportMessage[];
sessionGroups?: SessionGroupItem[];
sessionGroups?: ImportSessionGroup[];
sessions?: ImportSession[];
topics?: ChatTopic[];
version: number;
Expand Down
Loading