Spaces:
Running
Running
Delete CLAUDE.md
Browse files
CLAUDE.md
DELETED
@@ -1,76 +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 |
-
## Commands
|
6 |
-
|
7 |
-
### Running the Application
|
8 |
-
```bash
|
9 |
-
python app.py
|
10 |
-
```
|
11 |
-
This starts the Gradio web interface on local port (default 7860).
|
12 |
-
|
13 |
-
### Installing Dependencies
|
14 |
-
```bash
|
15 |
-
pip install -r requirements.txt
|
16 |
-
```
|
17 |
-
|
18 |
-
## Code Architecture
|
19 |
-
|
20 |
-
This is a single-file Gradio 4.32.0 application (`app.py`) that helps users create and deploy chat interfaces on HuggingFace Spaces. The application has two main features:
|
21 |
-
|
22 |
-
1. **Spaces Configuration Tool**: Generates complete deployment packages for chat interfaces
|
23 |
-
- Uses the `SPACE_TEMPLATE` string (lines 15-137) to generate Python code
|
24 |
-
- Creates zip files containing app.py, requirements.txt, README.md, and config.json
|
25 |
-
- Supports multiple LLM models via OpenRouter API
|
26 |
-
- **URL Grounding**: Supports up to 4 discrete URLs for context grounding
|
27 |
-
- Fetches web content from provided URLs using BeautifulSoup
|
28 |
-
- Injects content as context into the system prompt
|
29 |
-
- Automatically truncates content to ~4000 characters per URL
|
30 |
-
|
31 |
-
2. **Chat Support Assistant**: Provides configuration help using Gemma-2-27B
|
32 |
-
- Located in the second tab of the interface
|
33 |
-
- Uses OpenRouter API with environment variable `OPENROUTER_API_KEY`
|
34 |
-
- Includes URL grounding functionality in collapsible accordion
|
35 |
-
|
36 |
-
### Key Functions
|
37 |
-
- `create_readme()`: Generates deployment instructions with HuggingFace YAML frontmatter
|
38 |
-
- `create_requirements()`: Generates requirements.txt content including beautifulsoup4
|
39 |
-
- `generate_zip()`: Main function that creates the deployment package with URL grounding support
|
40 |
-
- `on_generate()`: Callback function for the generate button handling all input parameters
|
41 |
-
- `fetch_url_content()`: Fetches and extracts text from URLs (both in template and main app)
|
42 |
-
- `get_grounding_context()`: Combines URL content into context (both in template and main app)
|
43 |
-
- `respond()`: Chat support function with URL grounding parameters
|
44 |
-
|
45 |
-
### Template System
|
46 |
-
The app uses string templating to generate Python code. The main template (`SPACE_TEMPLATE`) contains placeholders that are filled with user configuration:
|
47 |
-
- `{name}`, `{description}`, `{system_prompt}`, `{model}`
|
48 |
-
- `{api_key_var}`, `{temperature}`, `{max_tokens}`, `{examples}`
|
49 |
-
- `{grounding_urls}`: JSON array of URLs for context grounding
|
50 |
-
|
51 |
-
### Model Configuration
|
52 |
-
Available models are limited to three open-source options:
|
53 |
-
- `google/gemma-2-27b-it` (default)
|
54 |
-
- `mistralai/mixtral-8x7b-instruct`
|
55 |
-
- `meta-llama/llama-3.1-70b-instruct`
|
56 |
-
|
57 |
-
### URL Grounding Architecture
|
58 |
-
URL grounding is implemented in both the main app and generated templates:
|
59 |
-
- Web scraping uses BeautifulSoup4 with 10-second timeout
|
60 |
-
- Content is cleaned (scripts/styles removed) and truncated to 4000 characters
|
61 |
-
- Error handling for failed requests returns descriptive error messages
|
62 |
-
- Context is injected into system prompts for enhanced responses
|
63 |
-
|
64 |
-
## Environment Variables
|
65 |
-
- `OPENROUTER_API_KEY`: Required for the Chat Support feature to work
|
66 |
-
- Uses python-dotenv to load from `.env` file automatically
|
67 |
-
|
68 |
-
## Important Notes
|
69 |
-
- This is a HuggingFace Spaces application (see YAML frontmatter in README.md)
|
70 |
-
- No test suite or linting configuration exists
|
71 |
-
- The generated packages are self-contained chat applications ready for deployment
|
72 |
-
- All generated code uses OpenRouter API for LLM access
|
73 |
-
- Generated spaces include BeautifulSoup4 for URL content extraction
|
74 |
-
- URL grounding fetches content at runtime, adding context to each conversation
|
75 |
-
- Generated README.md files include proper HuggingFace Spaces YAML frontmatter
|
76 |
-
- Template uses double braces `{{}}` for literal braces in generated code, single braces `{}` for template variables
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|