mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
server/www: rename topic text field to transcript
This aleviate the current issue with vercel deployment
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
"""rename back text to transcript
|
||||||
|
|
||||||
|
Revision ID: 38a927dcb099
|
||||||
|
Revises: 9920ecfe2735
|
||||||
|
Create Date: 2023-11-02 19:53:09.116240
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import table, column
|
||||||
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '38a927dcb099'
|
||||||
|
down_revision: Union[str, None] = '9920ecfe2735'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# bind the engine
|
||||||
|
bind = op.get_bind()
|
||||||
|
|
||||||
|
# Reflect the table
|
||||||
|
transcript = table("transcript", column("id", sa.String), column("topics", sa.JSON))
|
||||||
|
|
||||||
|
# Select all rows from the transcript table
|
||||||
|
results = bind.execute(select([transcript.c.id, transcript.c.topics]))
|
||||||
|
|
||||||
|
for row in results:
|
||||||
|
transcript_id = row["id"]
|
||||||
|
topics_json = row["topics"]
|
||||||
|
|
||||||
|
# Process each topic in the topics JSON array
|
||||||
|
updated_topics = []
|
||||||
|
for topic in topics_json:
|
||||||
|
if "text" in topic:
|
||||||
|
# Rename key 'text' back to 'transcript'
|
||||||
|
topic["transcript"] = topic.pop("text")
|
||||||
|
updated_topics.append(topic)
|
||||||
|
|
||||||
|
# Update the transcript table
|
||||||
|
bind.execute(
|
||||||
|
transcript.update()
|
||||||
|
.where(transcript.c.id == transcript_id)
|
||||||
|
.values(topics=updated_topics)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# bind the engine
|
||||||
|
bind = op.get_bind()
|
||||||
|
|
||||||
|
# Reflect the table
|
||||||
|
transcript = table("transcript", column("id", sa.String), column("topics", sa.JSON))
|
||||||
|
|
||||||
|
# Select all rows from the transcript table
|
||||||
|
results = bind.execute(select([transcript.c.id, transcript.c.topics]))
|
||||||
|
|
||||||
|
for row in results:
|
||||||
|
transcript_id = row["id"]
|
||||||
|
topics_json = row["topics"]
|
||||||
|
|
||||||
|
# Process each topic in the topics JSON array
|
||||||
|
updated_topics = []
|
||||||
|
for topic in topics_json:
|
||||||
|
if "transcript" in topic:
|
||||||
|
# Rename key 'transcript' to 'text'
|
||||||
|
topic["text"] = topic.pop("transcript")
|
||||||
|
updated_topics.append(topic)
|
||||||
|
|
||||||
|
# Update the transcript table
|
||||||
|
bind.execute(
|
||||||
|
transcript.update()
|
||||||
|
.where(transcript.c.id == transcript_id)
|
||||||
|
.values(topics=updated_topics)
|
||||||
|
)
|
||||||
@@ -9,7 +9,6 @@ from typing import Sequence, Union
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import json
|
|
||||||
from sqlalchemy.sql import table, column
|
from sqlalchemy.sql import table, column
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class TranscriptTopic(BaseModel):
|
|||||||
summary: str
|
summary: str
|
||||||
timestamp: float
|
timestamp: float
|
||||||
duration: float | None = 0
|
duration: float | None = 0
|
||||||
text: str | None = None
|
transcript: str | None = None
|
||||||
words: list[ProcessorWord] = []
|
words: list[ProcessorWord] = []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class PipelineMainBase(PipelineRunner):
|
|||||||
title=data.title,
|
title=data.title,
|
||||||
summary=data.summary,
|
summary=data.summary,
|
||||||
timestamp=data.timestamp,
|
timestamp=data.timestamp,
|
||||||
text=data.transcript.text,
|
transcript=data.transcript.text,
|
||||||
words=data.transcript.words,
|
words=data.transcript.words,
|
||||||
)
|
)
|
||||||
if isinstance(data, TitleSummaryWithIdProcessorType):
|
if isinstance(data, TitleSummaryWithIdProcessorType):
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class GetTranscriptTopic(BaseModel):
|
|||||||
title: str
|
title: str
|
||||||
summary: str
|
summary: str
|
||||||
timestamp: float
|
timestamp: float
|
||||||
text: str
|
transcript: str
|
||||||
segments: list[GetTranscriptSegmentTopic] = []
|
segments: list[GetTranscriptSegmentTopic] = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -154,7 +154,7 @@ class GetTranscriptTopic(BaseModel):
|
|||||||
title=topic.title,
|
title=topic.title,
|
||||||
summary=topic.summary,
|
summary=topic.summary,
|
||||||
timestamp=topic.timestamp,
|
timestamp=topic.timestamp,
|
||||||
text=text,
|
transcript=text,
|
||||||
segments=segments,
|
segments=segments,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ async def test_transcript_rtc_and_websocket(
|
|||||||
ev = events[eventnames.index("TOPIC")]
|
ev = events[eventnames.index("TOPIC")]
|
||||||
assert ev["data"]["id"]
|
assert ev["data"]["id"]
|
||||||
assert ev["data"]["summary"] == "LLM SUMMARY"
|
assert ev["data"]["summary"] == "LLM SUMMARY"
|
||||||
assert ev["data"]["text"].startswith("Hello world.")
|
assert ev["data"]["transcript"].startswith("Hello world.")
|
||||||
assert ev["data"]["timestamp"] == 0.0
|
assert ev["data"]["timestamp"] == 0.0
|
||||||
|
|
||||||
assert "FINAL_LONG_SUMMARY" in eventnames
|
assert "FINAL_LONG_SUMMARY" in eventnames
|
||||||
@@ -316,7 +316,7 @@ async def test_transcript_rtc_and_websocket_and_fr(
|
|||||||
ev = events[eventnames.index("TOPIC")]
|
ev = events[eventnames.index("TOPIC")]
|
||||||
assert ev["data"]["id"]
|
assert ev["data"]["id"]
|
||||||
assert ev["data"]["summary"] == "LLM SUMMARY"
|
assert ev["data"]["summary"] == "LLM SUMMARY"
|
||||||
assert ev["data"]["text"].startswith("Hello world.")
|
assert ev["data"]["transcript"].startswith("Hello world.")
|
||||||
assert ev["data"]["timestamp"] == 0.0
|
assert ev["data"]["timestamp"] == 0.0
|
||||||
|
|
||||||
assert "FINAL_LONG_SUMMARY" in eventnames
|
assert "FINAL_LONG_SUMMARY" in eventnames
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function TopicList({
|
|||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>{topic.text}</>
|
<>{topic.transcript}</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type Topic = {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
id: string;
|
id: string;
|
||||||
text: string;
|
transcript: string;
|
||||||
segments: SegmentTopic[];
|
segments: SegmentTopic[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ import { exists, mapValues } from "../runtime";
|
|||||||
* @interface GetTranscriptTopic
|
* @interface GetTranscriptTopic
|
||||||
*/
|
*/
|
||||||
export interface GetTranscriptTopic {
|
export interface GetTranscriptTopic {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {any}
|
||||||
|
* @memberof GetTranscriptTopic
|
||||||
|
*/
|
||||||
|
id: any | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {any}
|
* @type {any}
|
||||||
@@ -42,7 +48,7 @@ export interface GetTranscriptTopic {
|
|||||||
* @type {any}
|
* @type {any}
|
||||||
* @memberof GetTranscriptTopic
|
* @memberof GetTranscriptTopic
|
||||||
*/
|
*/
|
||||||
text: any | null;
|
transcript: any | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {any}
|
* @type {any}
|
||||||
@@ -56,10 +62,11 @@ export interface GetTranscriptTopic {
|
|||||||
*/
|
*/
|
||||||
export function instanceOfGetTranscriptTopic(value: object): boolean {
|
export function instanceOfGetTranscriptTopic(value: object): boolean {
|
||||||
let isInstance = true;
|
let isInstance = true;
|
||||||
|
isInstance = isInstance && "id" in value;
|
||||||
isInstance = isInstance && "title" in value;
|
isInstance = isInstance && "title" in value;
|
||||||
isInstance = isInstance && "summary" in value;
|
isInstance = isInstance && "summary" in value;
|
||||||
isInstance = isInstance && "timestamp" in value;
|
isInstance = isInstance && "timestamp" in value;
|
||||||
isInstance = isInstance && "text" in value;
|
isInstance = isInstance && "transcript" in value;
|
||||||
|
|
||||||
return isInstance;
|
return isInstance;
|
||||||
}
|
}
|
||||||
@@ -76,10 +83,11 @@ export function GetTranscriptTopicFromJSONTyped(
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
id: json["id"],
|
||||||
title: json["title"],
|
title: json["title"],
|
||||||
summary: json["summary"],
|
summary: json["summary"],
|
||||||
timestamp: json["timestamp"],
|
timestamp: json["timestamp"],
|
||||||
text: json["text"],
|
transcript: json["transcript"],
|
||||||
segments: !exists(json, "segments") ? undefined : json["segments"],
|
segments: !exists(json, "segments") ? undefined : json["segments"],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,10 +102,11 @@ export function GetTranscriptTopicToJSON(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
id: value.id,
|
||||||
title: value.title,
|
title: value.title,
|
||||||
summary: value.summary,
|
summary: value.summary,
|
||||||
timestamp: value.timestamp,
|
timestamp: value.timestamp,
|
||||||
text: value.text,
|
transcript: value.transcript,
|
||||||
segments: value.segments,
|
segments: value.segments,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user