mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 03:56:23 +08:00
feat(server): extract check params (#12187)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Improved input validation and error reporting for chat messages, attachments, and embeddings, with clearer error messages for invalid inputs. - Enhanced support for multimodal messages, including attachments such as images or audio. - **Refactor** - Unified and streamlined parameter validation across AI providers, resulting in more consistent behavior and error handling. - Centralized parameter checks into a common provider layer, removing duplicate validation code from individual AI providers. - **Tests** - Simplified and consolidated audio transcription test stubs for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -934,12 +934,22 @@ test('should be able to transcript', async t => {
|
||||
|
||||
const { id: workspaceId } = await createWorkspace(app);
|
||||
|
||||
Sinon.stub(app.get(GeminiProvider), 'structure').resolves(
|
||||
'[{"a":"A","s":30,"e":45,"t":"Hello, everyone."},{"a":"B","s":46,"e":70,"t":"Hi, thank you for joining the meeting today."}]'
|
||||
);
|
||||
Sinon.stub(app.get(GeminiProvider), 'text').resolves(
|
||||
'[{"a":"A","s":30,"e":45,"t":"Hello, everyone."},{"a":"B","s":46,"e":70,"t":"Hi, thank you for joining the meeting today."}]'
|
||||
);
|
||||
for (const [provider, func] of [
|
||||
[GeminiProvider, 'text'],
|
||||
[GeminiProvider, 'structure'],
|
||||
] as const) {
|
||||
Sinon.stub(app.get(provider), func).resolves(
|
||||
JSON.stringify([
|
||||
{ a: 'A', s: 30, e: 45, t: 'Hello, everyone.' },
|
||||
{
|
||||
a: 'B',
|
||||
s: 46,
|
||||
e: 70,
|
||||
t: 'Hi, thank you for joining the meeting today.',
|
||||
},
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const job = await submitAudioTranscription(app, workspaceId, '1', '1.mp3', [
|
||||
|
||||
Reference in New Issue
Block a user