Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/Service/RecordingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\TaskProcessing\IManager as ITaskProcessingManager;
use OCP\TaskProcessing\Task;
use OCP\TaskProcessing\TaskTypes\AudioToText;
use OCP\TaskProcessing\TaskTypes\TextToText;
use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -455,15 +456,24 @@ public function storeTranscript(string $owner, string $roomToken, int $recording
return;
}

$customSummarizePrompt = $this->serverConfig->getAppValue('spreed', 'call_recording_summary_prompt', '');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$customSummarizePrompt = $this->serverConfig->getAppValue('spreed', 'call_recording_summary_prompt', '');
$customSummarizePrompt = $this->appConfig->getAppValueString('call_recording_summary_prompt');

And can we should add it to the ConfigLexicon class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickvergessen

I just pushed new changes. As you suggested - I used ConfigLexicon and appConfig instead of serverConfig.

What is more, you said to assign default value to call_recording_summary_prompt. I did that and I kept Time and Place section for now , but we can edit that out if you wish. I changed h2. formatting to markdown ## formatting. I also changed some instruction for sections (there are now translated to soruce text/meeting language, they were not earlier).

Assigning a default value to call_recording_summary_prompt changes the behaviour implemented earlier:

if call_recording_summary_prompt is set - use TextToText task type
else use TextToTextSummary task type

that no longer exists. Changes introduced in this PR means that TextToText task type will be always used. It means that the whole input for LLM call_recording_summary_prompt (default or set by admin) + transcript have to fit in model context. FYI: one of my 1h45m meeting was equal to ~21k tokens

if ($customSummarizePrompt !== '') {
$taskType = TextToText::ID;
$input = $customSummarizePrompt . "\n" . $output;
} else {
$taskType = TextToTextSummary::ID;
$input = $output;
}

$supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds();
if (!in_array(TextToTextSummary::ID, $supportedTaskTypeIds, true)) {
$this->logger->error('Can not summarize call recording as no TextToTextSummary task provider is available');
if (!in_array($taskType, $supportedTaskTypeIds, true)) {
$this->logger->error('Can not summarize call recording as no ' . $taskType . ' task provider is available');
return;
}

$task = new Task(
TextToTextSummary::ID,
['input' => $output],
$taskType,
['input' => $input],
Application::APP_ID,
$owner,
'call/summary/' . $room->getToken() . '/' . $recordingFileId,
Expand Down
58 changes: 58 additions & 0 deletions tests/php/Service/RecordingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ function is_uploaded_file($filename) {
use OCP\Share\IShare;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\TaskProcessing\IManager as ITaskProcessingManager;
use OCP\TaskProcessing\Task;
use OCP\TaskProcessing\TaskTypes\TextToText;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -405,4 +407,60 @@ public function testFinishUploadInvalidFormat(): void {
$this->expectExceptionMessage('file_mimetype');
$this->recordingService->finishUpload($room, $owner, 'name.ogg');
}

public function testStoreTranscriptWithCustomPrompt(): void {
$owner = 'user1';
$roomToken = 'token123';
$recordingFileId = 42;
$output = 'This is the transcript contents.';
$aiTask = 'transcript';
$customPrompt = 'Summarize this transcript:';

$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')->with($owner)->willReturn($userFolder);
$recordingFolder = $this->createMock(Folder::class);
$recordingFolder->method('getName')->willReturn($roomToken);
$recording = $this->createMock(File::class);
$recording->method('getName')->willReturn('recording.ogg');
$recording->method('getParent')->willReturn($recordingFolder);
$userFolder->method('getById')->with($recordingFileId)->willReturn([$recording]);

$room = $this->createRoom($roomToken);
$participant = $this->createParticipant($room, $owner);
$this->roomManager->method('getRoomForUserByToken')->with($roomToken, $owner)->willReturn($room);
$this->participantService->method('getParticipant')->with($room, $owner)->willReturn($participant);

$this->serverConfig->method('getAppValue')
->willReturnCallback(
function (string $app, string $key, string $default = '') use ($customPrompt): string {
if ($key === 'call_recording_summary_prompt') {
return $customPrompt;
}

return $default;
}
);

$this->taskProcessingManager->method('getAvailableTaskTypeIds')->willReturn([TextToText::ID]);
$this->taskProcessingManager->expects($this->once())->method('scheduleTask')
->with($this->callback(
function (Task $task) use ($customPrompt, $output): bool {
if ($task->getTaskTypeId() !== TextToText::ID) {
return false;
}

return $task->getInput() === [
'input' => $customPrompt . "\n" . $output,
];
}
));

$this->recordingService->storeTranscript(
$owner,
$roomToken,
$recordingFileId,
$output,
$aiTask,
);
}
}
Loading