Skip to content

Commit 7bbd6b9

Browse files
committed
refactor: update Dockerfile to use poetry for mediapipe installation; restructure Twilio bot classes to initialize request overrides in constructors; change return type of call method in inbuilt_tools.py; remove unused run_v2 method in VideoBots.py; fix variable naming in create_twilio_sip_trunk.py; disable translation tests
1 parent f0321b2 commit 7bbd6b9

File tree

8 files changed

+25
-79
lines changed

8 files changed

+25
-79
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN poetry run playwright install-deps && poetry run playwright install chromium
5252
ARG RUN_LIVEKIT=${RUN_LIVEKIT}
5353
ENV RUN_LIVEKIT=${RUN_LIVEKIT}
5454
RUN if [ -z "$RUN_LIVEKIT" ]; then \
55-
pip install --no-cache-dir mediapipe; \
55+
poetry run pip install --no-cache-dir mediapipe; \
5656
fi
5757

5858
# copy the code into the container

daras_ai_v2/twilio_bot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
class TwilioSMS(BotInterface):
1919
platform = Platform.TWILIO
2020

21-
request_overrides = dict(
22-
variables=dict(platform_medium="SMS"),
23-
)
24-
2521
def __init__(self, data: dict):
22+
self.request_overrides = dict(
23+
variables=dict(platform_medium="SMS"),
24+
)
25+
2626
account_sid = data["AccountSid"][0]
2727
if account_sid == settings.TWILIO_ACCOUNT_SID:
2828
account_sid = ""
@@ -117,10 +117,6 @@ def send_sms_message(
117117
class TwilioVoice(BotInterface):
118118
platform = Platform.TWILIO
119119

120-
request_overrides = dict(
121-
variables=dict(platform_medium="VOICE"),
122-
)
123-
124120
@classmethod
125121
def from_webhook_data(cls, data: dict):
126122
## data samples:
@@ -182,6 +178,9 @@ def __init__(
182178
text: str = None,
183179
audio_url: str = None,
184180
):
181+
self.request_overrides = dict(
182+
variables=dict(platform_medium="VOICE"),
183+
)
185184
self.convo = convo
186185

187186
self.bot_id = convo.bot_integration.twilio_phone_number.as_e164

functions/inbuilt_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, state: dict):
7575
required=["queries"],
7676
)
7777

78-
def call(self, queries: list[str]) -> str:
78+
def call(self, queries: list[str]) -> dict[str, list[str]]:
7979
from daras_ai_v2.vector_search import get_top_k_references, DocSearchRequest
8080
from daras_ai_v2.language_model_openai_realtime import yield_from
8181

glossary_resources/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from decouple import config
23

34
from daras_ai.image_input import gcs_blob_for
45
from daras_ai_v2 import settings
@@ -74,7 +75,10 @@ def glossary_url():
7475
GlossaryResource.objects.all().delete()
7576

7677

77-
@pytest.mark.skipif(not settings.GS_BUCKET_NAME, reason="No GCS bucket")
78+
@pytest.mark.skipif(
79+
not settings.GS_BUCKET_NAME or not config("RUN_GOOGLE_TRANSLATE_TESTS", None),
80+
reason="No bucket name or run google translate tests",
81+
)
7882
def test_google_translate_glossary(transactional_db, glossary_url, threadpool_subtest):
7983
for text, expected, expected_with_glossary in TRANSLATION_TESTS_GLOSSARY:
8084
threadpool_subtest(

recipes/TextToSpeech.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ class TextToSpeechPage(BasePage):
7474
"compare-text-to-speech-engines",
7575
]
7676

77-
sane_defaults = {
78-
"tts_provider": TextToSpeechProviders.GOOGLE_TTS.value,
79-
"google_voice_name": "en-IN-Wavenet-A",
80-
"google_pitch": 0.0,
81-
"google_speaking_rate": 1.0,
82-
"uberduck_voice_name": "Aiden Botha",
83-
"uberduck_speaking_rate": 1.0,
84-
"elevenlabs_model": "eleven_multilingual_v2",
85-
"elevenlabs_stability": 0.5,
86-
"elevenlabs_similarity_boost": 0.75,
87-
}
88-
8977
class RequestModelBase(BasePage.RequestModel):
9078
text_prompt: str
9179

recipes/VideoBots.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,58 +1573,6 @@ def additional_notes(self):
15731573

15741574
return notes
15751575

1576-
def run_v2(
1577-
self,
1578-
request: "VideoBotsPage.RequestModel",
1579-
response: "VideoBotsPage.ResponseModel",
1580-
) -> typing.Iterator[str | None]:
1581-
if request.tts_provider == TextToSpeechProviders.ELEVEN_LABS.name and not (
1582-
self.is_current_user_paying() or self.is_current_user_admin()
1583-
):
1584-
raise UserError(
1585-
"""
1586-
Please purchase Gooey.AI credits to use ElevenLabs voices <a href="/account">here</a>.
1587-
"""
1588-
)
1589-
1590-
llm_model = LargeLanguageModels[request.selected_model]
1591-
user_input = (request.input_prompt or "").strip()
1592-
if not (
1593-
user_input
1594-
or request.input_audio
1595-
or request.input_images
1596-
or request.input_documents
1597-
):
1598-
return
1599-
1600-
asr_msg, user_input = yield from self.asr_step(
1601-
model=llm_model, request=request, response=response, user_input=user_input
1602-
)
1603-
1604-
ocr_texts = yield from self.document_understanding_step(request=request)
1605-
1606-
request.translation_model = (
1607-
request.translation_model or DEFAULT_TRANSLATION_MODEL
1608-
)
1609-
user_input = yield from self.input_translation_step(
1610-
request=request, user_input=user_input, ocr_texts=ocr_texts
1611-
)
1612-
1613-
yield from self.build_final_prompt(
1614-
request=request, response=response, user_input=user_input, model=llm_model
1615-
)
1616-
1617-
yield from self.llm_loop(
1618-
request=request,
1619-
response=response,
1620-
model=llm_model,
1621-
asr_msg=asr_msg,
1622-
)
1623-
1624-
yield from self.tts_step(model=llm_model, request=request, response=response)
1625-
1626-
yield from self.lipsync_step(request, response)
1627-
16281576
def render_header_extra(self):
16291577
if self.tab == RecipeTabs.run or self.tab == RecipeTabs.preview:
16301578
render_demo_buttons_header(self.current_pr)

scripts/create_twilio_sip_trunk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def get_or_create_origination_url(
114114
priority: int = 1,
115115
weight: int = 1,
116116
enabled: bool = True,
117-
) -> str:
117+
):
118118
existing = client.trunking.v1.trunks(trunk_sid).origination_urls.list()
119119
for ou in existing:
120120
if ou.sip_url != sip_url:
@@ -136,11 +136,11 @@ def get_or_create_credential_list(
136136
list_friendly_name: str,
137137
):
138138
try:
139-
cl = client.sip.credential_lists.create(friendly_name=list_friendly_name)
139+
clists = client.sip.credential_lists.create(friendly_name=list_friendly_name)
140140
except TwilioException as exc:
141141
if exc.code == 21240:
142-
cl = client.sip.credential_lists.list()
143-
for cl in cl:
142+
clists = client.sip.credential_lists.list()
143+
for cl in clists:
144144
if cl.friendly_name == list_friendly_name:
145145
return cl
146146
raise

tests/test_translation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
from decouple import config
3+
14
from conftest import flaky
25
from daras_ai_v2.asr import run_google_translate
36

@@ -47,6 +50,10 @@
4750
]
4851

4952

53+
@pytest.mark.skipif(
54+
not config("RUN_GOOGLE_TRANSLATE_TESTS", None),
55+
reason="No run google translate tests",
56+
)
5057
def test_google_translate(threadpool_subtest):
5158
for lang, text, expected in TRANSLATION_TESTS:
5259
threadpool_subtest(google_translate_check, text, expected, source_language=lang)

0 commit comments

Comments
 (0)