milwright commited on
Commit
ef93bca
Β·
1 Parent(s): 72ef28d

Update support documentation with visual deployment workflow

Browse files

- Restructure HuggingFace deployment section with step-by-step visual guides
- Integrate img directory screenshots for each deployment phase
- Condense redundant accordion sections into streamlined Configuration Guide
- Add README customization section with YAML frontmatter details
- Simplify troubleshooting to focus on most common issues
- Enhanced with configuration status indicators (βœ…βŒπŸ”„)

Files changed (1) hide show
  1. support_docs.py +192 -171
support_docs.py CHANGED
@@ -31,221 +31,242 @@ def create_support_docs():
31
  - Basic AI chatbot knowledge
32
  """)
33
 
34
- with gr.Accordion("βš™οΈ Basic Configuration", open=False):
35
  gr.Markdown("""
36
  ### Essential Settings
37
 
38
- **Space Title & Description** - Name and purpose
39
 
40
  **Model Selection:**
41
  - **Gemini 2.0 Flash** - Fast, reliable (recommended)
42
  - **Gemma 3 27B** - Open-source, cost-effective
43
  - **Claude 3.5 Haiku** - Advanced reasoning
44
 
45
- **API Key Variable** - Default: `OPENROUTER_API_KEY`
46
-
47
- **Access Code** - Optional student protection
48
- """)
49
-
50
- with gr.Accordion("πŸ€– Assistant Setup", open=False):
51
- gr.Markdown("""
52
- ### System Prompt & Templates
53
-
54
- **Templates (Easy Start):**
55
- - **Custom** - Write your own
56
  - **Research Template** - Academic work, citations, fact-checking
57
  - **Socratic Template** - Teaching through questions, critical thinking
58
 
59
- **Tips:**
60
- - Be clear about the assistant's role
61
- - Mention your target audience
62
- - Define specific behavior and tone
63
- """)
64
-
65
- with gr.Accordion("πŸ’¬ Example Prompts", open=False):
66
- gr.Markdown("""
67
- ### Quick Start Examples
68
-
69
- **Guidelines:** One prompt per line, under 100 characters, show capabilities
70
 
71
- **Course Assistant:**
72
- ```
73
- Can you explain [topic] in simple terms?
74
- Help me prepare for the midterm exam
75
- What are the key concepts I should focus on?
76
- ```
77
 
78
- **Research Assistant:**
79
- ```
80
- Analyze this source: [URL]
81
- Help me fact-check this claim
82
- What citation format should I use?
83
- ```
84
- """)
85
-
86
- with gr.Accordion("πŸ”§ Settings & Configuration", open=False):
87
- gr.Markdown("""
88
- ### Configuration Structure
89
-
90
- **Main Fields:**
91
- - Space Title & Description
92
- - Model Selection
93
- - API Key Variable
94
- - Access Code (optional)
95
-
96
- **Assistant Setup:**
97
- - System Prompt
98
- - Template Selection
99
- - URL Grounding (2-4 URLs)
100
- - Example Prompts
101
-
102
- **Advanced Settings:**
103
- - Temperature (0.0-2.0)
104
- - Max Tokens (50-4096)
105
-
106
- **URL Grounding (Static)**
107
- - 2-4 URLs for consistent context
108
- - Content cached during generation
109
- - Great for syllabi, policies, references
110
- """)
111
-
112
- with gr.Accordion("πŸŽ›οΈ Advanced Settings", open=False):
113
- gr.Markdown("""
114
- ### Model Parameters
115
-
116
- **Temperature (0.0 - 2.0)**
117
- - **0.0-0.3**: Focused, deterministic
118
- - **0.4-0.7**: Balanced (recommended)
119
- - **0.8-1.2**: Creative, varied
120
- - **1.3-2.0**: Highly creative
121
-
122
- **Max Response Tokens (50-4096)**
123
- - **50-200**: Short answers
124
- - **200-750**: Medium (recommended: 750)
125
- - **750-1500**: Detailed explanations
126
- - **1500+**: Extended analysis
127
-
128
- **Token Notes:**
129
- - Includes input (prompt + context) and output
130
- - URLs increase input tokens
131
- - Consider costs with high limits
132
  """)
133
 
134
- with gr.Accordion("πŸ”¬ Preview Tab Usage", open=False):
135
  gr.Markdown("""
136
- ### Testing Before Deployment
137
-
138
- **Preview Features:**
139
- - Real API integration
140
- - Configuration display
141
- - URL testing (up to 4 URLs)
142
- - Chat export
143
- - Clear function
144
 
145
  **Preview Steps:**
146
  1. Complete Configuration tab setup
147
  2. Click "Preview Deployment Package"
148
- 3. Test chat interface
149
- 4. Test URL grounding
150
- 5. Export conversations for analysis
151
 
152
- **Requirements:**
153
- - Set `OPENROUTER_API_KEY` environment variable
154
- - Without API key: shows configuration only
155
 
156
- **Best Practices:**
157
- - Test various query types
158
- - Verify URL grounding works
159
- - Confirm system prompt behavior
160
- - Export conversations as documentation
161
  """)
162
 
163
- with gr.Accordion("πŸš€ Deployment Process", open=False):
164
  gr.Markdown("""
165
- ### Deployment Guide
166
 
167
- **Steps:** Generate β†’ Create Space β†’ Add Secrets β†’ Go Live
168
-
169
- **1. Generate & Upload**
170
- - Click "Generate Deployment Package", download zip
171
- - Create Space at huggingface.co/spaces (Gradio SDK)
172
- - Upload `app.py` and `requirements.txt`
173
-
174
- **2. Add API Key**
175
- - Settings β†’ Variables and secrets β†’ New secret
176
- - Name: `OPENROUTER_API_KEY`
177
- - Value: Your API key (starts with `sk-or-`)
178
 
179
- **3. Access Control (Optional)**
180
- - Add secret: `SPACE_ACCESS_CODE`
181
- - Students enter code to access chatbot
182
- - Delete secret to disable protection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  """)
184
 
185
- # Add the secret configuration image (flush left)
186
  with gr.Row():
187
- with gr.Column(scale=1):
188
  gr.Image(
189
- value="https://drive.google.com/uc?export=view&id=1z67BZrYlJkpvHJ0Dp6vvIWAkN2iwUxCv",
190
- label="HuggingFace Secret Configuration Interface",
191
- show_label=False,
192
  interactive=False,
193
- width=400,
194
- height=300,
195
  container=False
196
  )
197
- with gr.Column(scale=2):
198
- gr.Markdown("""
199
- **Secret Configuration Interface:**
200
- - **Name**: Your variable name (e.g., `OPENROUTER_API_KEY`)
201
- - **Value**: Your API key or access code
202
- - **Add** button to save the secret
203
-
204
- **Required Secrets:**
205
- - `OPENROUTER_API_KEY`: Your API key (always required)
206
- - `SPACE_ACCESS_CODE`: Access code (only if using access control)
207
- """)
208
-
209
- gr.Markdown("""
210
- **4. Deploy & Test**
211
- - Wait for build (1-2 minutes)
212
- - Test with example prompts
213
- - Share URL when working
214
- """)
215
 
216
  with gr.Accordion("πŸ”§ Troubleshooting", open=False):
217
  gr.Markdown("""
218
  ### Common Issues and Solutions
219
 
220
- **"Please set your API key" message**
221
- - Check that you added the API key secret in Space settings
222
- - Verify the secret name matches your configuration
223
- - Ensure your OpenRouter account has credits
224
-
225
- **Building Failed**
226
- - Check `requirements.txt` formatting (no extra spaces/characters)
227
- - Verify all required dependencies are listed
228
- - Try reuploading files if build gets stuck
229
-
230
- **Error 401 (Unauthorized)**
231
- - Invalid API key or incorrect secret name
232
- - Check OpenRouter account status and credits
233
  - Regenerate API key if needed
234
 
235
- **Error 429 (Too Many Requests)**
236
- - Rate limit exceeded
237
- - Wait a few minutes before trying again
238
- - Consider upgrading OpenRouter plan for higher limits
239
 
240
- **Access code not working**
241
- - Verify `SPACE_ACCESS_CODE` secret is set correctly
242
- - Check for typos in the access code
243
- - Case-sensitive matching
244
 
245
- **URLs not fetching content**
246
- - Check URLs are publicly accessible
247
- - Some sites block automated requests
248
- - Verify dynamic URL fetching is enabled if needed
249
  """)
250
 
251
  with gr.Accordion("πŸ“š Additional Resources", open=False):
 
31
  - Basic AI chatbot knowledge
32
  """)
33
 
34
+ with gr.Accordion("βš™οΈ Configuration Guide", open=False):
35
  gr.Markdown("""
36
  ### Essential Settings
37
 
38
+ **Space Title & Description** - Name and purpose for your assistant
39
 
40
  **Model Selection:**
41
  - **Gemini 2.0 Flash** - Fast, reliable (recommended)
42
  - **Gemma 3 27B** - Open-source, cost-effective
43
  - **Claude 3.5 Haiku** - Advanced reasoning
44
 
45
+ **System Prompt & Templates:**
46
+ - **Custom** - Write your own specific instructions
 
 
 
 
 
 
 
 
 
47
  - **Research Template** - Academic work, citations, fact-checking
48
  - **Socratic Template** - Teaching through questions, critical thinking
49
 
50
+ **URL Grounding (2-4 URLs)** - Static content for consistent context (syllabi, policies, references)
 
 
 
 
 
 
 
 
 
 
51
 
52
+ **Example Prompts Guidelines:**
53
+ - One prompt per line, under 100 characters
54
+ - Show assistant capabilities
55
+ - Examples: "Explain [topic] in simple terms", "Help prepare for exam", "Analyze this source: [URL]"
 
 
56
 
57
+ **Advanced Parameters:**
58
+ - **Temperature (0.0-2.0)**: 0.0-0.3 (focused), 0.4-0.7 (balanced), 0.8+ (creative)
59
+ - **Max Tokens (50-4096)**: 750 recommended for balanced responses
60
+ - **API Key Variable**: Default `OPENROUTER_API_KEY`
61
+ - **Access Code**: Optional student protection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  """)
63
 
64
+ with gr.Accordion("πŸ”¬ Preview & Testing", open=False):
65
  gr.Markdown("""
66
+ ### Pre-Deployment Testing
 
 
 
 
 
 
 
67
 
68
  **Preview Steps:**
69
  1. Complete Configuration tab setup
70
  2. Click "Preview Deployment Package"
71
+ 3. Test chat interface and URL grounding
72
+ 4. Export conversations for documentation
 
73
 
74
+ **Requirements:** Set `OPENROUTER_API_KEY` environment variable for full testing
 
 
75
 
76
+ **Test Checklist:**
77
+ - Various query types and assistant responses
78
+ - URL grounding functionality (if enabled)
79
+ - System prompt behavior matches expectations
80
+ - Example prompts work correctly
81
  """)
82
 
83
+ with gr.Accordion("πŸš€ HuggingFace Space Deployment", open=False):
84
  gr.Markdown("""
85
+ ### Complete Deployment Workflow
86
 
87
+ **Overview:** Generate Package β†’ Create Space β†’ Upload Files β†’ Configure Secrets β†’ Monitor Build β†’ Verify Configuration
88
+ """)
 
 
 
 
 
 
 
 
 
89
 
90
+ with gr.Accordion("Step 1: Generate & Create Space", open=False):
91
+ gr.Markdown("""
92
+ **1.1 Generate Deployment Package**
93
+ - Click "Generate Deployment Package" and download zip
94
+ - Extract files: `app.py`, `config.json`, `requirements.txt`, `README.md`
95
+
96
+ **1.2 Create New Space**
97
+ - Go to [huggingface.co/spaces](https://huggingface.co/spaces)
98
+ - Click "New Space"
99
+ - Choose Gradio SDK
100
+ - Select hardware (CPU Basic is free)
101
+ """)
102
+
103
+ with gr.Row():
104
+ with gr.Column(scale=1):
105
+ gr.Image(
106
+ value="img/img 2/image-25.png",
107
+ label="Space Creation Form",
108
+ show_label=True,
109
+ interactive=False,
110
+ width=400,
111
+ container=False
112
+ )
113
+ with gr.Column(scale=1):
114
+ gr.Image(
115
+ value="img/img 2/image-24.png",
116
+ label="Hardware Selection",
117
+ show_label=True,
118
+ interactive=False,
119
+ width=400,
120
+ container=False
121
+ )
122
+
123
+ with gr.Accordion("Step 2: Upload Files", open=False):
124
+ gr.Markdown("""
125
+ **2.1 Upload Project Files**
126
+ - Navigate to Files tab
127
+ - Click "Upload files" or drag and drop
128
+ - Upload: `app.py`, `config.json`, `requirements.txt`
129
+ - Commit directly to main branch
130
+ """)
131
+
132
+ with gr.Row():
133
+ with gr.Column(scale=1):
134
+ gr.Image(
135
+ value="img/img 2/image-13.png",
136
+ label="File Upload Interface",
137
+ show_label=True,
138
+ interactive=False,
139
+ width=400,
140
+ container=False
141
+ )
142
+ with gr.Column(scale=1):
143
+ gr.Image(
144
+ value="img/img 2/image-29.png",
145
+ label="Files After Upload",
146
+ show_label=True,
147
+ interactive=False,
148
+ width=400,
149
+ container=False
150
+ )
151
+
152
+ with gr.Accordion("Step 3: Configure API Secrets", open=False):
153
+ gr.Markdown("""
154
+ **3.1 Add Required Secrets**
155
+ - Go to Settings β†’ Variables and secrets
156
+ - Click "New secret"
157
+ - **Required:** `OPENROUTER_API_KEY` with your API key
158
+ - **Optional:** `SPACE_ACCESS_CODE` for access control
159
+ """)
160
+
161
+ with gr.Row():
162
+ with gr.Column(scale=1):
163
+ gr.Image(
164
+ value="img/img 2/image-7.png",
165
+ label="API Key Secret Configuration",
166
+ show_label=True,
167
+ interactive=False,
168
+ width=400,
169
+ container=False
170
+ )
171
+ with gr.Column(scale=1):
172
+ gr.Image(
173
+ value="img/img 2/image-9.png",
174
+ label="Settings Variables and Secrets",
175
+ show_label=True,
176
+ interactive=False,
177
+ width=400,
178
+ container=False
179
+ )
180
+
181
+ with gr.Accordion("Step 4: Monitor Build & Verify Configuration", open=False):
182
+ gr.Markdown("""
183
+ **4.1 Build Monitoring**
184
+ - Space will show "Building..." status
185
+ - Monitor build logs for errors
186
+ - Wait 1-3 minutes for completion
187
+
188
+ **4.2 Configuration Verification**
189
+ - Check Configuration Status panel
190
+ - API Key should show "Configured and valid" βœ…
191
+ - Test chat interface with example prompts
192
+ """)
193
+
194
+ with gr.Row():
195
+ with gr.Column(scale=1):
196
+ gr.Image(
197
+ value="img/img 2/image-1.png",
198
+ label="Build Process",
199
+ show_label=True,
200
+ interactive=False,
201
+ width=400,
202
+ container=False
203
+ )
204
+ with gr.Column(scale=1):
205
+ gr.Image(
206
+ value="img/img 2/image-8.png",
207
+ label="Successful Configuration",
208
+ show_label=True,
209
+ interactive=False,
210
+ width=400,
211
+ container=False
212
+ )
213
+
214
+ gr.Markdown("""
215
+ **Configuration Status Indicators:**
216
+ - ❌ Red X: API key not configured or invalid
217
+ - βœ… Green check: All settings configured correctly
218
+ - πŸ”„ Building: Space is updating with new changes
219
+ """)
220
+
221
+ with gr.Accordion("πŸ“ README Customization", open=False):
222
+ gr.Markdown("""
223
+ ### Space Metadata and Configuration
224
+
225
+ **YAML Frontmatter in README.md:**
226
+ - `sdk: gradio` - Specifies Gradio framework
227
+ - `app_file: app.py` - Main application file
228
+ - `license: mit` or `gpl-3.0` - License selection
229
+ - Space description and usage instructions
230
+
231
+ **Customization Options:**
232
+ - Update Space description and title
233
+ - Add usage instructions for students
234
+ - Include course-specific information
235
+ - Link to additional resources
236
  """)
237
 
 
238
  with gr.Row():
239
+ with gr.Column():
240
  gr.Image(
241
+ value="img/img 2/image-2.png",
242
+ label="README.md Editing Interface",
243
+ show_label=True,
244
  interactive=False,
245
+ width=500,
 
246
  container=False
247
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  with gr.Accordion("πŸ”§ Troubleshooting", open=False):
250
  gr.Markdown("""
251
  ### Common Issues and Solutions
252
 
253
+ **Configuration Status Shows Red X:**
254
+ - Verify API key secret name matches configuration (usually `OPENROUTER_API_KEY`)
255
+ - Check OpenRouter account has credits
 
 
 
 
 
 
 
 
 
 
256
  - Regenerate API key if needed
257
 
258
+ **Build Failed:**
259
+ - Check `requirements.txt` formatting (no extra spaces)
260
+ - Try reuploading files if build gets stuck
261
+ - Monitor build logs for specific errors
262
 
263
+ **API Errors:**
264
+ - **401 Unauthorized**: Invalid API key or incorrect secret name
265
+ - **429 Rate Limited**: Wait a few minutes, consider upgrading OpenRouter plan
 
266
 
267
+ **Access Issues:**
268
+ - **Access code not working**: Verify `SPACE_ACCESS_CODE` secret is set correctly (case-sensitive)
269
+ - **URLs not fetching**: Check URLs are publicly accessible, some sites block automated requests
 
270
  """)
271
 
272
  with gr.Accordion("πŸ“š Additional Resources", open=False):