MCPcopy Create free account
hub / github.com/HumeAI/hume-api-examples / construct_transcript

Function construct_transcript

evi/evi-python-webhooks/utils.py:23–35  ·  view source on GitHub ↗

Constructs a formatted transcript string from user and assistant messages.

(chat_events: list[ReturnChatEvent])

Source from the content-addressed store, hash-verified

21
22
23def construct_transcript(chat_events: list[ReturnChatEvent]) -> str:
24 """Constructs a formatted transcript string from user and assistant messages."""
25 relevant_events = [e for e in chat_events if e.type in ("USER_MESSAGE", "AGENT_MESSAGE")]
26
27 lines: list[str] = []
28 for event in relevant_events:
29 role = "User" if event.role == "USER" else "Assistant"
30 timestamp = event.timestamp
31 dt = datetime.fromtimestamp(timestamp / 1000.0)
32 readable_time = dt.strftime("%Y-%m-%d %H:%M:%S")
33 lines.append(f"[{readable_time}] {role}: {event.message_text}")
34
35 return "\n".join(lines)
36
37
38def save_transcript_to_file(transcript: str, chat_id: str) -> None:

Callers 1

get_chat_transcriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected