Spaces:
Sleeping
Sleeping
Sheyda Kiani Mehr
commited on
Commit
Β·
d98558a
1
Parent(s):
3123e36
revert to test version
Browse files- Dockerfile +8 -0
- README.md +10 -0
- main.py +41 -0
- Containerfile.txt β original/Containerfile.txt +0 -0
- __init__.py β original/__init__.py +0 -0
- __main__.py β original/__main__.py +0 -0
- agent_executor.py β original/agent_executor.py +0 -0
- pyproject.toml β original/pyproject.toml +0 -0
- uv.lock β original/uv.lock +0 -0
- requirements.txt +4 -0
Dockerfile
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PORT=7860
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
COPY requirements.txt .
|
| 5 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 6 |
+
COPY . .
|
| 7 |
+
CMD ["python", "main.py"]
|
| 8 |
+
|
README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: A2a Server
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: pink
|
| 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
|
main.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# main.py
|
| 2 |
+
import os
|
| 3 |
+
import uvicorn
|
| 4 |
+
|
| 5 |
+
# ---- Adjust imports to match a2a-python ----
|
| 6 |
+
# These paths are common in the tutorial; if yours differ, change them accordingly.
|
| 7 |
+
from a2a.server.apps import A2AStarletteApplication
|
| 8 |
+
from a2a.server.request_handlers import DefaultRequestHandler
|
| 9 |
+
from a2a.server.tasks import InMemoryTaskStore
|
| 10 |
+
|
| 11 |
+
# Example minimal executor
|
| 12 |
+
class HelloWorldAgentExecutor:
|
| 13 |
+
async def call(self, message: str, **kwargs):
|
| 14 |
+
return {"text": f"Hello from A2A on HF Spaces! You said: {message}"}
|
| 15 |
+
|
| 16 |
+
# Example minimal public AgentCard (adjust fields to your spec)
|
| 17 |
+
AGENT_CARD = {
|
| 18 |
+
"name": "HF A2A Agent",
|
| 19 |
+
"version": "1.0",
|
| 20 |
+
"description": "A2A demo running on Hugging Face Spaces",
|
| 21 |
+
"endpoints": {
|
| 22 |
+
"send": "/message/send",
|
| 23 |
+
"stream": "/message/stream"
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
def build_app():
|
| 28 |
+
app = A2AStarletteApplication(
|
| 29 |
+
agent_card=AGENT_CARD,
|
| 30 |
+
http_handler=DefaultRequestHandler(
|
| 31 |
+
agent_executor=HelloWorldAgentExecutor(),
|
| 32 |
+
task_store=InMemoryTaskStore(),
|
| 33 |
+
),
|
| 34 |
+
# extended_agent_card=... # optional
|
| 35 |
+
).build()
|
| 36 |
+
return app
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
port = int(os.getenv("PORT", "7860")) # HF provides PORT
|
| 40 |
+
uvicorn.run(build_app(), host="0.0.0.0", port=port)
|
| 41 |
+
|
Containerfile.txt β original/Containerfile.txt
RENAMED
|
File without changes
|
__init__.py β original/__init__.py
RENAMED
|
File without changes
|
__main__.py β original/__main__.py
RENAMED
|
File without changes
|
agent_executor.py β original/agent_executor.py
RENAMED
|
File without changes
|
pyproject.toml β original/pyproject.toml
RENAMED
|
File without changes
|
uv.lock β original/uv.lock
RENAMED
|
File without changes
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uvicorn>=0.30
|
| 2 |
+
starlette>=0.37
|
| 3 |
+
# The A2A library (adjust to the name/extra you use)
|
| 4 |
+
a2a-sdk[http-server]
|