zequn-fireworks commited on
Commit
ae77a1b
·
1 Parent(s): 9b7762b

Fix: add trailing slash to multi-provider agent card URLs (avoid 307 redirect)

Browse files
scripts/upload_secrets.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Upload secrets from a .env file to a Hugging Face Space.
3
+
4
+ Usage:
5
+ python scripts/upload_secrets.py <space_id> <env_file>
6
+
7
+ Example:
8
+ python scripts/upload_secrets.py zequn-fireworks/fireaction-a2a .env
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ from huggingface_hub import HfApi
17
+
18
+
19
+ def parse_env_file(path: Path) -> dict[str, str]:
20
+ """Parse a .env file into a dict, skipping comments and blank lines."""
21
+ secrets = {}
22
+ for line in path.read_text().splitlines():
23
+ line = line.strip()
24
+ if not line or line.startswith("#"):
25
+ continue
26
+ if "=" not in line:
27
+ continue
28
+ key, _, value = line.partition("=")
29
+ key = key.strip()
30
+ value = value.strip().strip("'\"")
31
+ if key and value:
32
+ secrets[key] = value
33
+ return secrets
34
+
35
+
36
+ def main() -> None:
37
+ if len(sys.argv) != 3:
38
+ print(f"Usage: {sys.argv[0]} <space_id> <env_file>")
39
+ print(f"Example: {sys.argv[0]} zequn-fireworks/fireaction-a2a .env")
40
+ sys.exit(1)
41
+
42
+ space_id = sys.argv[1]
43
+ env_file = Path(sys.argv[2])
44
+
45
+ if not env_file.exists():
46
+ print(f"Error: {env_file} not found")
47
+ sys.exit(1)
48
+
49
+ secrets = parse_env_file(env_file)
50
+ if not secrets:
51
+ print(f"No secrets found in {env_file}")
52
+ sys.exit(1)
53
+
54
+ api = HfApi()
55
+ print(f"Uploading {len(secrets)} secrets to {space_id}...")
56
+
57
+ for key, value in secrets.items():
58
+ api.add_space_secret(repo_id=space_id, key=key, value=value)
59
+ print(f" + {key}")
60
+
61
+ print("Done.")
62
+
63
+
64
+ if __name__ == "__main__":
65
+ main()
src/fireaction_a2a/card.py CHANGED
@@ -44,7 +44,7 @@ def build_card(
44
  f"Specialist agent for {provider_name} API operations "
45
  f"using {len(skills)} validated contracts."
46
  ),
47
- url=_resolve_public_url(host, port) + path_prefix,
48
  version="1.0.0",
49
  skills=skills,
50
  defaultInputModes=["text"],
 
44
  f"Specialist agent for {provider_name} API operations "
45
  f"using {len(skills)} validated contracts."
46
  ),
47
+ url=_resolve_public_url(host, port) + path_prefix + ("/" if path_prefix else ""),
48
  version="1.0.0",
49
  skills=skills,
50
  defaultInputModes=["text"],