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:
darkskygit
2025-05-22 13:43:59 +00:00
parent 5035ab218d
commit 477250f1b8
8 changed files with 114 additions and 206 deletions
@@ -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', [