Spaces:
Running
Running
milwright
commited on
Commit
·
777f0c6
1
Parent(s):
69cb0c3
update support_docs.py: remove image refs, reorganize structure, fix outdated content
Browse files- support_docs.py +159 -181
support_docs.py
CHANGED
|
@@ -32,100 +32,113 @@ def create_support_docs():
|
|
| 32 |
---
|
| 33 |
""")
|
| 34 |
|
| 35 |
-
with gr.Accordion("📝 Step 1: Configure Your Space", open=False):
|
| 36 |
gr.Markdown("""
|
| 37 |
-
### Configuration
|
| 38 |
-
|
| 39 |
-
#### 1a. Templates & Identity
|
| 40 |
-
Included are several pre-populated templates to get you started with playful (but applied) configurations. Or start with the "None (Custom)" option for a blank slate. Personalize the chat u/i and giving it a name, header (max 60 char) and a markdown description for the `README.md` file, then select from Gradio themes like Default, Soft, Glass, Monochrome, or Base.
|
| 41 |
-
""")
|
| 42 |
|
| 43 |
-
|
| 44 |
-
gr.Image(
|
| 45 |
-
value="img/quick-start-template.png",
|
| 46 |
-
label="Templates & Identity Configuration",
|
| 47 |
-
interactive=True,
|
| 48 |
-
width=600
|
| 49 |
-
)
|
| 50 |
-
|
| 51 |
-
gr.Markdown("""
|
| 52 |
-
#### 1b. Model Configuration
|
| 53 |
-
Craft a system prompt that steers your model's behavior using a well-defined role, context and audience, code of conduct, and/or terms of engagement——think of guardrails as creative constraints. Afterward select a model ID from the menu of options, then experiment with sampling parameters, adjusting temperature (values from 0 to 2) to control response variability and/or setting a token response limit (between 50-4096) to cap output.
|
| 54 |
""")
|
| 55 |
|
| 56 |
-
with gr.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
interactive=False,
|
| 69 |
-
width=400
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
gr.Markdown("""
|
| 73 |
-
#### 1c. Example Prompts
|
| 74 |
-
Add 3 to 5 starter prompts that showcase the purpose and design of your space. These examples appear as quick-start buttons for users to try and meant to help them get started.
|
| 75 |
-
""")
|
| 76 |
|
| 77 |
-
with gr.
|
| 78 |
-
gr.
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
-
with gr.
|
| 100 |
-
gr.
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
with gr.
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
|
| 128 |
-
with gr.Accordion("🗳️ Step
|
| 129 |
gr.Markdown("""
|
| 130 |
### Deployment Package & HuggingFace Space Setup
|
| 131 |
|
|
@@ -134,121 +147,86 @@ def create_support_docs():
|
|
| 134 |
- `requirements.txt`: Python dependencies
|
| 135 |
- `config.json`: Configuration backup
|
| 136 |
- `README.md`: Deployment instructions
|
| 137 |
-
|
| 138 |
-
**Deployment Overview:** Generate Package
|
| 139 |
""")
|
| 140 |
|
| 141 |
-
with gr.Accordion("Step
|
| 142 |
gr.Markdown("""
|
| 143 |
**Generate Deployment Package**
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
|
| 148 |
**Create New Space**
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
| 153 |
""")
|
| 154 |
-
|
| 155 |
-
with gr.Row():
|
| 156 |
-
with gr.Column(scale=1):
|
| 157 |
-
gr.Image(
|
| 158 |
-
value="img/new-space-gradio-blank.png",
|
| 159 |
-
label="Space Creation Form",
|
| 160 |
-
interactive=False,
|
| 161 |
-
width=400
|
| 162 |
-
)
|
| 163 |
-
with gr.Column(scale=1):
|
| 164 |
-
gr.Image(
|
| 165 |
-
value="img/space-hardware.png",
|
| 166 |
-
label="Hardware Selection",
|
| 167 |
-
interactive=False,
|
| 168 |
-
width=400
|
| 169 |
-
)
|
| 170 |
|
| 171 |
-
with gr.Accordion("Step
|
| 172 |
gr.Markdown("""
|
| 173 |
-
**
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
""")
|
| 179 |
-
|
| 180 |
-
with gr.Row():
|
| 181 |
-
with gr.Column(scale=1):
|
| 182 |
-
gr.Image(
|
| 183 |
-
value="img/upload-files.png",
|
| 184 |
-
label="File Upload",
|
| 185 |
-
interactive=False,
|
| 186 |
-
width=400
|
| 187 |
-
)
|
| 188 |
-
with gr.Column(scale=1):
|
| 189 |
-
gr.Image(
|
| 190 |
-
value="img/highlight-files.png",
|
| 191 |
-
label="Files After Upload",
|
| 192 |
-
interactive=False,
|
| 193 |
-
width=400
|
| 194 |
-
)
|
| 195 |
|
| 196 |
-
with gr.Accordion("Step
|
| 197 |
gr.Markdown("""
|
| 198 |
-
**
|
| 199 |
-
|
| 200 |
-
|
|
|
|
| 201 |
|
| 202 |
-
**Required Secret
|
| 203 |
-
- `API_KEY` (or your configured variable name)
|
| 204 |
-
|
| 205 |
-
|
| 206 |
|
| 207 |
-
**Optional Secrets
|
| 208 |
-
-
|
|
|
|
| 209 |
- Get from: https://huggingface.co/settings/tokens
|
| 210 |
-
- Enable *write* permissions
|
| 211 |
-
|
| 212 |
-
- `ACCESS_CODE`: Password protects your Space
|
| 213 |
-
- To enable add secret `ACCESS_CODE` with a custom value
|
| 214 |
-
- To disable delete `ACCESS_CODE` secret entirely from *Variables and Secrets*
|
| 215 |
-
- Share with authorized users only
|
| 216 |
|
| 217 |
-
**
|
| 218 |
-
|
|
|
|
|
|
|
| 219 |
""")
|
| 220 |
-
|
| 221 |
-
with gr.Row():
|
| 222 |
-
|
| 223 |
-
with gr.Column(scale=1):
|
| 224 |
-
gr.Image(
|
| 225 |
-
value="img/go-to-settings.png",
|
| 226 |
-
label="Navigating to Settings",
|
| 227 |
-
interactive=False,
|
| 228 |
-
width=400
|
| 229 |
-
)
|
| 230 |
-
|
| 231 |
-
with gr.Column(scale=1):
|
| 232 |
-
gr.Image(
|
| 233 |
-
value="img/variables-and-secrets.png",
|
| 234 |
-
label="API Key Secret Configuration",
|
| 235 |
-
interactive=False,
|
| 236 |
-
width=400
|
| 237 |
-
)
|
| 238 |
|
| 239 |
-
with gr.Accordion("Step
|
| 240 |
gr.Markdown("""
|
| 241 |
-
**
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
""")
|
| 253 |
|
| 254 |
gr.Markdown("""
|
|
|
|
| 32 |
---
|
| 33 |
""")
|
| 34 |
|
| 35 |
+
with gr.Accordion("📝 Step 1: Configure & Preview Your Space", open=False):
|
| 36 |
gr.Markdown("""
|
| 37 |
+
### Configuration Tab Overview
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
Configure your assistant through various sections in the Configuration tab, then test it in the Preview tab before generating your deployment package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
""")
|
| 41 |
|
| 42 |
+
with gr.Accordion("Step 1a: Templates & Identity", open=False):
|
| 43 |
+
gr.Markdown("""
|
| 44 |
+
**Quick Start Templates**
|
| 45 |
+
- Choose from pre-configured academic templates (Socratic Research Chat, STEM Adventure Games, etc.)
|
| 46 |
+
- Or select "None (Custom)" for a blank slate
|
| 47 |
+
|
| 48 |
+
**Space Identity**
|
| 49 |
+
- **Assistant Name**: Give your assistant a memorable name
|
| 50 |
+
- **Tagline**: Brief description (max 60 characters) for HuggingFace YAML frontmatter
|
| 51 |
+
- **Description**: Full markdown description for the README
|
| 52 |
+
- **Theme**: Select from Gradio themes (Default, Soft, Glass, Monochrome, Base)
|
| 53 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
with gr.Accordion("Step 1b: System Configuration", open=False):
|
| 56 |
+
gr.Markdown("""
|
| 57 |
+
**System Prompt**
|
| 58 |
+
- Define your assistant's role, context, and behavior
|
| 59 |
+
- Set guardrails and creative constraints
|
| 60 |
+
- Specify audience and terms of engagement
|
| 61 |
+
|
| 62 |
+
**Model Selection**
|
| 63 |
+
- Choose from available models (Gemini, Claude, GPT, Mistral, etc.)
|
| 64 |
+
- Or enter a custom model ID
|
| 65 |
+
|
| 66 |
+
**Language Support**
|
| 67 |
+
- Configure language through system prompt instructions
|
| 68 |
+
- Assistant can be instructed to respond exclusively in any language
|
| 69 |
+
- See "Language Learning Partner" template for Italian example
|
| 70 |
+
|
| 71 |
+
**Sampling Parameters**
|
| 72 |
+
- **Temperature** (0-2): Controls response variability
|
| 73 |
+
- **Max Tokens** (50-4096): Limits response length
|
| 74 |
+
""")
|
| 75 |
|
| 76 |
+
with gr.Accordion("Step 1c: Example Prompts", open=False):
|
| 77 |
+
gr.Markdown("""
|
| 78 |
+
**Example Prompts**
|
| 79 |
+
- Add 3-5 starter prompts that showcase your assistant's capabilities
|
| 80 |
+
- These appear as quick-start buttons for users
|
| 81 |
+
- Help users understand how to interact with your assistant
|
| 82 |
+
- Use the ➕/➖ buttons to add or remove examples
|
| 83 |
+
""")
|
| 84 |
|
| 85 |
+
with gr.Accordion("Step 1d: URL Grounding", open=False):
|
| 86 |
+
gr.Markdown("""
|
| 87 |
+
**Grounding URLs**
|
| 88 |
+
- Add up to 10 reference URLs to provide context
|
| 89 |
+
- **Primary Sources (URLs 1-2)**: Always loaded, up to 8000 characters each
|
| 90 |
+
- **Secondary Sources (URLs 3+)**: Supplementary context, up to 2500 characters each
|
| 91 |
+
- URLs are fetched and included in the system prompt
|
| 92 |
+
- Assistant will cite specific URLs when using grounded information
|
| 93 |
+
- Use the ➕/➖ buttons to manage URLs
|
| 94 |
+
""")
|
| 95 |
+
|
| 96 |
+
with gr.Accordion("Step 1e: API Configuration", open=False):
|
| 97 |
+
gr.Markdown("""
|
| 98 |
+
**Required Secrets**
|
| 99 |
+
- **API_KEY**: Your OpenRouter API key (must start with `sk-or-`)
|
| 100 |
+
- Get from: https://openrouter.ai/keys
|
| 101 |
+
- Configure in HuggingFace Space settings
|
| 102 |
+
|
| 103 |
+
**Optional Secrets**
|
| 104 |
+
- **HF_TOKEN** (Recommended): Enables configuration editor in deployed Space
|
| 105 |
+
- Get from: https://huggingface.co/settings/tokens
|
| 106 |
+
- Select "write" permissions when creating
|
| 107 |
+
- Allows updating configuration without redeployment
|
| 108 |
+
|
| 109 |
+
- **ACCESS_CODE**: Password-protect your Space
|
| 110 |
+
- Set any password value
|
| 111 |
+
- Users will need this code to access
|
| 112 |
+
- Leave unset for public access
|
| 113 |
+
""")
|
| 114 |
+
|
| 115 |
+
with gr.Accordion("Step 1f: Upload Configuration", open=False):
|
| 116 |
+
gr.Markdown("""
|
| 117 |
+
**Upload Existing Configuration**
|
| 118 |
+
- Have a previous `config.json` file?
|
| 119 |
+
- Use the "Upload Configuration" accordion
|
| 120 |
+
- Drag and drop or click to upload
|
| 121 |
+
- All settings will be restored automatically
|
| 122 |
+
""")
|
| 123 |
|
| 124 |
+
with gr.Accordion("Step 1g: Preview Your Assistant", open=False):
|
| 125 |
+
gr.Markdown("""
|
| 126 |
+
**Testing in Preview Tab**
|
| 127 |
+
- Click "💬 Preview Configuration" to prepare your assistant
|
| 128 |
+
- Switch to the Preview tab
|
| 129 |
+
- Test with real queries and example prompts
|
| 130 |
+
- Upload files if file upload is enabled
|
| 131 |
+
- Export conversation history as markdown
|
| 132 |
+
|
| 133 |
+
**Preview Features**
|
| 134 |
+
- Real-time API responses (requires API key in environment)
|
| 135 |
+
- Grounding context from configured URLs
|
| 136 |
+
- Language-specific responses
|
| 137 |
+
- File upload handling
|
| 138 |
+
- Conversation export
|
| 139 |
+
""")
|
| 140 |
|
| 141 |
+
with gr.Accordion("🗳️ Step 2: Generate & Deploy", open=True):
|
| 142 |
gr.Markdown("""
|
| 143 |
### Deployment Package & HuggingFace Space Setup
|
| 144 |
|
|
|
|
| 147 |
- `requirements.txt`: Python dependencies
|
| 148 |
- `config.json`: Configuration backup
|
| 149 |
- `README.md`: Deployment instructions
|
| 150 |
+
|
| 151 |
+
**Deployment Overview:** Generate Package → Create Space → Upload Files → Configure Secrets → Monitor Build
|
| 152 |
""")
|
| 153 |
|
| 154 |
+
with gr.Accordion("Step 2a: Generate & Create Space", open=False):
|
| 155 |
gr.Markdown("""
|
| 156 |
**Generate Deployment Package**
|
| 157 |
+
1. Click "🗳️ Generate Deployment Package" in Configuration tab
|
| 158 |
+
2. Download the generated ZIP file
|
| 159 |
+
3. Extract files: `app.py`, `config.json`, `requirements.txt`, `README.md`
|
| 160 |
|
| 161 |
**Create New Space**
|
| 162 |
+
1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
|
| 163 |
+
2. Click "Create new Space"
|
| 164 |
+
3. Name your Space
|
| 165 |
+
4. Select **Gradio** SDK
|
| 166 |
+
5. Choose **Blank** template
|
| 167 |
+
6. Select hardware (CPU Basic is free)
|
| 168 |
+
7. Click "Create Space"
|
| 169 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
+
with gr.Accordion("Step 2b: Upload Files", open=False):
|
| 172 |
gr.Markdown("""
|
| 173 |
+
**Upload Project Files**
|
| 174 |
+
1. Navigate to the **Files** tab in your new Space
|
| 175 |
+
2. Click "Add file" → "Upload files"
|
| 176 |
+
3. Select all 4 files from your extracted package:
|
| 177 |
+
- `README.md`
|
| 178 |
+
- `app.py`
|
| 179 |
+
- `config.json`
|
| 180 |
+
- `requirements.txt`
|
| 181 |
+
4. Commit directly to main branch
|
| 182 |
+
5. Your Space will automatically start building
|
| 183 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
with gr.Accordion("Step 2c: Configure Secrets", open=False):
|
| 186 |
gr.Markdown("""
|
| 187 |
+
**Navigate to Settings**
|
| 188 |
+
1. Click the **Settings** tab in your Space
|
| 189 |
+
2. Find **Variables and secrets** section
|
| 190 |
+
3. Click **New secret**
|
| 191 |
|
| 192 |
+
**Add Required Secret**
|
| 193 |
+
- **Name**: `API_KEY` (or your configured variable name)
|
| 194 |
+
- **Value**: Your OpenRouter API key
|
| 195 |
+
- Must start with `sk-or-`
|
| 196 |
|
| 197 |
+
**Add Optional Secrets (if desired)**
|
| 198 |
+
- **HF_TOKEN**: Your HuggingFace token with write permissions
|
| 199 |
+
- Enables the configuration editor in your Space
|
| 200 |
- Get from: https://huggingface.co/settings/tokens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
+
- **ACCESS_CODE**: Any password value
|
| 203 |
+
- Restricts access to authorized users
|
| 204 |
+
- Do NOT set an empty value
|
| 205 |
+
- Either set a code or don't create the secret
|
| 206 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
+
with gr.Accordion("Step 2d: Verify & Iterate", open=False):
|
| 209 |
gr.Markdown("""
|
| 210 |
+
**Monitor Build Process**
|
| 211 |
+
1. Return to the **App** tab
|
| 212 |
+
2. Watch for "Building..." status
|
| 213 |
+
3. Check build logs for any errors
|
| 214 |
+
4. Wait 1-3 minutes for completion
|
| 215 |
+
5. Space will show "Running" when ready
|
| 216 |
+
|
| 217 |
+
**Test Your Deployment**
|
| 218 |
+
1. Try the example prompts
|
| 219 |
+
2. Test different types of queries
|
| 220 |
+
3. Verify grounding URLs are working
|
| 221 |
+
4. Check language responses (if configured)
|
| 222 |
+
|
| 223 |
+
**Iterate Configuration (with HF_TOKEN)**
|
| 224 |
+
1. Go to ⚙️ Configuration tab in your Space
|
| 225 |
+
2. Enter your HF_TOKEN to authenticate
|
| 226 |
+
3. Modify settings as needed
|
| 227 |
+
4. Click "Save Configuration"
|
| 228 |
+
5. Space will automatically rebuild
|
| 229 |
+
6. Test new configuration
|
| 230 |
""")
|
| 231 |
|
| 232 |
gr.Markdown("""
|