Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .claude/settings.local.json +9 -0
- .gitignore +53 -0
- DEPLOY.md +79 -0
- README.md +52 -12
- app.py +201 -0
- config.yaml +10 -0
- packages.txt +1 -0
- requirements.txt +5 -0
- test_app.py +56 -0
.claude/settings.local.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"permissions": {
|
| 3 |
+
"allow": [
|
| 4 |
+
"Bash(pip install:*)",
|
| 5 |
+
"Bash(huggingface-cli:*)"
|
| 6 |
+
],
|
| 7 |
+
"deny": []
|
| 8 |
+
}
|
| 9 |
+
}
|
.gitignore
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
build/
|
| 8 |
+
develop-eggs/
|
| 9 |
+
dist/
|
| 10 |
+
downloads/
|
| 11 |
+
eggs/
|
| 12 |
+
.eggs/
|
| 13 |
+
lib/
|
| 14 |
+
lib64/
|
| 15 |
+
parts/
|
| 16 |
+
sdist/
|
| 17 |
+
var/
|
| 18 |
+
wheels/
|
| 19 |
+
*.egg-info/
|
| 20 |
+
.installed.cfg
|
| 21 |
+
*.egg
|
| 22 |
+
MANIFEST
|
| 23 |
+
|
| 24 |
+
# Virtual environments
|
| 25 |
+
venv/
|
| 26 |
+
env/
|
| 27 |
+
ENV/
|
| 28 |
+
.venv
|
| 29 |
+
.ENV
|
| 30 |
+
|
| 31 |
+
# IDE
|
| 32 |
+
.vscode/
|
| 33 |
+
.idea/
|
| 34 |
+
*.swp
|
| 35 |
+
*.swo
|
| 36 |
+
*~
|
| 37 |
+
|
| 38 |
+
# OS
|
| 39 |
+
.DS_Store
|
| 40 |
+
Thumbs.db
|
| 41 |
+
|
| 42 |
+
# Gradio
|
| 43 |
+
gradio_cached_examples/
|
| 44 |
+
flagged/
|
| 45 |
+
|
| 46 |
+
# Hugging Face
|
| 47 |
+
.cache/
|
| 48 |
+
models/
|
| 49 |
+
*.bin
|
| 50 |
+
*.safetensors
|
| 51 |
+
|
| 52 |
+
# Logs
|
| 53 |
+
*.log
|
DEPLOY.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Deploy to Hugging Face Spaces
|
| 4 |
+
|
| 5 |
+
### Prerequisites
|
| 6 |
+
1. Install Hugging Face CLI:
|
| 7 |
+
```bash
|
| 8 |
+
pip install huggingface_hub
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
2. Login to Hugging Face:
|
| 12 |
+
```bash
|
| 13 |
+
huggingface-cli login
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
### Create and Deploy Space
|
| 17 |
+
|
| 18 |
+
1. **Create a new Space on Hugging Face Hub:**
|
| 19 |
+
```bash
|
| 20 |
+
huggingface-cli repo create --type space --space_sdk gradio your-username/one-pager-generator
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
2. **Clone and set up the repository:**
|
| 24 |
+
```bash
|
| 25 |
+
git clone https://huggingface.co/spaces/your-username/one-pager-generator
|
| 26 |
+
cd one-pager-generator
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
3. **Copy files to the Space repository:**
|
| 30 |
+
```bash
|
| 31 |
+
cp ../one-pager/* .
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
4. **Add, commit and push:**
|
| 35 |
+
```bash
|
| 36 |
+
git add .
|
| 37 |
+
git commit -m "Initial commit: AI One-Pager Generator"
|
| 38 |
+
git push
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
### Alternative: Direct CLI Upload
|
| 42 |
+
|
| 43 |
+
You can also use the HF CLI to upload files directly:
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
huggingface-cli upload your-username/one-pager-generator . --repo-type=space
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### Files Required for Deployment
|
| 50 |
+
|
| 51 |
+
- `app.py` - Main application file
|
| 52 |
+
- `requirements.txt` - Python dependencies
|
| 53 |
+
- `config.yaml` - Space configuration
|
| 54 |
+
- `README.md` - Documentation
|
| 55 |
+
- `.gitignore` - Git ignore patterns
|
| 56 |
+
|
| 57 |
+
### Configuration Notes
|
| 58 |
+
|
| 59 |
+
- The app uses `distilgpt2` model for better compatibility
|
| 60 |
+
- CPU-only inference for free tier compatibility
|
| 61 |
+
- Fallback template system ensures reliable output
|
| 62 |
+
- Gradio interface optimized for Spaces
|
| 63 |
+
|
| 64 |
+
### Post-Deployment
|
| 65 |
+
|
| 66 |
+
After deployment, your Space will be available at:
|
| 67 |
+
`https://huggingface.co/spaces/your-username/one-pager-generator`
|
| 68 |
+
|
| 69 |
+
The app will automatically:
|
| 70 |
+
1. Install dependencies from requirements.txt
|
| 71 |
+
2. Load the AI model
|
| 72 |
+
3. Launch the Gradio interface
|
| 73 |
+
4. Be accessible via the web
|
| 74 |
+
|
| 75 |
+
### Troubleshooting
|
| 76 |
+
|
| 77 |
+
- **Model loading issues**: The app falls back to structured templates
|
| 78 |
+
- **Memory issues**: Using smaller DistilGPT2 model for efficiency
|
| 79 |
+
- **Timeout issues**: CPU inference may be slower but more reliable
|
README.md
CHANGED
|
@@ -1,12 +1,52 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π AI One-Pager Generator
|
| 2 |
+
|
| 3 |
+
An intelligent Gradio application that generates professional one-page documents on any topic using Hugging Face transformers.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- **Topic-based Generation**: Create one-pagers on any subject
|
| 8 |
+
- **Customizable Parameters**:
|
| 9 |
+
- Target audience specification
|
| 10 |
+
- Tone selection (Professional, Casual, Academic, Persuasive, Informative)
|
| 11 |
+
- Length control (Short, Medium, Long)
|
| 12 |
+
- Key points input
|
| 13 |
+
- **Professional Formatting**: Structured output with title, executive summary, key points, and conclusion
|
| 14 |
+
- **Easy to Use**: Simple web interface powered by Gradio
|
| 15 |
+
|
| 16 |
+
## Installation
|
| 17 |
+
|
| 18 |
+
1. Clone this repository
|
| 19 |
+
2. Install dependencies:
|
| 20 |
+
```bash
|
| 21 |
+
pip install -r requirements.txt
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
3. Run the application:
|
| 25 |
+
```bash
|
| 26 |
+
python app.py
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Usage
|
| 30 |
+
|
| 31 |
+
1. Enter your topic in the "Topic" field
|
| 32 |
+
2. Specify your target audience
|
| 33 |
+
3. List key points you want covered
|
| 34 |
+
4. Select the appropriate tone and length
|
| 35 |
+
5. Click "Generate One-Pager"
|
| 36 |
+
6. Copy and use your generated document!
|
| 37 |
+
|
| 38 |
+
## Deployment to Hugging Face Spaces
|
| 39 |
+
|
| 40 |
+
This app is ready to be deployed to Hugging Face Spaces:
|
| 41 |
+
|
| 42 |
+
1. Create a new Space on Hugging Face
|
| 43 |
+
2. Upload these files to your Space
|
| 44 |
+
3. Your app will be automatically deployed!
|
| 45 |
+
|
| 46 |
+
## Model Information
|
| 47 |
+
|
| 48 |
+
This application uses Microsoft's DialoGPT-large model for text generation, optimized for document creation tasks.
|
| 49 |
+
|
| 50 |
+
## License
|
| 51 |
+
|
| 52 |
+
MIT License
|
app.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import torch
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# Initialize the text generation pipeline
|
| 7 |
+
generator = None
|
| 8 |
+
|
| 9 |
+
def initialize_model():
|
| 10 |
+
global generator
|
| 11 |
+
try:
|
| 12 |
+
# Use a reliable text generation model
|
| 13 |
+
generator = pipeline(
|
| 14 |
+
"text-generation",
|
| 15 |
+
model="distilgpt2", # Smaller, faster model
|
| 16 |
+
device=-1, # CPU only for compatibility
|
| 17 |
+
pad_token_id=50256 # Set pad token to avoid warnings
|
| 18 |
+
)
|
| 19 |
+
return "Model loaded successfully!"
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return f"Error loading model: {str(e)}"
|
| 22 |
+
|
| 23 |
+
def generate_onepager(topic, target_audience, key_points, tone, length):
|
| 24 |
+
if generator is None:
|
| 25 |
+
return "Error: Model not initialized. Please wait for the model to load."
|
| 26 |
+
|
| 27 |
+
# Create a structured prompt for one-pager generation
|
| 28 |
+
length_tokens = {"Short": 200, "Medium": 400, "Long": 600}
|
| 29 |
+
max_tokens = length_tokens.get(length, 400)
|
| 30 |
+
|
| 31 |
+
prompt = f"""ONE-PAGE DOCUMENT
|
| 32 |
+
|
| 33 |
+
TOPIC: {topic}
|
| 34 |
+
AUDIENCE: {target_audience}
|
| 35 |
+
TONE: {tone}
|
| 36 |
+
|
| 37 |
+
EXECUTIVE SUMMARY:
|
| 38 |
+
{key_points}
|
| 39 |
+
|
| 40 |
+
DETAILED CONTENT:
|
| 41 |
+
|
| 42 |
+
Title: {topic}
|
| 43 |
+
|
| 44 |
+
Overview:"""
|
| 45 |
+
|
| 46 |
+
try:
|
| 47 |
+
# Generate the one-pager
|
| 48 |
+
result = generator(
|
| 49 |
+
prompt,
|
| 50 |
+
max_length=len(prompt.split()) + max_tokens,
|
| 51 |
+
num_return_sequences=1,
|
| 52 |
+
temperature=0.8,
|
| 53 |
+
do_sample=True,
|
| 54 |
+
pad_token_id=generator.tokenizer.eos_token_id,
|
| 55 |
+
eos_token_id=generator.tokenizer.eos_token_id,
|
| 56 |
+
repetition_penalty=1.1
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
# Extract the generated text
|
| 60 |
+
generated_text = result[0]['generated_text']
|
| 61 |
+
|
| 62 |
+
# Clean up the output
|
| 63 |
+
onepager = generated_text.replace(prompt, "").strip()
|
| 64 |
+
|
| 65 |
+
# If output is too short, provide a structured fallback
|
| 66 |
+
if len(onepager) < 50:
|
| 67 |
+
onepager = create_structured_onepager(topic, target_audience, key_points, tone)
|
| 68 |
+
|
| 69 |
+
return onepager
|
| 70 |
+
|
| 71 |
+
except Exception as e:
|
| 72 |
+
# Fallback to structured template
|
| 73 |
+
return create_structured_onepager(topic, target_audience, key_points, tone)
|
| 74 |
+
|
| 75 |
+
def create_structured_onepager(topic, target_audience, key_points, tone):
|
| 76 |
+
"""Create a structured one-pager when AI generation fails"""
|
| 77 |
+
|
| 78 |
+
tone_styles = {
|
| 79 |
+
"Professional": "formal and business-oriented",
|
| 80 |
+
"Casual": "friendly and approachable",
|
| 81 |
+
"Academic": "scholarly and research-focused",
|
| 82 |
+
"Persuasive": "compelling and action-oriented",
|
| 83 |
+
"Informative": "clear and educational"
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
style_desc = tone_styles.get(tone, "professional")
|
| 87 |
+
|
| 88 |
+
template = f"""# {topic}
|
| 89 |
+
|
| 90 |
+
## Executive Summary
|
| 91 |
+
This document provides a comprehensive overview of {topic.lower()} tailored for {target_audience.lower()}. The content is presented in a {style_desc} manner to ensure maximum impact and understanding.
|
| 92 |
+
|
| 93 |
+
## Key Points
|
| 94 |
+
|
| 95 |
+
{chr(10).join([f"β’ {point.strip()}" for point in key_points.split(',') if point.strip()])}
|
| 96 |
+
|
| 97 |
+
## Background
|
| 98 |
+
{topic} represents an important area that requires careful consideration and strategic thinking. Understanding the core concepts and implications is essential for {target_audience.lower()}.
|
| 99 |
+
|
| 100 |
+
## Main Content
|
| 101 |
+
The fundamental aspects of {topic.lower()} encompass several critical areas that directly impact stakeholders. These elements work together to create a comprehensive framework for understanding and implementation.
|
| 102 |
+
|
| 103 |
+
## Benefits & Opportunities
|
| 104 |
+
- Enhanced understanding of core concepts
|
| 105 |
+
- Improved decision-making capabilities
|
| 106 |
+
- Strategic advantages for implementation
|
| 107 |
+
- Clear actionable insights
|
| 108 |
+
|
| 109 |
+
## Recommendations
|
| 110 |
+
1. Begin with thorough analysis of current situation
|
| 111 |
+
2. Develop comprehensive implementation strategy
|
| 112 |
+
3. Monitor progress and adjust approach as needed
|
| 113 |
+
4. Measure results and iterate for continuous improvement
|
| 114 |
+
|
| 115 |
+
## Conclusion
|
| 116 |
+
{topic} offers significant opportunities for {target_audience.lower()} when approached strategically. The key points outlined above provide a solid foundation for moving forward with confidence and clarity.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
*This one-pager was generated to provide quick, actionable insights on {topic.lower()}.*"""
|
| 120 |
+
|
| 121 |
+
return template
|
| 122 |
+
|
| 123 |
+
# Create the Gradio interface
|
| 124 |
+
def create_interface():
|
| 125 |
+
with gr.Blocks(title="One-Pager Generator", theme=gr.themes.Soft()) as demo:
|
| 126 |
+
gr.Markdown("# π AI One-Pager Generator")
|
| 127 |
+
gr.Markdown("Generate professional one-page documents on any topic using AI!")
|
| 128 |
+
|
| 129 |
+
with gr.Row():
|
| 130 |
+
with gr.Column(scale=1):
|
| 131 |
+
topic_input = gr.Textbox(
|
| 132 |
+
label="Topic",
|
| 133 |
+
placeholder="e.g., Digital Marketing Strategy, Climate Change Solutions, etc.",
|
| 134 |
+
lines=2,
|
| 135 |
+
value="Artificial Intelligence in Healthcare"
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
audience_input = gr.Textbox(
|
| 139 |
+
label="Target Audience",
|
| 140 |
+
placeholder="e.g., Business executives, Students, General public, etc.",
|
| 141 |
+
lines=1,
|
| 142 |
+
value="Healthcare professionals"
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
keypoints_input = gr.Textbox(
|
| 146 |
+
label="Key Points to Cover",
|
| 147 |
+
placeholder="Enter main points separated by commas",
|
| 148 |
+
lines=4,
|
| 149 |
+
value="Machine learning applications, Data privacy, Cost-effectiveness, Implementation challenges"
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
tone_dropdown = gr.Dropdown(
|
| 153 |
+
choices=["Professional", "Casual", "Academic", "Persuasive", "Informative"],
|
| 154 |
+
label="Tone",
|
| 155 |
+
value="Professional"
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
length_dropdown = gr.Dropdown(
|
| 159 |
+
choices=["Short", "Medium", "Long"],
|
| 160 |
+
label="Length",
|
| 161 |
+
value="Medium"
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
generate_btn = gr.Button("π Generate One-Pager", variant="primary")
|
| 165 |
+
|
| 166 |
+
with gr.Column(scale=2):
|
| 167 |
+
output_text = gr.Textbox(
|
| 168 |
+
label="Generated One-Pager",
|
| 169 |
+
lines=25,
|
| 170 |
+
max_lines=35,
|
| 171 |
+
show_copy_button=True,
|
| 172 |
+
placeholder="Your generated one-pager will appear here..."
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
with gr.Row():
|
| 176 |
+
gr.Markdown("""
|
| 177 |
+
### π‘ Tips for Best Results:
|
| 178 |
+
- **Be specific** with your topic for more targeted content
|
| 179 |
+
- **Include 3-5 key points** separated by commas
|
| 180 |
+
- **Choose the right tone** for your intended audience
|
| 181 |
+
- **Use descriptive audience** details (e.g., "C-level executives" vs "executives")
|
| 182 |
+
""")
|
| 183 |
+
|
| 184 |
+
# Connect the generate button to the function
|
| 185 |
+
generate_btn.click(
|
| 186 |
+
fn=generate_onepager,
|
| 187 |
+
inputs=[topic_input, audience_input, keypoints_input, tone_dropdown, length_dropdown],
|
| 188 |
+
outputs=output_text
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
return demo
|
| 192 |
+
|
| 193 |
+
# Initialize model and launch
|
| 194 |
+
if __name__ == "__main__":
|
| 195 |
+
print("π Starting One-Pager Generator...")
|
| 196 |
+
print("π₯ Loading AI model...")
|
| 197 |
+
initialize_model()
|
| 198 |
+
print("β
Model loaded! Launching interface...")
|
| 199 |
+
|
| 200 |
+
demo = create_interface()
|
| 201 |
+
demo.launch()
|
config.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
title: AI One-Pager Generator
|
| 2 |
+
emoji: π
|
| 3 |
+
colorFrom: blue
|
| 4 |
+
colorTo: purple
|
| 5 |
+
sdk: gradio
|
| 6 |
+
sdk_version: 4.44.0
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
short_description: Generate professional one-page documents on any topic using AI
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
huggingface_hub
|
| 5 |
+
tokenizers
|
test_app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Simple test script to verify the one-pager generator functionality
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import sys
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
# Add the current directory to the path so we can import our app
|
| 10 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 11 |
+
|
| 12 |
+
def test_basic_functionality():
|
| 13 |
+
"""Test basic app functionality without launching the full interface"""
|
| 14 |
+
try:
|
| 15 |
+
from app import generate_onepager, initialize_model
|
| 16 |
+
|
| 17 |
+
print("π§ͺ Testing One-Pager Generator...")
|
| 18 |
+
print("Initializing model...")
|
| 19 |
+
|
| 20 |
+
# Initialize the model
|
| 21 |
+
init_result = initialize_model()
|
| 22 |
+
print(f"Model initialization: {init_result}")
|
| 23 |
+
|
| 24 |
+
# Test generation with sample data
|
| 25 |
+
print("\nπ Testing one-pager generation...")
|
| 26 |
+
test_topic = "Artificial Intelligence in Healthcare"
|
| 27 |
+
test_audience = "Healthcare professionals"
|
| 28 |
+
test_keypoints = "Machine learning applications, Data privacy concerns, Cost-effectiveness, Implementation challenges"
|
| 29 |
+
test_tone = "Professional"
|
| 30 |
+
test_length = "Medium"
|
| 31 |
+
|
| 32 |
+
result = generate_onepager(
|
| 33 |
+
topic=test_topic,
|
| 34 |
+
target_audience=test_audience,
|
| 35 |
+
key_points=test_keypoints,
|
| 36 |
+
tone=test_tone,
|
| 37 |
+
length=test_length
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
print("Generated One-Pager:")
|
| 41 |
+
print("-" * 50)
|
| 42 |
+
print(result)
|
| 43 |
+
print("-" * 50)
|
| 44 |
+
|
| 45 |
+
if "Error" not in result:
|
| 46 |
+
print("β
Test passed! One-pager generated successfully.")
|
| 47 |
+
else:
|
| 48 |
+
print("β Test failed! Error in generation.")
|
| 49 |
+
|
| 50 |
+
except Exception as e:
|
| 51 |
+
print(f"β Test failed with exception: {str(e)}")
|
| 52 |
+
import traceback
|
| 53 |
+
traceback.print_exc()
|
| 54 |
+
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
test_basic_functionality()
|