mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
feat(server): find transcript actions (#11890)
This commit is contained in:
@@ -54,6 +54,9 @@ class TranscriptionResultType implements TranscriptionPayload {
|
||||
@Field(() => String, { nullable: true })
|
||||
summary!: string | null;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
actions!: string | null;
|
||||
|
||||
@Field(() => [TranscriptionItemType], { nullable: true })
|
||||
transcription!: TranscriptionItemType[] | null;
|
||||
|
||||
@@ -84,11 +87,13 @@ export class CopilotTranscriptionResolver {
|
||||
status,
|
||||
title: null,
|
||||
summary: null,
|
||||
actions: null,
|
||||
transcription: null,
|
||||
};
|
||||
if (FinishedStatus.has(finalJob.status)) {
|
||||
finalJob.title = ret?.title || null;
|
||||
finalJob.summary = ret?.summary || null;
|
||||
finalJob.actions = ret?.actions || null;
|
||||
finalJob.transcription = ret?.transcription || null;
|
||||
}
|
||||
return finalJob;
|
||||
|
||||
@@ -283,7 +283,7 @@ export class CopilotTranscriptionService {
|
||||
.trim();
|
||||
|
||||
if (content.length) {
|
||||
payload.summary = await this.chatWithPrompt('Summary', {
|
||||
payload.summary = await this.chatWithPrompt('Summarize the meeting', {
|
||||
content,
|
||||
});
|
||||
await this.models.copilotJob.update(jobId, {
|
||||
@@ -328,7 +328,7 @@ export class CopilotTranscriptionService {
|
||||
await this.models.copilotJob.update(jobId, {
|
||||
payload,
|
||||
});
|
||||
this.event.emit('workspace.file.transcript.finished', {
|
||||
await this.job.add('copilot.transcript.findAction.submit', {
|
||||
jobId,
|
||||
});
|
||||
return;
|
||||
@@ -346,6 +346,32 @@ export class CopilotTranscriptionService {
|
||||
}
|
||||
}
|
||||
|
||||
@OnJob('copilot.transcript.findAction.submit')
|
||||
async transcriptFindAction({
|
||||
jobId,
|
||||
}: Jobs['copilot.transcript.findAction.submit']) {
|
||||
try {
|
||||
const payload = await this.models.copilotJob.getPayload(
|
||||
jobId,
|
||||
TranscriptPayloadSchema
|
||||
);
|
||||
if (payload.summary) {
|
||||
const actions = await this.chatWithPrompt('Find action for summary', {
|
||||
content: payload.summary,
|
||||
}).then(a => a.trim());
|
||||
if (actions) {
|
||||
payload.actions = actions;
|
||||
await this.models.copilotJob.update(jobId, {
|
||||
payload,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch {} // finish even if failed
|
||||
this.event.emit('workspace.file.transcript.finished', {
|
||||
jobId,
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent('workspace.file.transcript.finished')
|
||||
async onFileTranscriptFinish({
|
||||
jobId,
|
||||
|
||||
@@ -33,6 +33,7 @@ export const TranscriptPayloadSchema = z.object({
|
||||
infos: AudioBlobInfosSchema.nullable().optional(),
|
||||
title: z.string().nullable().optional(),
|
||||
summary: z.string().nullable().optional(),
|
||||
actions: z.string().nullable().optional(),
|
||||
transcription: TranscriptionSchema.nullable().optional(),
|
||||
});
|
||||
|
||||
@@ -66,6 +67,9 @@ declare global {
|
||||
'copilot.transcript.title.submit': {
|
||||
jobId: string;
|
||||
};
|
||||
'copilot.transcript.findAction.submit': {
|
||||
jobId: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user