--- title: StyleForge Lite emoji: 🔬 colorFrom: blue colorTo: purple sdk: gradio sdk_version: "4.44.0" app_file: app.py pinned: false --- # 🔬 StyleForge Lite A minimal Gradio app that learns your scientific writing style from pasted abstracts and rewrites new text in that style using the Groq API. ## Features - **Style Learning**: Paste 3-8 abstracts to build your writing profile - **Text Rewriting**: Rewrite any text in your learned scientific style - **Style Metrics**: Get detailed scoring on: - Average sentence length - Passive voice ratio - Vocabulary match (% scientific verbs) - Flow markers (context→method→result→implication) - Total score (/20) - **Deployment Guide**: Built-in instructions for Hugging Face Spaces ## Quick Deploy to Hugging Face Spaces ### Method 1: Direct Clone (Recommended) 1. **Clone this repository**: ```bash git clone https://huggingface.co/spaces/Babajaan/Writing-Style cd Writing-Style ``` 2. **Set your API key**: - Go to your Space settings - Add `GROQ_API_KEY` as a secret with your Groq API key - Get your API key from [Groq Console](https://console.groq.com) 3. **Deploy**: The Space will automatically rebuild with your changes ### Method 2: Create New Space 1. **Create new Space**: - Go to [Hugging Face Spaces](https://huggingface.co/spaces) - Click "Create new Space" - Choose "Gradio" as SDK - Set visibility (Public/Private) 2. **Upload files**: - Upload `app.py` - Upload `requirements.txt` - Upload this `README.md` 3. **Configure environment**: - Add `GROQ_API_KEY` in Space settings → Secrets - Set Space hardware (CPU is sufficient) 4. **Deploy**: The Space will automatically build and deploy ## Environment Variables - `GROQ_API_KEY`: Your Groq API key (required) ## Requirements - Python 3.8+ - Gradio >= 4.44.0 - Groq >= 0.9.0 ## Usage 1. **Paste Abstracts**: Input 3-8 of your scientific abstracts in the first text box 2. **Enter Text**: Input the text you want to rewrite in the second text box 3. **Click "Build Profile & Rewrite"**: The app will analyze your style and rewrite the text 4. **View Results**: See the rewritten text and style metrics ## Style Analysis The app analyzes your writing style based on: - **Sentence Length**: Optimal 15-25 words per sentence - **Voice**: Preference for active over passive voice - **Vocabulary**: Use of precise scientific verbs (identify, demonstrate, suggest, etc.) - **Flow**: Logical progression from context → method → result → implication ## Troubleshooting - **Build fails**: Check `requirements.txt` syntax - **API errors**: Verify `GROQ_API_KEY` is set correctly in Space secrets - **Import errors**: Ensure all dependencies are in `requirements.txt` - **Empty responses**: Check your Groq API key and quota ## Cost Considerations - Groq API has generous free tier - Monitor usage in [Groq Console](https://console.groq.com) - Consider rate limiting for production use ## Example **Input Abstracts**: ``` Resveratrol (RESL), a natural polyphenol, has been studied for its cancer chemopreventive properties. In this study, a diacetate derivative (RESL43) was synthesized, exhibiting potent cytotoxic and pro-apoptotic effects in U937 cells. Molecular docking indicated that RESL43 may inhibit NFκB by disrupting DNA–protein interactions. These findings support stronger activity than RESL and warrant further investigation. ``` **Original Text**: ``` Our study shows that the new drug works well. We tested it on cells and found good results. The drug might help treat cancer. ``` **Rewritten Output**: ``` Our investigation demonstrates that the novel therapeutic compound exhibits significant efficacy in cellular models. Through comprehensive in vitro analysis, we identified substantial cytotoxic activity and pro-apoptotic effects in U937 cell lines. These findings suggest the potential utility of this compound as a chemopreventive agent and warrant further investigation into its molecular mechanisms. ``` ## License This project is open source and available under the MIT License.