inventwithdean commited on
Commit
eefc538
·
1 Parent(s): ff7b479

add url validity

Browse files
Files changed (2) hide show
  1. app.py +4 -1
  2. validity.py +5 -0
app.py CHANGED
@@ -10,6 +10,7 @@ from guard import Guardian
10
  import random
11
  import threading
12
  from timing import TimeManager
 
13
 
14
  api_key = os.getenv("API_KEY_OPENROUTER")
15
  client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=api_key)
@@ -46,7 +47,9 @@ def join_show(avatar_url):
46
  your guest_name for the talk show and info about your situation
47
 
48
  """
49
- # TODO: Validate the URL
 
 
50
  payload = {"avatar_url": avatar_url}
51
  headers = {"Content-Type": "application/json", "x-api-key": api_key_unreal}
52
  response = requests.post(
 
10
  import random
11
  import threading
12
  from timing import TimeManager
13
+ from validity import is_valid_rpm_url
14
 
15
  api_key = os.getenv("API_KEY_OPENROUTER")
16
  client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=api_key)
 
47
  your guest_name for the talk show and info about your situation
48
 
49
  """
50
+ if not is_valid_rpm_url(avatar_url):
51
+ return "Invalid Avatar URL! Please make sure you are using a Ready Player Me .glb avatar URL."
52
+
53
  payload = {"avatar_url": avatar_url}
54
  headers = {"Content-Type": "application/json", "x-api-key": api_key_unreal}
55
  response = requests.post(
validity.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import re
2
+
3
+ def is_valid_rpm_url(url: str) -> bool:
4
+ pattern = r"^https://models\.readyplayer\.me/[0-9a-fA-F]+\.glb$"
5
+ return bool(re.match(pattern, url))