CoolFace
Apppublic

GhulamMustafa0/children-story-api

sourceHugging Facemitupdated 9mo agoView on Hugging Face
0likes
App README

๐Ÿ“š 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
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
javascript
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
bash
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

ParameterTypeRequiredDescriptionExample
namestringYesChild's name"Emma"
agestringYesChild's age"6"
moodstringYesMood (happy/curious/brave/excited/scared)"curious"
animalstringYesFavorite animal"fox"
max_lengthnumberNoStory length (100-800)500
temperaturenumberNoCreativity (0.3-1.0)0.7

๐Ÿ“Š Response Format

json
{
  "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

  1. 1.First request is slow: The model needs to load (30-60s). Subsequent requests are much faster.
  2. 2.Optimal temperature: 0.7 provides good balance between creativity and coherence
  3. 3.Story length: 400-600 tokens works best for children's stories
  4. 4.Mood options: stick to: happy, curious, brave, excited, scared
  5. 5.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! โœจ๐Ÿ“š