Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lobehub/lobe-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 25, 2024
2 parents 4b9f98b + d1d0350 commit 4882f3c
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 90 deletions.
75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,81 @@

# Changelog

### [Version 1.12.19](https://github.com/lobehub/lobe-chat/compare/v1.12.18...v1.12.19)

<sup>Released on **2024-08-25**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix cannot clone agent when imported from client.

<br/>

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

#### What's fixed

- **misc**: Fix cannot clone agent when imported from client, closes [#3606](https://github.com/lobehub/lobe-chat/issues/3606) ([1fd2fa0](https://github.com/lobehub/lobe-chat/commit/1fd2fa0))

</details>

<div align="right">

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

</div>

### [Version 1.12.18](https://github.com/lobehub/lobe-chat/compare/v1.12.17...v1.12.18)

<sup>Released on **2024-08-25**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix dayjs error in en-US language.

<br/>

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

#### What's fixed

- **misc**: Fix dayjs error in en-US language, closes [#3604](https://github.com/lobehub/lobe-chat/issues/3604) ([174f4df](https://github.com/lobehub/lobe-chat/commit/174f4df))

</details>

<div align="right">

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

</div>

### [Version 1.12.17](https://github.com/lobehub/lobe-chat/compare/v1.12.16...v1.12.17)

<sup>Released on **2024-08-25**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix multi file upload dupicate.

<br/>

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

#### What's fixed

- **misc**: Fix multi file upload dupicate, closes [#3603](https://github.com/lobehub/lobe-chat/issues/3603) ([60dbed7](https://github.com/lobehub/lobe-chat/commit/60dbed7))

</details>

<div align="right">

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

</div>

### [Version 1.12.16](https://github.com/lobehub/lobe-chat/compare/v1.12.15...v1.12.16)

<sup>Released on **2024-08-24**</sup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Our marketplace is not just a showcase platform but also a collaborative space.
| [Prompt Engineering Expert](https://chat-preview.lobehub.com/market?agent=ai-prompts-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | Specializing in prompt optimization and design<br/>`prompt-engineering` `ai-interaction` `writing` `optimization` `consulting` |
| [Commit Message Generator](https://chat-preview.lobehub.com/market?agent=commit-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | Expert at generating precise Git commit messages<br/>`programming` `git` `commit-message` `code-review` |

> 📊 Total agents: [<kbd>**316**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
> 📊 Total agents: [<kbd>**317**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
| [提示工程专家](https://chat-preview.lobehub.com/market?agent=ai-prompts-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | 专精 Prompt 优化与设计<br/>`提示工程` `ai交互` `写作` `优化` `咨询` |
| [提交信息生成器](https://chat-preview.lobehub.com/market?agent=commit-assistant)<br/><sup>By **[cyicz123](https://github.com/cyicz123)** on **2024-08-12**</sup> | 擅长生成精准的 Git 提交信息<br/>`编程` `git` `提交信息` `代码审查` |

> 📊 Total agents: [<kbd>**316**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
> 📊 Total agents: [<kbd>**317**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
"version": "1.12.16",
"version": "1.12.19",
"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 Expand Up @@ -124,7 +124,7 @@
"@neondatabase/serverless": "^0.9.4",
"@next/third-parties": "^14.2.6",
"@sentry/nextjs": "^7.119.0",
"@t3-oss/env-nextjs": "^0.10.1",
"@t3-oss/env-nextjs": "^0.11.0",
"@tanstack/react-query": "^5.52.1",
"@trpc/client": "next",
"@trpc/next": "next",
Expand Down Expand Up @@ -171,7 +171,7 @@
"nuqs": "^1.17.8",
"officeparser": "^4.1.1",
"ollama": "^0.5.8",
"openai": "~4.54.0",
"openai": "^4.56.0",
"partial-json": "^0.1.7",
"pdf-parse": "^1.1.1",
"pdfjs-dist": "4.4.168",
Expand Down
3 changes: 2 additions & 1 deletion src/database/server/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export class SessionModel {

if (!result) return;

const { agent, ...session } = result;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { agent, clientId, ...session } = result;
const sessionId = this.genId();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
8 changes: 4 additions & 4 deletions src/features/FileManager/FileList/EmptyStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const EmptyStatus = ({ showKnowledgeBase, knowledgeBaseId }: EmptyStatusProps) =
</Flexbox>
)}
<Upload
beforeUpload={async (_, fileList) => {
await pushDockFileList(Array.from(fileList), knowledgeBaseId);
beforeUpload={async (file) => {
await pushDockFileList([file], knowledgeBaseId);

return false;
}}
Expand All @@ -122,8 +122,8 @@ const EmptyStatus = ({ showKnowledgeBase, knowledgeBaseId }: EmptyStatusProps) =
</Flexbox>
</Upload>
<Upload
beforeUpload={async (_, fileList) => {
await pushDockFileList(Array.from(fileList), knowledgeBaseId);
beforeUpload={async (file) => {
await pushDockFileList([file], knowledgeBaseId);

return false;
}}
Expand Down
8 changes: 4 additions & 4 deletions src/features/FileManager/Header/UploadFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const UploadFileButton = ({ knowledgeBaseId }: { knowledgeBaseId?: string }) =>
key: 'upload-file',
label: (
<Upload
beforeUpload={async (_, fileList) => {
await pushDockFileList(Array.from(fileList), knowledgeBaseId);
beforeUpload={async (file) => {
await pushDockFileList([file], knowledgeBaseId);

return false;
}}
Expand All @@ -47,8 +47,8 @@ const UploadFileButton = ({ knowledgeBaseId }: { knowledgeBaseId?: string }) =>
key: 'upload-folder',
label: (
<Upload
beforeUpload={async (_, fileList) => {
await pushDockFileList(Array.from(fileList), knowledgeBaseId);
beforeUpload={async (file) => {
await pushDockFileList([file], knowledgeBaseId);

return false;
}}
Expand Down
12 changes: 11 additions & 1 deletion src/layout/GlobalProvider/Locale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ const Locale = memo<LocaleLayoutProps>(({ children, defaultLang, antdLocale }) =
if (!lang) return;

// load default lang
const dayJSLocale = await import(`dayjs/locale/${lang!.toLowerCase()}.js`);
let dayJSLocale;
try {
// dayjs locale is using `en` instead of `en-US`
// refs: https://github.com/lobehub/lobe-chat/issues/3396
const locale = lang!.toLowerCase() === 'en-us' ? 'en' : lang!.toLowerCase();

dayJSLocale = await import(`dayjs/locale/${locale}.js`);
} catch {
console.warn(`dayjs locale for ${lang} not found, fallback to en`);
dayJSLocale = await import(`dayjs/locale/en.js`);
}

dayjs.locale(dayJSLocale.default);
});
Expand Down
2 changes: 1 addition & 1 deletion src/libs/agent-runtime/groq/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('LobeGroqAI', () => {
choices: [
{
index: 0,
message: { role: 'assistant', content: 'hello' },
message: { role: 'assistant', content: 'hello', refusal: null },
logprobs: null,
finish_reason: 'stop',
},
Expand Down
4 changes: 2 additions & 2 deletions src/libs/agent-runtime/qwen/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('LobeQwenAI', () => {
});

it('should transform non-streaming response to stream correctly', async () => {
const mockResponse: OpenAI.ChatCompletion = {
const mockResponse = {
id: 'chatcmpl-fc539f49-51a8-94be-8061',
object: 'chat.completion',
created: 1719901794,
Expand All @@ -119,7 +119,7 @@ describe('LobeQwenAI', () => {
logprobs: null,
},
],
};
} as OpenAI.ChatCompletion;
vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(
mockResponse as any,
);
Expand Down
50 changes: 28 additions & 22 deletions src/libs/agent-runtime/utils/openaiCompatibleFactory/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('LobeOpenAICompatibleFactory', () => {
});

it('should transform non-streaming response to stream correctly', async () => {
const mockResponse: OpenAI.ChatCompletion = {
const mockResponse = {
id: 'a',
object: 'chat.completion',
created: 123,
Expand All @@ -360,7 +360,7 @@ describe('LobeOpenAICompatibleFactory', () => {
completion_tokens: 5,
total_tokens: 10,
},
};
} as OpenAI.ChatCompletion;
vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(
mockResponse as any,
);
Expand Down Expand Up @@ -426,27 +426,29 @@ describe('LobeOpenAICompatibleFactory', () => {
},
provider: ModelProvider.Mistral,
});

const instance = new LobeMockProvider({ apiKey: 'test' });
const mockCreateMethod = vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(new ReadableStream() as any);

const mockCreateMethod = vi
.spyOn(instance['client'].chat.completions, 'create')
.mockResolvedValue(new ReadableStream() as any);

await instance.chat(
{
messages: [{ content: 'Hello', role: 'user' }],
model: 'open-mistral-7b',
temperature: 0,
},
{ user: 'testUser' }
{ user: 'testUser' },
);

expect(mockCreateMethod).toHaveBeenCalledWith(
expect.not.objectContaining({
user: 'testUser',
}),
expect.anything()
expect.anything(),
);
});

it('should add user to payload when noUserId is false', async () => {
const LobeMockProvider = LobeOpenAICompatibleFactory({
baseURL: 'https://api.mistral.ai/v1',
Expand All @@ -455,50 +457,54 @@ describe('LobeOpenAICompatibleFactory', () => {
},
provider: ModelProvider.Mistral,
});

const instance = new LobeMockProvider({ apiKey: 'test' });
const mockCreateMethod = vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(new ReadableStream() as any);

const mockCreateMethod = vi
.spyOn(instance['client'].chat.completions, 'create')
.mockResolvedValue(new ReadableStream() as any);

await instance.chat(
{
messages: [{ content: 'Hello', role: 'user' }],
model: 'open-mistral-7b',
temperature: 0,
},
{ user: 'testUser' }
{ user: 'testUser' },
);

expect(mockCreateMethod).toHaveBeenCalledWith(
expect.objectContaining({
user: 'testUser',
}),
expect.anything()
expect.anything(),
);
});

it('should add user to payload when noUserId is not set in chatCompletion', async () => {
const LobeMockProvider = LobeOpenAICompatibleFactory({
baseURL: 'https://api.mistral.ai/v1',
provider: ModelProvider.Mistral,
});

const instance = new LobeMockProvider({ apiKey: 'test' });
const mockCreateMethod = vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(new ReadableStream() as any);

const mockCreateMethod = vi
.spyOn(instance['client'].chat.completions, 'create')
.mockResolvedValue(new ReadableStream() as any);

await instance.chat(
{
messages: [{ content: 'Hello', role: 'user' }],
model: 'open-mistral-7b',
temperature: 0,
},
{ user: 'testUser' }
{ user: 'testUser' },
);

expect(mockCreateMethod).toHaveBeenCalledWith(
expect.objectContaining({
user: 'testUser',
}),
expect.anything()
expect.anything(),
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/libs/trpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @link https://trpc.io/docs/v11/procedures
*/
import { trpc } from './init';
import { passwordChecker } from './middleware/password';
import { jwtPayloadChecker } from './middleware/jwtPayload';
import { userAuth } from './middleware/userAuth';

/**
Expand All @@ -27,7 +27,7 @@ export const publicProcedure = trpc.procedure;
export const authedProcedure = trpc.procedure.use(userAuth);

// procedure that asserts that the user add the password
export const passwordProcedure = trpc.procedure.use(passwordChecker);
export const passwordProcedure = trpc.procedure.use(jwtPayloadChecker);

/**
* Merge multiple routers together
Expand Down
Loading

0 comments on commit 4882f3c

Please sign in to comment.