GhulamMustafa0/children-story-api
0
๐ Children's Story Generator API
A FREE API for generating personalized children's stories using a fine-tuned Llama 2 model!
๐ Features
- ๐ญ Personalized stories based on child's details
- ๐ Completely free to use
- ๐ Simple REST API
- ๐จ Beautiful web interface
- ๐ Privacy-focused (no data stored)
๐ Quick Start
Web Interface
Visit the Space and use the interactive interface to generate stories instantly!
API Usage
Python
import requests
API_URL = "https://ghulamustafa0-children-story-api.hf.space/api/predict"
def generate_story(name, age, mood, animal, max_length=500, temperature=0.7):
response = requests.post(API_URL, json={
"data": [name, age, mood, animal, max_length, temperature]
})
return response.json()["data"][0]
# Generate a story
story = generate_story("Emma", "6", "curious", "fox")
print(story)JavaScript/Node.js
const API_URL = "https://ghulamustafa0-children-story-api.hf.space/api/predict";
async function generateStory(name, age, mood, animal) {
const response = await fetch(API_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: [name, age, mood, animal, 500, 0.7]
})
});
const result = await response.json();
return result.data[0];
}
// Usage
generateStory("Emma", "6", "curious", "fox")
.then(story => console.log(story));cURL
curl -X POST https://ghulamustafa0-children-story-api.hf.space/api/predict -H "Content-Type: application/json" -d '{"data": ["Emma", "6", "curious", "fox", 500, 0.7]}'๐ API Parameters
๐ Response Format
{
"data": [
"Once upon a time, there was a curious girl named Emma who loved foxes..."
],
"duration": 23.5
}โฑ๏ธ Performance
- First Request: 30-60 seconds (cold start)
- Subsequent Requests: 15-30 seconds
- Concurrent Users: Supported via queue system
- Rate Limit: No hard limits (fair use policy)
๐ ๏ธ Technical Details
- Base Model: Llama 2 7B Chat
- Fine-tuning: LoRA (Low-Rank Adaptation)
- Quantization: 4-bit (bitsandbytes)
- Framework: Transformers, PEFT, Gradio
- Hardware: CPU (Hugging Face free tier)
๐ก Usage Tips
- First request is slow: The model needs to load (30-60s). Subsequent requests are much faster.
- Optimal temperature: 0.7 provides good balance between creativity and coherence
- Story length: 400-600 tokens works best for children's stories
- Mood options: stick to: happy, curious, brave, excited, scared
- Animals: Any animal works, but common ones (fox, lion, bear) produce better results
๐ฏ Use Cases
- ๐ฑ Mobile apps for children
- ๐ Educational websites
- ๐ E-book generation
- ๐ฎ Interactive storytelling games
- ๐จโ๐ฉโ๐ง Parenting apps
๐ Privacy & Safety
- No data is stored or logged
- Stories are generated fresh each time
- Content is appropriate for children
- No personal information required
๐ License
This project uses the Llama 2 Community License from the base model.
๐ค Contributing
Feel free to:
- Report issues
- Suggest improvements
- Share your use cases
๐ง Support
For questions or issues, please open a discussion on this Space.
๐ Credits
- Model: Based on Meta's Llama 2 7B Chat
- Fine-tuning: Custom children's story dataset
- Framework: Hugging Face Transformers & Gradio
- Creator: GhulamMustafa0
Enjoy creating magical stories for children! โจ๐
