Penpal-AI-Interface / README.md
danielrosehill's picture
Add complete Pen Pal AI application for Hugging Face deployment
b6607da
---
title: Pen Pal AI
emoji: ๐Ÿ“ฎ
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: mit
---
# Pen Pal AI - Letter Exchange
![alt text](image.png)
An experimental AI interface that reimagines conversational AI through the timeless metaphor of letter writing. Instead of rapid-fire chatbot exchanges, Pen Pal AI encourages thoughtful, long-form correspondence with an AI pen pal.
## ๐ŸŽฏ Concept
Traditional conversational AI is modeled after instant messaging - quick back-and-forth exchanges. Pen Pal AI explores a different paradigm:
- **Asynchronous**: Take your time composing thoughtful letters
- **Long-form**: Write detailed, context-rich prompts without worrying about length
- **Single-turn focus**: Each letter gets a complete, comprehensive response
- **Relaxed correspondence**: More like writing to a friend than querying a chatbot
## โœจ Features
- ๐Ÿ“ **Letter-writing interface** with serif fonts and comfortable styling
- ๐Ÿ“ฌ **Automatic subject line generation** for each conversation thread
- ๐Ÿ”ข **Turn tracking** - User Prompt 1, AI Reply 1, User Prompt 2, etc.
- ๐Ÿ“š **Thread history** showing all letters in chronological order
- ๐Ÿ’พ **Markdown downloads** for each letter (preserve your correspondence!)
- ๐Ÿ”„ **New conversation** button to start fresh threads
## ๐Ÿš€ Quick Start
### Local Installation
1. **Clone the repository:**
```bash
git clone https://github.com/danielrosehill/Penpal-AI.git
cd Penpal-AI
```
2. **Set up virtual environment:**
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
3. **Install dependencies:**
```bash
pip install -r requirements.txt
```
4. **Configure API key:**
```bash
cp .env.example .env
# Edit .env and add your OpenAI API key
```
5. **Run the application:**
```bash
python app.py
```
6. **Open your browser** to the URL shown in the terminal (typically `http://localhost:7860`)
## ๐Ÿ”‘ API Key Setup
This application uses OpenAI's API. You'll need:
1. An OpenAI API account ([sign up here](https://platform.openai.com/signup))
2. An API key ([get one here](https://platform.openai.com/api-keys))
3. Add the key to your `.env` file:
```
OPENAI_API_KEY=sk-...your-key-here
```
## ๐Ÿ“– How to Use
1. **Compose your letter** in the text area on the left
2. Click **"๐Ÿ“ฎ Send Letter"**
3. Your letter appears in the "Your Last Letter" section
4. The AI's reply appears on the right side
5. View the **complete thread history** at the bottom
6. Download any letter using the **๐Ÿ’พ Download** buttons
7. Start a **new conversation** anytime with the ๐Ÿ”„ button
## ๐Ÿ’ก Tips for Best Results
- **Write naturally** - compose as if writing to a thoughtful friend
- **Provide context** - since each letter is self-contained, include relevant background
- **Ask complex questions** - this format excels at exploring ideas in depth
- **Take your time** - this isn't instant messaging, it's correspondence
- **Use voice-to-text** - long-form prompts work wonderfully with STT
## ๐ŸŽจ The Philosophy
This project explores what happens when we:
- Reject the chat interface paradigm
- Embrace asynchronous, thoughtful communication
- Encourage long-form, context-rich prompts
- Treat AI interaction more like correspondence than commands
The hypothesis: This approach might work better for certain types of thinking, exploration, and creative work.
## ๐ŸŒ Deployment to Hugging Face
### Option 1: Deploy via Hugging Face Spaces UI
1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
2. Click "Create new Space"
3. Choose "Gradio" as the SDK
4. Upload `app.py` and `requirements.txt`
5. Add your `OPENAI_API_KEY` in Settings โ†’ Repository Secrets
6. Your space will build and deploy automatically!
### Option 2: Deploy via Git
1. Create a new Space on Hugging Face
2. Clone the Space repository:
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME
cd SPACE_NAME
```
3. Copy files:
```bash
cp /path/to/Penpal-AI/app.py .
cp /path/to/Penpal-AI/requirements.txt .
```
4. Commit and push:
```bash
git add app.py requirements.txt
git commit -m "Initial deployment of Pen Pal AI"
git push
```
5. Add `OPENAI_API_KEY` in Space Settings โ†’ Repository Secrets
## ๐Ÿ› ๏ธ Technical Details
- **Framework**: Gradio 5.49.1
- **LLM**: OpenAI GPT-4o (for responses) and GPT-4o-mini (for subject generation)
- **Language**: Python 3.12+
- **Deployment**: Compatible with Hugging Face Spaces
## ๐Ÿค” Why This Exists
The creator discovered that long-form prompting, especially with voice-to-text input, produces better AI interactions than traditional chat. This interface explores that insight by creating a UI that encourages and celebrates long-form correspondence.
It sits between:
- **Workflow AI** (non-interactive, task-oriented)
- **Conversational AI** (interactive chat)
Creating a third category: **Correspondence AI** (conversational but asynchronous)
## ๐Ÿ”ฎ Future Ideas
- Email-style notifications when "letters arrive"
- Context truncation controls (experiment with memory vs. fresh-start)
- User-selectable AI "personalities" or writing styles
- Export entire threads as formatted PDFs
- Integration with actual email for true async correspondence
## ๐Ÿ“ License
MIT License
## ๐Ÿ™ Acknowledgments
Inspired by the art of letter writing and the belief that slower, more thoughtful communication can be powerful even (or especially) with AI.
## ๐Ÿ“ง Contact
For questions, suggestions, or to share your experience:
- **Website**: danielrosehill.com
- **Email**: public@danielrosehill.com
---
*Built with โœ‰๏ธ by Daniel Rosehill*