Nikita Makarov commited on
Commit
178b50b
Β·
1 Parent(s): bb97e91

Fix Modal proxy: update decorators and add deployment script

Browse files
Files changed (2) hide show
  1. deploy_modal.sh +29 -0
  2. modal_proxy.py +3 -3
deploy_modal.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # AI Radio Modal Proxy Deployment Script
3
+
4
+ echo "πŸš€ Deploying AI Radio YouTube Proxy to Modal..."
5
+
6
+ # Check if modal is installed
7
+ if ! command -v modal &> /dev/null; then
8
+ echo "❌ Modal CLI not found. Installing..."
9
+ pip install modal
10
+ fi
11
+
12
+ # Login to Modal (if not already logged in)
13
+ echo "πŸ”‘ Checking Modal authentication..."
14
+ modal token new
15
+
16
+ # Fix deprecated decorators
17
+ echo "πŸ”§ Fixing deprecated decorators..."
18
+ sed -i '' 's/@modal.web_endpoint/@modal.fastapi_endpoint/g' modal_proxy.py
19
+
20
+ # Deploy the app
21
+ echo "πŸ“¦ Deploying to Modal..."
22
+ modal deploy modal_proxy.py
23
+
24
+ echo "βœ… Deployment complete!"
25
+ echo ""
26
+ echo "πŸ“ Next steps:"
27
+ echo "1. Copy the Modal URL shown above"
28
+ echo "2. Update src/mcp_servers/music_server.py with your Modal URL"
29
+ echo "3. Run: git add . && git commit -m 'Update Modal URL' && git push hf main --force"
modal_proxy.py CHANGED
@@ -9,7 +9,7 @@ import json
9
  from typing import Dict, List, Any
10
 
11
  # Create Modal app
12
- app = modal.App("youtube-proxy")
13
 
14
  # Define image with dependencies
15
  image = modal.Image.debian_slim().pip_install(
@@ -19,7 +19,7 @@ image = modal.Image.debian_slim().pip_install(
19
  )
20
 
21
  @app.function(image=image, secrets=[modal.Secret.from_name("youtube-api-key")])
22
- @modal.web_endpoint(method="GET", label="youtube-search")
23
  def search_youtube(query: str, limit: int = 5) -> Dict[str, Any]:
24
  """Search YouTube via official API"""
25
  try:
@@ -64,7 +64,7 @@ def search_youtube(query: str, limit: int = 5) -> Dict[str, Any]:
64
  return {"success": False, "error": str(e), "tracks": []}
65
 
66
  @app.function(image=image)
67
- @modal.web_endpoint(method="GET", label="soundcloud-search")
68
  def search_soundcloud(query: str, limit: int = 5) -> Dict[str, Any]:
69
  """Search SoundCloud via API"""
70
  try:
 
9
  from typing import Dict, List, Any
10
 
11
  # Create Modal app
12
+ app = modal.App("ai-radio-youtube-proxy")
13
 
14
  # Define image with dependencies
15
  image = modal.Image.debian_slim().pip_install(
 
19
  )
20
 
21
  @app.function(image=image, secrets=[modal.Secret.from_name("youtube-api-key")])
22
+ @modal.fastapi_endpoint(method="GET", label="youtube-search")
23
  def search_youtube(query: str, limit: int = 5) -> Dict[str, Any]:
24
  """Search YouTube via official API"""
25
  try:
 
64
  return {"success": False, "error": str(e), "tracks": []}
65
 
66
  @app.function(image=image)
67
+ @modal.fastapi_endpoint(method="GET", label="soundcloud-search")
68
  def search_soundcloud(query: str, limit: int = 5) -> Dict[str, Any]:
69
  """Search SoundCloud via API"""
70
  try: