OpceanAI commited on
Commit
74f2db3
·
verified ·
1 Parent(s): ac8f0cb

Upload DEPLOY.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. DEPLOY.md +89 -0
DEPLOY.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploying PASITA
2
+
3
+ Step-by-step guide to run the Space on your PC or on Hugging Face Spaces.
4
+
5
+ ## Option A: on your PC (CPU or local GPU)
6
+
7
+ 1. Clone the Space:
8
+ ```
9
+ git clone https://huggingface.co/spaces/OpceanAI/PASITA pasita-space
10
+ cd pasita-space
11
+ ```
12
+
13
+ 2. Create a virtual environment and install dependencies:
14
+ ```
15
+ python -m venv .venv
16
+ source .venv/bin/activate
17
+ pip install -r requirements.txt
18
+ pip install "gradio>=6.26" spaces torch
19
+ ```
20
+ On a CPU-only machine, the lighter CPU torch wheel works:
21
+ `pip install torch --index-url https://download.pytorch.org/whl/cpu`
22
+
23
+ 3. (Optional) If the model is private or you want to avoid download limits:
24
+ ```
25
+ hf auth login
26
+ ```
27
+
28
+ 4. Start the app:
29
+ ```
30
+ python app.py
31
+ ```
32
+ Open http://127.0.0.1:7860. Without a local GPU the model runs on CPU (bf16, slower).
33
+ The `spaces` package is a no-op outside ZeroGPU: no code changes are needed.
34
+
35
+ 5. Try the local API (same surface as the Space):
36
+ ```
37
+ curl http://127.0.0.1:7860/v1/health
38
+ curl -X POST http://127.0.0.1:7860/v1/convert -H "Content-Type: application/json" \
39
+ -d '{"text": "Shopping list: keyboard 49.90 EUR; free shipping over 50 EUR."}'
40
+ ```
41
+
42
+ ## Option B: on Hugging Face Spaces (ZeroGPU)
43
+
44
+ 1. Create the Space (ZeroGPU hardware, free for up to 2 Spaces per account):
45
+ ```
46
+ hf repos create OpceanAI/PASITA --type space --sdk gradio --flavor zero-a10g --public
47
+ ```
48
+
49
+ 2. Upload the files:
50
+ ```
51
+ hf upload OpceanAI/PASITA . --repo-type space
52
+ ```
53
+
54
+ 3. The build installs `requirements.txt` and starts `app.py` automatically.
55
+ Check the status:
56
+ ```
57
+ hf spaces info OpceanAI/PASITA --expand runtime
58
+ hf spaces logs OpceanAI/PASITA --tail 100
59
+ ```
60
+
61
+ 4. To change the hardware later:
62
+ ```
63
+ hf spaces settings OpceanAI/PASITA --hardware zero-a10g
64
+ ```
65
+
66
+ ## Using the API from outside
67
+
68
+ Base URL on the Space: `https://opceanai-pasita.hf.space` (local: `http://127.0.0.1:7860`).
69
+
70
+ - OpenAI SDK compatible (`/v1/chat/completions`, streaming included):
71
+
72
+ ```python
73
+ from openai import OpenAI
74
+
75
+ client = OpenAI(base_url="https://opceanai-pasita.hf.space/v1", api_key="not-needed")
76
+ resp = client.chat.completions.create(
77
+ model="pasita-v1",
78
+ messages=[{"role": "user", "content": "<your plain text>"}],
79
+ )
80
+ print(resp.choices[0].message.content)
81
+ ```
82
+
83
+ - Native REST: `POST /v1/convert` with `{"text", "candidates" 1-3, "structured_fallback"}`.
84
+ - Interactive docs: `GET /docs` (Swagger UI, schema at `/openapi.json`).
85
+ - Gradio API and MCP server: `?view=api` and `https://opceanai-pasita.hf.space/gradio_api/mcp/`.
86
+
87
+ Quota notes: on ZeroGPU every visitor consumes their own daily quota (the `x-ip-token` JWT
88
+ from the HF proxy travels through the request headers). Unauthenticated requests get less
89
+ quota; quota errors answer with HTTP 429.