mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-16 08:25:18 +02:00
feat: download campaign report
This commit is contained in:
parent
ff92c6ae5c
commit
4d807266a7
12 changed files with 429 additions and 28 deletions
|
|
@ -16,6 +16,28 @@ from api.services.configuration.registry import ServiceConfig
|
|||
|
||||
VISIBLE_CHARS = 4 # number of trailing characters to reveal
|
||||
MASK_CHAR = "*"
|
||||
MASK_MARKER = "***" # substring that indicates a masked key
|
||||
|
||||
|
||||
def contains_masked_key(api_key: str | list[str] | None) -> bool:
|
||||
"""Return True if *api_key* looks like a masked placeholder."""
|
||||
if api_key is None:
|
||||
return False
|
||||
keys = api_key if isinstance(api_key, list) else [api_key]
|
||||
return any(MASK_MARKER in k for k in keys)
|
||||
|
||||
|
||||
def check_for_masked_keys(config: "UserConfiguration") -> None:
|
||||
"""Raise ValueError if any service in *config* still has a masked API key."""
|
||||
for field in ("llm", "tts", "stt", "embeddings"):
|
||||
service = getattr(config, field, None)
|
||||
if service is None:
|
||||
continue
|
||||
if contains_masked_key(service.get_all_api_keys()):
|
||||
raise ValueError(
|
||||
f"The {field} api_key appears to be masked. "
|
||||
"Please provide the actual API key, not the masked value."
|
||||
)
|
||||
|
||||
|
||||
def mask_key(real_key: str, visible: int = VISIBLE_CHARS) -> str:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import random
|
|||
from enum import Enum, auto
|
||||
from typing import Annotated, Dict, Literal, Type, TypeVar, Union
|
||||
|
||||
from loguru import logger
|
||||
from pydantic import BaseModel, Field, computed_field, field_validator
|
||||
|
||||
|
||||
|
|
@ -607,6 +606,7 @@ class SpeechmaticsSTTConfiguration(BaseSTTConfiguration):
|
|||
STTConfig = Annotated[
|
||||
Union[
|
||||
DeepgramSTTConfiguration,
|
||||
CartesiaSTTConfiguration,
|
||||
OpenAISTTConfiguration,
|
||||
DograhSTTService,
|
||||
SpeechmaticsSTTConfiguration,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from typing import List, Optional
|
|||
|
||||
from loguru import logger
|
||||
|
||||
from api.utils.transcript import generate_transcript_text as _generate_transcript_text
|
||||
from pipecat.utils.enums import RealtimeFeedbackType
|
||||
|
||||
|
||||
|
|
@ -138,26 +139,9 @@ class InMemoryLogsBuffer:
|
|||
"""Generate transcript text from logged events.
|
||||
|
||||
Filters for rtf-user-transcription (final) and rtf-bot-text events,
|
||||
formats them as '[timestamp] user/assistant: text\n'.
|
||||
formats them as '[timestamp] user/assistant: text\\n'.
|
||||
"""
|
||||
lines: List[str] = []
|
||||
for event in self._events:
|
||||
event_type = event.get("type")
|
||||
payload = event.get("payload", {})
|
||||
|
||||
if (
|
||||
event_type == RealtimeFeedbackType.USER_TRANSCRIPTION.value
|
||||
and payload.get("final") is True
|
||||
):
|
||||
timestamp = payload.get("timestamp", "")
|
||||
prefix = f"[{timestamp}] " if timestamp else ""
|
||||
lines.append(f"{prefix}user: {payload.get('text', '')}\n")
|
||||
elif event_type == RealtimeFeedbackType.BOT_TEXT.value:
|
||||
timestamp = payload.get("timestamp", "")
|
||||
prefix = f"[{timestamp}] " if timestamp else ""
|
||||
lines.append(f"{prefix}assistant: {payload.get('text', '')}\n")
|
||||
|
||||
return "".join(lines)
|
||||
return _generate_transcript_text(self._events)
|
||||
|
||||
def write_transcript_to_temp_file(self) -> Optional[str]:
|
||||
"""Write transcript to a temporary text file and return the path.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue