forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: refactor with new plugin implement with dexie db (lobehu…
…b#596) * ♻️ refactor: refactor with plugin dev * ✅ test: add test for chain * 🐛 fix: fix plugin display in tool * ✅ test: add test for plugin service * ✅ test: add test for plugin service * 💚 ci: fix ci
- Loading branch information
Showing
66 changed files
with
1,743 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { OpenAIChatStreamPayload } from '@/types/openai/chat'; | ||
|
||
import { chainLangDetect } from '../langDetect'; | ||
|
||
// 描述测试块 | ||
describe('chainLangDetect', () => { | ||
// 测试用例:验证函数返回的结构 | ||
it('should return a payload with the correct structure and embedded user content', () => { | ||
// 用户输入的内容 | ||
const userContent = 'Hola'; | ||
|
||
// 预期的返回值结构 | ||
const expectedPayload: Partial<OpenAIChatStreamPayload> = { | ||
messages: [ | ||
{ | ||
content: | ||
'你是一名精通全世界语言的语言专家,你需要识别用户输入的内容,以国际标准 locale 进行输出', | ||
role: 'system', | ||
}, | ||
{ | ||
content: '{你好}', | ||
role: 'user', | ||
}, | ||
{ | ||
content: 'zh-CN', | ||
role: 'assistant', | ||
}, | ||
{ | ||
content: '{hello}', | ||
role: 'user', | ||
}, | ||
{ | ||
content: 'en-US', | ||
role: 'assistant', | ||
}, | ||
{ | ||
content: `{${userContent}}`, | ||
role: 'user', | ||
}, | ||
], | ||
}; | ||
|
||
// 执行函数并获取结果 | ||
const result = chainLangDetect(userContent); | ||
|
||
// 断言结果是否符合预期 | ||
expect(result).toEqual(expectedPayload); | ||
}); | ||
}); |
Oops, something went wrong.