evalstate HF Staff commited on
Commit
c58fd87
·
verified ·
1 Parent(s): bc9bae9

Deploy fast-agent A2A demo

Browse files
Files changed (4) hide show
  1. Dockerfile +10 -0
  2. README.md +12 -5
  3. __pycache__/app.cpython-313.pyc +0 -0
  4. app.py +55 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ ENV PYTHONUNBUFFERED=1 \
4
+ PIP_NO_CACHE_DIR=1 \
5
+ FAST_AGENT_BUCKET_MOUNT=/data
6
+
7
+ WORKDIR /app
8
+ COPY app.py /app/app.py
9
+
10
+ CMD ["python", "/app/app.py"]
README.md CHANGED
@@ -1,10 +1,17 @@
1
  ---
2
- title: A2a Demo
3
- emoji: 📈
4
- colorFrom: purple
5
- colorTo: red
6
  sdk: docker
 
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
1
  ---
2
+ title: a2a-demo
3
+ emoji: 🕸️
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
  ---
10
 
11
+ # a2a-demo
12
+
13
+ fast-agent A2A server with Hugging Face bearer/OAuth pass-through.
14
+
15
+ The Space mounts an `a2a-demo` bucket at `/data`, installs the latest
16
+ `fast-agent-mcp` wheel from `/data/wheels`, and serves the AgentCard in
17
+ `/data/agent-cards`.
__pycache__/app.cpython-313.pyc ADDED
Binary file (2.63 kB). View file
 
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import glob
4
+ import os
5
+ import subprocess
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ BUCKET_MOUNT = Path(os.environ.get("FAST_AGENT_BUCKET_MOUNT", "/data"))
10
+ CARD_DIR = BUCKET_MOUNT / "agent-cards"
11
+
12
+
13
+ def latest_wheel() -> str:
14
+ wheels = sorted(
15
+ glob.glob(str(BUCKET_MOUNT / "wheels" / "fast_agent_mcp-*.whl")),
16
+ key=os.path.getmtime,
17
+ reverse=True,
18
+ )
19
+ if not wheels:
20
+ raise RuntimeError(f"No fast-agent-mcp wheel found under {BUCKET_MOUNT / 'wheels'}")
21
+ return wheels[0]
22
+
23
+
24
+ def main() -> None:
25
+ wheel = latest_wheel()
26
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", wheel])
27
+
28
+ os.environ.setdefault("FAST_AGENT_SERVE_OAUTH", "huggingface")
29
+ os.environ.setdefault("FAST_AGENT_OAUTH_SCOPES", "access")
30
+ os.environ.setdefault("PYTHONUNBUFFERED", "1")
31
+
32
+ cmd = [
33
+ sys.executable,
34
+ "-m",
35
+ "fast_agent.cli.__main__",
36
+ "serve",
37
+ "a2a",
38
+ "--name",
39
+ os.environ.get("FAST_AGENT_A2A_NAME", "a2a-demo"),
40
+ "--host",
41
+ "0.0.0.0",
42
+ "--port",
43
+ os.environ.get("PORT", "7860"),
44
+ "--instance-scope",
45
+ os.environ.get("FAST_AGENT_A2A_INSTANCE_SCOPE", "connection"),
46
+ "--agent-cards",
47
+ str(CARD_DIR),
48
+ "--model",
49
+ os.environ.get("FAST_AGENT_MODEL", "kimi"),
50
+ ]
51
+ os.execv(sys.executable, cmd)
52
+
53
+
54
+ if __name__ == "__main__":
55
+ main()