26 lines
795 B
Python
26 lines
795 B
Python
import os
|
|
import sys
|
|
|
|
BACKEND_HOST = os.getenv("BACKEND_HOST", "https://onprem-dev.gbase.ai/api")
|
|
ASSISTANT_ID = os.getenv("ASSISTANT_ID", "")
|
|
|
|
if not ASSISTANT_ID:
|
|
print("Error: ASSISTANT_ID environment variable is not set")
|
|
sys.exit(1)
|
|
|
|
if len(sys.argv) < 2:
|
|
print(f"Usage: python3 {sys.argv[0]} <file_path>")
|
|
print(f"Example: python3 {sys.argv[0]} /workspace/index.html")
|
|
sys.exit(1)
|
|
|
|
file_path = os.path.abspath(sys.argv[1])
|
|
|
|
workspace_root = "/workspace"
|
|
if not file_path.startswith(workspace_root):
|
|
print(f"Error: path must be under {workspace_root}, got: {file_path}")
|
|
sys.exit(1)
|
|
|
|
relative_path = file_path[len(workspace_root):] # e.g. "/css/style.css"
|
|
base_url = f"{BACKEND_HOST.rstrip('/')}/robot-assets/{ASSISTANT_ID}"
|
|
print(f"{base_url}{relative_path}")
|