steliosot commited on
Commit
67d5a6d
·
1 Parent(s): ed69e30

Add step-by-step deployment guide

Browse files
Files changed (1) hide show
  1. SETUP_FOR_DUMMIES.md +172 -0
SETUP_FOR_DUMMIES.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ollama Qwen on Hugging Face Space (For Dummies)
2
+
3
+ This is the exact workflow that worked.
4
+
5
+ ## 0) What you are building
6
+
7
+ A Hugging Face **Docker Space** that:
8
+ - starts `ollama`
9
+ - pulls model `qwen2.5:0.5b`
10
+ - serves a simple web app on port `7860`
11
+ - exposes an API endpoint: `POST /api/chat`
12
+
13
+ ---
14
+
15
+ ## 1) One-time setup on your Mac
16
+
17
+ ### 1.1 Install Hugging Face CLI
18
+
19
+ ```bash
20
+ curl -LsSf https://hf.co/cli/install.sh | bash
21
+ ```
22
+
23
+ ### 1.2 Login with token
24
+
25
+ Create token at: https://huggingface.co/settings/tokens
26
+
27
+ Token needs **write access** to your Space repo.
28
+
29
+ ```bash
30
+ hf auth login
31
+ ```
32
+
33
+ Optional check:
34
+
35
+ ```bash
36
+ hf auth whoami
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 2) Clone your Space repo
42
+
43
+ ```bash
44
+ cd /Users/stelios/Desktop
45
+ git clone https://huggingface.co/spaces/steliosot/llm
46
+ cd llm
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 3) Use the working files
52
+
53
+ Copy the final known-good files:
54
+
55
+ ```bash
56
+ cp /Users/stelios/Desktop/hf/{Dockerfile,app.py,start.sh,requirements.txt,README.md} /Users/stelios/Desktop/llm/
57
+ ```
58
+
59
+ Quick check:
60
+
61
+ ```bash
62
+ ls -la /Users/stelios/Desktop/llm
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 4) Commit + push
68
+
69
+ ```bash
70
+ cd /Users/stelios/Desktop/llm
71
+ git add Dockerfile app.py start.sh requirements.txt README.md
72
+ git commit -m "Deploy Ollama Qwen working setup"
73
+ ```
74
+
75
+ If git says remote is ahead:
76
+
77
+ ```bash
78
+ git pull --rebase origin main
79
+ ```
80
+
81
+ Then push:
82
+
83
+ ```bash
84
+ git push origin main
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 5) Wait for Space build
90
+
91
+ - Open your Space page
92
+ - Wait for build + startup logs
93
+ - First run pulls model (`~397 MB`) and can take a few minutes
94
+
95
+ Expected good log signs:
96
+ - `Listening on 127.0.0.1:11434`
97
+ - `Pulling model qwen2.5:0.5b...`
98
+ - `success`
99
+ - `Uvicorn running on http://0.0.0.0:7860`
100
+
101
+ ---
102
+
103
+ ## 6) Test with curl (important)
104
+
105
+ Your app is **FastAPI**, not Gradio.
106
+ Use:
107
+
108
+ ```bash
109
+ curl -sS -X POST "https://steliosot-llm.hf.space/api/chat" \
110
+ -H "Content-Type: application/json" \
111
+ -d '{"prompt":"say hi"}'
112
+ ```
113
+
114
+ If Space is private, add auth header:
115
+
116
+ ```bash
117
+ curl -sS -X POST "https://steliosot-llm.hf.space/api/chat" \
118
+ -H "Authorization: Bearer hf_YOUR_TOKEN" \
119
+ -H "Content-Type: application/json" \
120
+ -d '{"prompt":"say hi"}'
121
+ ```
122
+
123
+ If you enabled app key (`APP_KEY`):
124
+
125
+ ```bash
126
+ curl -sS -X POST "https://steliosot-llm.hf.space/api/chat" \
127
+ -H "Content-Type: application/json" \
128
+ -d '{"prompt":"say hi","key":"my-secret"}'
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 7) Common errors and fixes
134
+
135
+ ### Error: `This version requires zstd`
136
+ Fix: ensure Dockerfile apt install includes `zstd`.
137
+
138
+ ### Error: `ImportError: cannot import name 'HfFolder'`
139
+ Cause: Gradio + huggingface_hub mismatch.
140
+ Fix used: moved to FastAPI app.
141
+
142
+ ### Error: `POST /run/predict 404`
143
+ Expected now. That is a Gradio endpoint.
144
+ Use `POST /api/chat` instead.
145
+
146
+ ### Error: `You are not authorized to push to this repo`
147
+ Token is valid but not allowed for this repo.
148
+ Create/use a token with **explicit write access** to `spaces/steliosot/llm`.
149
+
150
+ ### Error: `git push ... fetch first`
151
+ Run:
152
+
153
+ ```bash
154
+ git pull --rebase origin main
155
+ git push origin main
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 8) Final checklist
161
+
162
+ - [ ] `hf auth whoami` works
163
+ - [ ] files copied to `/Users/stelios/Desktop/llm`
164
+ - [ ] `git push origin main` succeeds
165
+ - [ ] Space logs show Uvicorn on port `7860`
166
+ - [ ] curl to `/api/chat` returns a response
167
+
168
+ You are done when this command returns model text:
169
+
170
+ ```bash
171
+ curl -sS -X POST "https://steliosot-llm.hf.space/api/chat" -H "Content-Type: application/json" -d '{"prompt":"say hi"}'
172
+ ```