milwright commited on
Commit
b0cbc79
·
verified ·
1 Parent(s): 897b428

Delete CLAUDE.md

Browse files
Files changed (1) hide show
  1. CLAUDE.md +0 -192
CLAUDE.md DELETED
@@ -1,192 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- **Chat UI Helper** is a Gradio-based configuration and deployment tool for creating custom AI chat interfaces on HuggingFace Spaces. It serves as middleware that helps educators and developers generate secure, configurable chat assistants with OpenRouter API integration and web scraping capabilities.
8
-
9
- ## Key Commands
10
-
11
- ### Development
12
- ```bash
13
- # Install dependencies
14
- pip install -r requirements.txt
15
-
16
- # Run application locally (launches on default Gradio port)
17
- python app.py
18
-
19
- # Run faculty authentication tests
20
- pytest test_faculty_password.py -v
21
-
22
- # Run specific test class
23
- pytest test_faculty_password.py::TestFacultyPasswordAuthentication -v
24
-
25
- # Run with coverage report
26
- pytest test_faculty_password.py --cov=secure_config_editor --cov-report=html
27
- ```
28
-
29
- ### Virtual Environment
30
- ```bash
31
- # Project uses Python 3.11
32
- source venv311/bin/activate # or venv/bin/activate
33
- ```
34
-
35
- ## Architecture Overview
36
-
37
- ### Three-Tab Interface Structure
38
- - **app.py** (1,942 lines): Main entry point with sophisticated three-tab Gradio interface
39
- - **Configuration Tab**: Assistant creation, template selection, deployment package generation
40
- - **Preview Tab**: Real-time testing sandbox with OpenRouter API integration
41
- - **Support Tab**: Documentation, guides, and expert chat support
42
-
43
- ### Key Components and Their Relationships
44
- - **secure_config_editor.py**: Faculty-only configuration editor with password protection
45
- - **support_docs.py**: Documentation module with accordion-style help and conversation export
46
- - **test_faculty_password.py**: Comprehensive test suite covering authentication, security scenarios, and edge cases
47
- - **simplified_ui_config.py**: User-friendly configuration components with reduced complexity
48
- - **ui_simplification_guide.md**: Implementation guide for less intimidating UI patterns
49
-
50
- ### Template-Based Space Generation System
51
- The application generates complete, self-contained HuggingFace Space deployments via `SPACE_TEMPLATE` containing:
52
- - Customized `app.py` with modern Gradio 5.x ChatInterface
53
- - Runtime `config.json` with all user configurations
54
- - Complete `requirements.txt` with exact dependency versions
55
- - Built-in access control and URL grounding capabilities
56
-
57
- ### Multi-Layer Security Architecture
58
- 1. **Faculty Authentication**: `FACULTY_CONFIG_PASSWORD` environment variable controls configuration editing
59
- 2. **Student Access Control**: Optional `SPACE_ACCESS_CODE` for general space access
60
- 3. **Configuration Locking**: Exam-mode freeze prevents changes during assessments
61
- 4. **Authentication State Management**: Session-based access control with proper validation
62
-
63
- ## URL Grounding System Architecture
64
-
65
- ### Two-Tier URL Processing
66
- - **Primary URLs (2)**: Highest priority sources (syllabus, main textbook) processed first
67
- - **Secondary URLs (8)**: Additional context sources for enhanced responses
68
- - **Dynamic URL Fetching**: Real-time content extraction from URLs mentioned in conversations
69
- - **Global Caching**: `url_content_cache` prevents re-crawling identical URL sets
70
-
71
- ### Web Scraping Implementation Details
72
- - Uses `requests` + `beautifulsoup4` with enhanced headers for compatibility
73
- - Smart content cleaning: removes scripts, styles, navigation, forms
74
- - Preferential main content extraction (`<main>`, `<article>`, content divs)
75
- - Timeout handling (15s limit) with graceful error messages
76
- - Smart text truncation at sentence boundaries (4000 char limit)
77
-
78
- ## Template System and Model Support
79
-
80
- ### Built-in Assistant Templates
81
- - **Research Template**: Academic literature search and analysis with dynamic URL fetching enabled
82
- - **Socratic Template**: Pedagogical questioning approach for educational use
83
- - **Mathematics Template**: LaTeX-enabled mathematical education with step-by-step problem solving
84
- - **Custom Templates**: User-defined system prompts with flexible configuration
85
-
86
- ### Template Development Pattern
87
- When adding new templates to the system:
88
- 1. Add template choice to `template_selector` choices in the Configuration Tab
89
- 2. Create template prompt variable in `toggle_template()` function (matching length/detail of existing templates)
90
- 3. Add template prompt to the caching logic check (prevents accidental caching of template prompts)
91
- 4. Add elif clause in `toggle_template()` with the template logic and appropriate dynamic URL setting
92
- 5. Templates should be pedagogically focused and include specific formatting instructions when relevant
93
-
94
- ### Supported OpenRouter Models
95
- ```python
96
- MODELS = [
97
- "google/gemini-2.0-flash-001", # Fast, reliable, general tasks
98
- "google/gemma-3-27b-it", # High-performance open model
99
- "anthropic/claude-3.5-sonnet", # Superior LaTeX rendering and mathematical reasoning
100
- "anthropic/claude-3.5-haiku", # Complex reasoning and analysis
101
- "openai/gpt-4o-mini-search-preview", # Balanced with search capabilities
102
- # ... additional models in app.py MODELS list
103
- ]
104
- ```
105
-
106
- ## Important Configuration Details
107
-
108
- ### Environment Variables for Generated Spaces
109
- - `OPENROUTER_API_KEY`: LLM API access (configurable variable name)
110
- - `FACULTY_CONFIG_PASSWORD`: Faculty configuration access
111
- - `SPACE_ACCESS_CODE`: Optional student access control
112
- - `CONFIG_EDIT_TOKEN`: Alternative token-based authentication
113
-
114
- ### Generated Deployment Package Structure
115
- ```
116
- ai_assistant_space.zip/
117
- ├── app.py # 684-line ChatInterface with access control
118
- ├── config.json # Complete runtime configuration backup
119
- └── requirements.txt # gradio>=5.38.0, requests>=2.32.3, beautifulsoup4>=4.12.3
120
- ```
121
-
122
- ### Configuration JSON Schema
123
- ```json
124
- {
125
- "name": "AI Assistant",
126
- "system_prompt": "Behavioral instructions with grounding context",
127
- "model": "google/gemini-2.0-flash-001",
128
- "api_key_var": "OPENROUTER_API_KEY",
129
- "temperature": 0.7,
130
- "max_tokens": 750,
131
- "examples": "['Example 1', 'Example 2']",
132
- "grounding_urls": "[\"https://...\"]",
133
- "enable_dynamic_urls": true,
134
- "locked": false,
135
- "last_modified_by": "faculty"
136
- }
137
- ```
138
-
139
- ## Testing and Quality Assurance
140
-
141
- ### Faculty Authentication Test Coverage
142
- `test_faculty_password.py` includes:
143
- - **Password Validation**: Correct/incorrect credentials, case sensitivity, special characters
144
- - **Security Scenarios**: SQL injection attempts, brute force protection, environment manipulation
145
- - **Configuration Locking**: Lock behavior and access prevention
146
- - **Edge Cases**: Empty passwords, None values, whitespace handling
147
- - **Manual Testing Procedures**: UI flow verification and session management
148
-
149
- ### Running the Full Test Suite
150
- ```bash
151
- # Automated tests with verbose output
152
- pytest test_faculty_password.py -v
153
-
154
- # Generate test report with manual procedures
155
- python test_faculty_password.py
156
-
157
- # Coverage analysis
158
- pytest test_faculty_password.py --cov=secure_config_editor --cov-report=html
159
- ```
160
-
161
- ## UI Simplification System
162
-
163
- ### User-Friendly Configuration Options
164
- The `simplified_ui_config.py` provides:
165
- - **Simplified Variable Names**: "MY_API_KEY" instead of "OPENROUTER_API_KEY"
166
- - **Progressive Disclosure**: Advanced options hidden by default
167
- - **Compact Layout**: Mobile-responsive design with minimal vertical space
168
- - **Template-First Approach**: Quick-start templates prominently displayed
169
- - **Friendly Labels**: "Assistant Instructions" instead of "System Prompt"
170
-
171
- ### Implementation Pattern for UI Changes
172
- 1. Create user-friendly components in `simplified_ui_config.py`
173
- 2. Map friendly names to technical equivalents in `generate_zip()`
174
- 3. Maintain backward compatibility with existing deployments
175
- 4. Test across desktop, tablet, and mobile viewports
176
-
177
- ## Critical Architecture Patterns
178
-
179
- ### State Management Across Tabs
180
- - `sandbox_state` and `preview_config_state` enable cross-tab functionality
181
- - Configuration flows: Config Tab → Preview Tab → Deployment Package
182
- - Preview system uses real OpenRouter API calls for accurate testing
183
-
184
- ### Error Handling and User Feedback
185
- - Comprehensive API error handling with user-friendly messages
186
- - Rate limiting and timeout management
187
- - Progressive enhancement: works without API key but shows limitations
188
-
189
- ### Security-First Design
190
- - No API keys stored in generated code (environment variable approach)
191
- - Faculty authentication required for configuration changes
192
- - Configuration locking prevents unauthorized modifications during exams