mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
feat: allow www domain for embedded websites (#60)
This commit is contained in:
parent
02becc7fff
commit
ed3ceaf5ad
2 changed files with 24 additions and 3 deletions
|
|
@ -71,6 +71,16 @@ def validate_origin(origin: str, allowed_domains: list) -> bool:
|
|||
else:
|
||||
domain = origin
|
||||
|
||||
# Normalize domain for www matching
|
||||
def normalize_www(d: str) -> tuple[str, str]:
|
||||
"""Return both www and non-www versions of a domain"""
|
||||
if d.startswith("www."):
|
||||
return (d, d[4:]) # (www.x.com, x.com)
|
||||
else:
|
||||
return (d, f"www.{d}") # (x.com, www.x.com)
|
||||
|
||||
domain_variants = normalize_www(domain)
|
||||
|
||||
for allowed in allowed_domains:
|
||||
if allowed == "*":
|
||||
return True
|
||||
|
|
@ -79,8 +89,13 @@ def validate_origin(origin: str, allowed_domains: list) -> bool:
|
|||
base_domain = allowed[2:]
|
||||
if domain == base_domain or domain.endswith("." + base_domain):
|
||||
return True
|
||||
elif domain == allowed:
|
||||
return True
|
||||
else:
|
||||
# Check both www and non-www versions
|
||||
allowed_variants = normalize_www(allowed)
|
||||
# If any variant of domain matches any variant of allowed, it's valid
|
||||
if any(dv in allowed_variants or av in domain_variants
|
||||
for dv in domain_variants for av in allowed_variants):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from api.constants import MPS_API_URL
|
|||
from api.services.configuration.registry import ServiceProviders
|
||||
from pipecat.services.azure.llm import AzureLLMService
|
||||
from pipecat.services.cartesia.stt import CartesiaSTTService
|
||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||
from pipecat.services.deepgram.stt import DeepgramSTTService, LiveOptions
|
||||
from pipecat.services.deepgram.tts import DeepgramTTSService
|
||||
from pipecat.services.dograh.llm import DograhLLMService
|
||||
from pipecat.services.dograh.stt import DograhSTTService
|
||||
|
|
@ -25,7 +25,13 @@ if TYPE_CHECKING:
|
|||
def create_stt_service(user_config):
|
||||
"""Create and return appropriate STT service based on user configuration"""
|
||||
if user_config.stt.provider == ServiceProviders.DEEPGRAM.value:
|
||||
live_options = LiveOptions(
|
||||
language="multi",
|
||||
profanity_filter=False,
|
||||
endpointing=100
|
||||
)
|
||||
return DeepgramSTTService(
|
||||
live_options=live_options,
|
||||
api_key=user_config.stt.api_key,
|
||||
audio_passthrough=False, # Disable passthrough since audio is buffered separately
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue