mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
hotfix/server: fix duplication of topics
This commit is contained in:
@@ -106,9 +106,9 @@ class Transcript(BaseModel):
|
|||||||
return ev
|
return ev
|
||||||
|
|
||||||
def upsert_topic(self, topic: TranscriptTopic):
|
def upsert_topic(self, topic: TranscriptTopic):
|
||||||
existing_topic = next((t for t in self.topics if t.id == topic.id), None)
|
index = next((i for i, t in enumerate(self.topics) if t.id == topic.id), None)
|
||||||
if existing_topic:
|
if index is not None:
|
||||||
existing_topic.update_from(topic)
|
self.topics[index] = topic
|
||||||
else:
|
else:
|
||||||
self.topics.append(topic)
|
self.topics.append(topic)
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ from reflector.processors import (
|
|||||||
TranscriptTranslatorProcessor,
|
TranscriptTranslatorProcessor,
|
||||||
)
|
)
|
||||||
from reflector.processors.types import AudioDiarizationInput
|
from reflector.processors.types import AudioDiarizationInput
|
||||||
from reflector.processors.types import TitleSummary as TitleSummaryProcessorType
|
from reflector.processors.types import (
|
||||||
|
TitleSummaryWithId as TitleSummaryWithIdProcessorType,
|
||||||
|
)
|
||||||
from reflector.processors.types import Transcript as TranscriptProcessorType
|
from reflector.processors.types import Transcript as TranscriptProcessorType
|
||||||
from reflector.settings import settings
|
from reflector.settings import settings
|
||||||
from reflector.ws_manager import WebsocketManager, get_ws_manager
|
from reflector.ws_manager import WebsocketManager, get_ws_manager
|
||||||
@@ -163,6 +165,8 @@ class PipelineMainBase(PipelineRunner):
|
|||||||
text=data.transcript.text,
|
text=data.transcript.text,
|
||||||
words=data.transcript.words,
|
words=data.transcript.words,
|
||||||
)
|
)
|
||||||
|
if isinstance(data, TitleSummaryWithIdProcessorType):
|
||||||
|
topic.id = data.id
|
||||||
async with self.transaction():
|
async with self.transaction():
|
||||||
transcript = await self.get_transcript()
|
transcript = await self.get_transcript()
|
||||||
await transcripts_controller.upsert_topic(transcript, topic)
|
await transcripts_controller.upsert_topic(transcript, topic)
|
||||||
@@ -302,7 +306,8 @@ class PipelineMainDiarization(PipelineMainBase):
|
|||||||
# XXX translation is lost when converting our data model to the processor model
|
# XXX translation is lost when converting our data model to the processor model
|
||||||
transcript = await self.get_transcript()
|
transcript = await self.get_transcript()
|
||||||
topics = [
|
topics = [
|
||||||
TitleSummaryProcessorType(
|
TitleSummaryWithIdProcessorType(
|
||||||
|
id=topic.id,
|
||||||
title=topic.title,
|
title=topic.title,
|
||||||
summary=topic.summary,
|
summary=topic.summary,
|
||||||
timestamp=topic.timestamp,
|
timestamp=topic.timestamp,
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ class TitleSummary(BaseModel):
|
|||||||
return f"{minutes:02d}:{seconds:02d}.{milliseconds:03d}"
|
return f"{minutes:02d}:{seconds:02d}.{milliseconds:03d}"
|
||||||
|
|
||||||
|
|
||||||
|
class TitleSummaryWithId(TitleSummary):
|
||||||
|
id: str
|
||||||
|
|
||||||
|
|
||||||
class FinalLongSummary(BaseModel):
|
class FinalLongSummary(BaseModel):
|
||||||
long_summary: str
|
long_summary: str
|
||||||
duration: float
|
duration: float
|
||||||
@@ -386,4 +390,4 @@ class TranslationLanguages(BaseModel):
|
|||||||
|
|
||||||
class AudioDiarizationInput(BaseModel):
|
class AudioDiarizationInput(BaseModel):
|
||||||
audio_url: str
|
audio_url: str
|
||||||
topics: list[TitleSummary]
|
topics: list[TitleSummaryWithId]
|
||||||
|
|||||||
Reference in New Issue
Block a user