Skip to content

Commit e453bd6

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
1 parent 247ff17 commit e453bd6

File tree

5 files changed

+12
-65
lines changed

5 files changed

+12
-65
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

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)