mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat(server): init gemini provider & transcript action (#10731)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { ExecutionContext, TestFn } from 'ava';
|
||||
import ava from 'ava';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ConfigModule } from '../base/config';
|
||||
import { AuthService } from '../core/auth';
|
||||
@@ -269,6 +270,36 @@ test('should validate markdown list', t => {
|
||||
// ==================== action ====================
|
||||
|
||||
const actions = [
|
||||
{
|
||||
promptName: ['Transcript audio'],
|
||||
messages: [
|
||||
{
|
||||
role: 'user' as const,
|
||||
content: '',
|
||||
attachments: [
|
||||
'https://cdn.affine.pro/copilot-test/MP9qDGuYgnY+ILoEAmHpp3h9Npuw2403EAYMEA.mp3',
|
||||
],
|
||||
},
|
||||
],
|
||||
verifier: (t: ExecutionContext<Tester>, result: string) => {
|
||||
// cleanup json markdown wrap
|
||||
const cleaned = result
|
||||
.replace(/```[\w\s]+\n/g, '')
|
||||
.replace(/\n```/g, '')
|
||||
.trim();
|
||||
t.notThrows(() => {
|
||||
z.object({
|
||||
speaker: z.string(),
|
||||
start: z.string(),
|
||||
end: z.string(),
|
||||
transcription: z.string(),
|
||||
})
|
||||
.array()
|
||||
.parse(JSON.parse(cleaned));
|
||||
});
|
||||
},
|
||||
type: 'text' as const,
|
||||
},
|
||||
{
|
||||
promptName: [
|
||||
'Summary',
|
||||
@@ -401,6 +432,7 @@ const actions = [
|
||||
type: 'image' as const,
|
||||
},
|
||||
];
|
||||
|
||||
for (const { promptName, messages, verifier, type } of actions) {
|
||||
const prompts = Array.isArray(promptName) ? promptName : [promptName];
|
||||
for (const promptName of prompts) {
|
||||
|
||||
Reference in New Issue
Block a user