Spaces:
Running
Running
End of Demo
Browse files- app.py +22 -25
- mcp_host/ui.py +21 -0
app.py
CHANGED
|
@@ -38,13 +38,12 @@ from fastrtc import (
|
|
| 38 |
ReplyOnPause,
|
| 39 |
get_cloudflare_turn_credentials_async,
|
| 40 |
get_cloudflare_turn_credentials,
|
| 41 |
-
get_twilio_turn_credentials,
|
| 42 |
WebRTCError,
|
| 43 |
)
|
| 44 |
|
| 45 |
from mcp_host.agent import VibeShoppingAgent
|
| 46 |
from mcp_host.tts.utils import VOICES
|
| 47 |
-
from mcp_host.ui import WelcomeUI, ColdBootUI, ImageDisplay, ProductList
|
| 48 |
|
| 49 |
if TYPE_CHECKING:
|
| 50 |
from openai.types.chat import ChatCompletionMessageParam
|
|
@@ -147,32 +146,30 @@ def handle_audio_stream(
|
|
| 147 |
|
| 148 |
|
| 149 |
def set_client_for_session(request: gr.Request):
|
| 150 |
-
health_check_response = requests.get(
|
| 151 |
-
|
| 152 |
-
)
|
| 153 |
-
if health_check_response.status_code != 200:
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
|
| 158 |
-
threading.Thread(target=health_check_virtual_try_model).start()
|
| 159 |
|
| 160 |
if not vibe_shopping_agent.clients_connected:
|
| 161 |
vibe_shopping_agent.connect_clients()
|
| 162 |
|
| 163 |
if IS_HF_ZERO_GPU:
|
| 164 |
# No need to set client for HF Zero GPU, we will run tts & stt inference on the gpu
|
| 165 |
-
return None
|
| 166 |
|
| 167 |
if "x-ip-token" not in request.headers:
|
| 168 |
# Probably running in a local environment
|
| 169 |
-
return Client("sitatech/Kokoro-TTS")
|
| 170 |
|
| 171 |
x_ip_token = request.headers["x-ip-token"]
|
| 172 |
|
| 173 |
-
return Client("sitatech/Kokoro-TTS", headers={"X-IP-Token": x_ip_token})
|
| 174 |
-
visible=False
|
| 175 |
-
)
|
| 176 |
|
| 177 |
|
| 178 |
with gr.Blocks(
|
|
@@ -218,13 +215,12 @@ with gr.Blocks(
|
|
| 218 |
mode="send-receive",
|
| 219 |
modality="audio",
|
| 220 |
button_labels={"start": "Start Vibe Shopping"},
|
| 221 |
-
rtc_configuration=(
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
# ),
|
| 228 |
scale=0,
|
| 229 |
time_limit=3600,
|
| 230 |
)
|
|
@@ -316,8 +312,9 @@ with gr.Blocks(
|
|
| 316 |
show_progress="hidden",
|
| 317 |
)
|
| 318 |
|
| 319 |
-
with Modal(visible=True, allow_user_close=
|
| 320 |
-
ColdBootUI()
|
|
|
|
| 321 |
|
| 322 |
-
vibe_shopping_app.load(set_client_for_session, None, [gradio_client
|
| 323 |
vibe_shopping_app.queue().launch(allowed_paths=["/tmp/vibe-shopping-public/"])
|
|
|
|
| 38 |
ReplyOnPause,
|
| 39 |
get_cloudflare_turn_credentials_async,
|
| 40 |
get_cloudflare_turn_credentials,
|
|
|
|
| 41 |
WebRTCError,
|
| 42 |
)
|
| 43 |
|
| 44 |
from mcp_host.agent import VibeShoppingAgent
|
| 45 |
from mcp_host.tts.utils import VOICES
|
| 46 |
+
from mcp_host.ui import EndOfDemo, WelcomeUI, ColdBootUI, ImageDisplay, ProductList
|
| 47 |
|
| 48 |
if TYPE_CHECKING:
|
| 49 |
from openai.types.chat import ChatCompletionMessageParam
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
def set_client_for_session(request: gr.Request):
|
| 149 |
+
# health_check_response = requests.get(
|
| 150 |
+
# os.environ["OPENAI_API_BASE_URL"].replace("/v1", "/health")
|
| 151 |
+
# )
|
| 152 |
+
# if health_check_response.status_code != 200:
|
| 153 |
+
# raise WebRTCError(
|
| 154 |
+
# f"Inference server is not available. Status code: {health_check_response.status_code}"
|
| 155 |
+
# )
|
| 156 |
|
| 157 |
+
# threading.Thread(target=health_check_virtual_try_model).start()
|
| 158 |
|
| 159 |
if not vibe_shopping_agent.clients_connected:
|
| 160 |
vibe_shopping_agent.connect_clients()
|
| 161 |
|
| 162 |
if IS_HF_ZERO_GPU:
|
| 163 |
# No need to set client for HF Zero GPU, we will run tts & stt inference on the gpu
|
| 164 |
+
return None
|
| 165 |
|
| 166 |
if "x-ip-token" not in request.headers:
|
| 167 |
# Probably running in a local environment
|
| 168 |
+
return Client("sitatech/Kokoro-TTS")
|
| 169 |
|
| 170 |
x_ip_token = request.headers["x-ip-token"]
|
| 171 |
|
| 172 |
+
return Client("sitatech/Kokoro-TTS", headers={"X-IP-Token": x_ip_token})
|
|
|
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
with gr.Blocks(
|
|
|
|
| 215 |
mode="send-receive",
|
| 216 |
modality="audio",
|
| 217 |
button_labels={"start": "Start Vibe Shopping"},
|
| 218 |
+
rtc_configuration=(
|
| 219 |
+
get_cloudflare_turn_credentials_async if not IS_LOCAL else None
|
| 220 |
+
),
|
| 221 |
+
server_rtc_configuration=(
|
| 222 |
+
get_cloudflare_turn_credentials(ttl=360_000) if not IS_LOCAL else None
|
| 223 |
+
),
|
|
|
|
| 224 |
scale=0,
|
| 225 |
time_limit=3600,
|
| 226 |
)
|
|
|
|
| 312 |
show_progress="hidden",
|
| 313 |
)
|
| 314 |
|
| 315 |
+
with Modal(visible=True, allow_user_close=True) as modal:
|
| 316 |
+
# ColdBootUI()
|
| 317 |
+
EndOfDemo()
|
| 318 |
|
| 319 |
+
vibe_shopping_app.load(set_client_for_session, None, [gradio_client])
|
| 320 |
vibe_shopping_app.queue().launch(allowed_paths=["/tmp/vibe-shopping-public/"])
|
mcp_host/ui.py
CHANGED
|
@@ -150,3 +150,24 @@ def ColdBootUI():
|
|
| 150 |
</div>
|
| 151 |
""",
|
| 152 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
</div>
|
| 151 |
""",
|
| 152 |
)
|
| 153 |
+
|
| 154 |
+
def EndOfDemo():
|
| 155 |
+
return gr.HTML(
|
| 156 |
+
"""
|
| 157 |
+
<div style="
|
| 158 |
+
display: flex;
|
| 159 |
+
flex-direction: column;
|
| 160 |
+
align-items: center;
|
| 161 |
+
justify-content: center;
|
| 162 |
+
height: 100%;
|
| 163 |
+
width: 100%;
|
| 164 |
+
text-align: center;
|
| 165 |
+
">
|
| 166 |
+
<h2>The free demo period is over :(</h2>
|
| 167 |
+
<p style="font-size: 1.2rem; margin-top: 16px;">
|
| 168 |
+
If you still want to try it out, you can clone the repo and run it yourself.</br>
|
| 169 |
+
If you need any help, feel free to ask in the community tab in the huggingface space.
|
| 170 |
+
</p>
|
| 171 |
+
</div>
|
| 172 |
+
""",
|
| 173 |
+
)
|