Delete Agent.md with huggingface_hub
Browse files
Agent.md
DELETED
|
@@ -1,177 +0,0 @@
|
|
| 1 |
-
# Deployment Management & Agent Guide
|
| 2 |
-
|
| 3 |
-
This file outlines tricks, configurations, and ongoing deployment best practices for running this application on Hugging Face Spaces.
|
| 4 |
-
|
| 5 |
-
## 1. Deployment Configuration
|
| 6 |
-
|
| 7 |
-
### Target Space
|
| 8 |
-
- **Profile:** `Leon4gr45`
|
| 9 |
-
- **Space:** `nova-test`
|
| 10 |
-
- **Full Identifier:** `Leon4gr45/nova-test`
|
| 11 |
-
- **Frontend Port:** `7860` (mandatory for all Hugging Face Spaces)
|
| 12 |
-
|
| 13 |
-
### Deployment Method
|
| 14 |
-
Choose the correct SDK based on the app type based on the codebase language:
|
| 15 |
-
|
| 16 |
-
- **Docker SDK** — Used for this application to provide maximum flexibility with an Express backend and a React/Vite frontend.
|
| 17 |
-
|
| 18 |
-
### HF Token
|
| 19 |
-
- The environment variable `HF_TOKEN` must be set at execution time. Never hardcode the token. Always read it from the environment. All monitoring and log-streaming commands rely on the Hugging Face API token.
|
| 20 |
-
|
| 21 |
-
### Required Files
|
| 22 |
-
- `Dockerfile`
|
| 23 |
-
- `README.md` with Hugging Face YAML frontmatter:
|
| 24 |
-
```yaml
|
| 25 |
-
---
|
| 26 |
-
title: Branding Content Testing
|
| 27 |
-
sdk: docker
|
| 28 |
-
app_port: 7860
|
| 29 |
-
---
|
| 30 |
-
```
|
| 31 |
-
- `.hfignore` to exclude unnecessary files
|
| 32 |
-
- This `Agent.md` file (must be committed before deployment)
|
| 33 |
-
|
| 34 |
-
---
|
| 35 |
-
|
| 36 |
-
## 2. API Exposure and Documentation
|
| 37 |
-
|
| 38 |
-
### Mandatory Endpoints
|
| 39 |
-
Every deployment **must** expose:
|
| 40 |
-
|
| 41 |
-
- **`/health`**
|
| 42 |
-
- Returns HTTP 200 when the app is ready.
|
| 43 |
-
- Required for Hugging Face to transition the Space from *starting* → *running*.
|
| 44 |
-
|
| 45 |
-
- **`/api-docs`**
|
| 46 |
-
- Documents **all** available API endpoints.
|
| 47 |
-
- Must be reachable at:
|
| 48 |
-
`https://Leon4gr45-nova-test.hf.space/api-docs`
|
| 49 |
-
|
| 50 |
-
### Functional Endpoints
|
| 51 |
-
|
| 52 |
-
### /api-docs
|
| 53 |
-
- Method: GET
|
| 54 |
-
- Purpose: Documents all available API endpoints.
|
| 55 |
-
- Response: HTML page displaying API documentation.
|
| 56 |
-
|
| 57 |
-
### /health
|
| 58 |
-
- Method: GET
|
| 59 |
-
- Purpose: Simple healthcheck endpoint returning HTTP 200 OK.
|
| 60 |
-
- Response: "OK"
|
| 61 |
-
|
| 62 |
-
### /api/craft
|
| 63 |
-
- Method: POST
|
| 64 |
-
- Purpose: Help craft marketing and social media content based on input content and variation using Blablador API.
|
| 65 |
-
- Request:
|
| 66 |
-
```json
|
| 67 |
-
{
|
| 68 |
-
"content": "hello world",
|
| 69 |
-
"variation": "social media post"
|
| 70 |
-
}
|
| 71 |
-
```
|
| 72 |
-
- Response:
|
| 73 |
-
```json
|
| 74 |
-
{
|
| 75 |
-
"result": "..."
|
| 76 |
-
}
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
### /api/config
|
| 80 |
-
- Method: GET
|
| 81 |
-
- Purpose: Retrieve OAuth client configuration.
|
| 82 |
-
- Response:
|
| 83 |
-
```json
|
| 84 |
-
{
|
| 85 |
-
"clientId": "some-client-id",
|
| 86 |
-
"scopes": "openid profile"
|
| 87 |
-
}
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
### /login
|
| 91 |
-
- Method: GET
|
| 92 |
-
- Purpose: Initiate OAuth login redirect flow to Hugging Face.
|
| 93 |
-
- Response: Redirects user to Hugging Face authorize page.
|
| 94 |
-
|
| 95 |
-
### /oauth/callback
|
| 96 |
-
- Method: GET
|
| 97 |
-
- Purpose: OAuth callback endpoint to exchange authorization code for an access token and retrieve user info.
|
| 98 |
-
- Response: Redirects user back to root / with hf_user cookie.
|
| 99 |
-
|
| 100 |
-
### /api/user
|
| 101 |
-
- Method: GET
|
| 102 |
-
- Purpose: Retrieve authenticated Hugging Face user details from hf_user cookie.
|
| 103 |
-
- Response:
|
| 104 |
-
```json
|
| 105 |
-
{
|
| 106 |
-
"name": "Jane Doe",
|
| 107 |
-
"preferred_username": "janedoe",
|
| 108 |
-
"picture": "https://..."
|
| 109 |
-
}
|
| 110 |
-
```
|
| 111 |
-
|
| 112 |
-
### /api/logout
|
| 113 |
-
- Method: GET
|
| 114 |
-
- Purpose: Log out the user by clearing the hf_user cookie and redirecting to root /.
|
| 115 |
-
- Response: Redirects user to root /.
|
| 116 |
-
|
| 117 |
-
### /api/save-data
|
| 118 |
-
- Method: POST
|
| 119 |
-
- Purpose: Save JSON data to server's data directory under a unique timestamped filename.
|
| 120 |
-
- Request:
|
| 121 |
-
```json
|
| 122 |
-
{
|
| 123 |
-
"type": "branding",
|
| 124 |
-
"data": { "theme": "dark" },
|
| 125 |
-
"user": "janedoe"
|
| 126 |
-
}
|
| 127 |
-
```
|
| 128 |
-
- Response:
|
| 129 |
-
```json
|
| 130 |
-
{
|
| 131 |
-
"success": true,
|
| 132 |
-
"message": "Data saved as janedoe_branding_2026-07-14-19-12-35-123Z.json"
|
| 133 |
-
}
|
| 134 |
-
```
|
| 135 |
-
|
| 136 |
-
### /api/list-data
|
| 137 |
-
- Method: GET
|
| 138 |
-
- Purpose: Retrieve list of saved JSON data files filtered optionally by type and user.
|
| 139 |
-
- Response:
|
| 140 |
-
```json
|
| 141 |
-
[
|
| 142 |
-
{
|
| 143 |
-
"user": "janedoe",
|
| 144 |
-
"type": "branding",
|
| 145 |
-
"timestamp": "2026-07-14T19-12-35-123Z",
|
| 146 |
-
"data": { "theme": "dark" }
|
| 147 |
-
}
|
| 148 |
-
]
|
| 149 |
-
```
|
| 150 |
-
|
| 151 |
-
All endpoints listed here appear in `/api-docs`.
|
| 152 |
-
|
| 153 |
-
---
|
| 154 |
-
|
| 155 |
-
## 3. Deployment Workflow
|
| 156 |
-
|
| 157 |
-
Precondition: Use the huggingface hub cli hf to check that the space is empty of files and delete any which are still in there and not belonging to the project to be uploaded.
|
| 158 |
-
|
| 159 |
-
### Standard Deployment Command
|
| 160 |
-
After any code change, run:
|
| 161 |
-
|
| 162 |
-
```bash
|
| 163 |
-
hf upload Leon4gr45/nova-test ./UserSync . --repo-type=space
|
| 164 |
-
```
|
| 165 |
-
|
| 166 |
-
### Scan build and run logs
|
| 167 |
-
To scan build logs (SSE):
|
| 168 |
-
```bash
|
| 169 |
-
curl -N -H "Authorization: Bearer <TOKEN>" "https://huggingface.co/api/spaces/Leon4gr45/nova-test/logs/build"
|
| 170 |
-
```
|
| 171 |
-
|
| 172 |
-
To get run logs (SSE):
|
| 173 |
-
```bash
|
| 174 |
-
curl -N -H "Authorization: Bearer <TOKEN>" "https://huggingface.co/api/spaces/Leon4gr45/nova-test/logs/run"
|
| 175 |
-
```
|
| 176 |
-
|
| 177 |
-
Wait up to 300 seconds to see if the deployment has been successful, and if not, fix the errors of deployment, and redeploy and monitor in a cycle until the space is running and reacts to the API endpoints.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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