跳到正文
DEV Community· LeoJulieta·· 23 小時前AI 評分24

StoryAI:為難民營按需提供多語言兒童故事

StoryAI: On‑Demand Multilingual Kids' Tales for Refugee Camps

AI 導讀

StoryAI 按需生成符合年齡、融入文化元素的多語言兒童故事,並透過 WhatsApp、SMS 或離線裝置送達難民營家庭。部署指南涵蓋提示詞建構、安全過濾、人工審核、配送及私隱優先的使用數據收集。指南提及可選用 GPT-4、Claude-2.1 或 LLaMA-2-13B,並以 Raspberry Pi 邊緣裝置離線提供故事。

正文

LeoJulieta

Launching StoryAI: Scalable, Multilingual Children’s Stories for Refugee Camps (Google Launch #en‑0105)


Introduction

Millions of displaced children grow up without a single storybook. StoryAI changes that by generating age‑appropriate, culturally‑sensitive tales on‑demand and delivering them over the low‑bandwidth channels that dominate refugee camps—WhatsApp, SMS, or even offline‑first devices.

Since the product’s debut on Product Hunt and the sharp rise in Google Trends for “children’s stories + refugees,” NGOs are asking: How do we turn a prototype into a privacy‑first, sustainable service? This guide gives you the practical steps, code snippets, and deployment tips you need to start today.


How StoryAI Works (At a Glance)

Component What It Does Quick‑Start Command
Prompt Builder Adds age, language, and cultural tags to steer the LLM. python build_prompt.py --age 5-7 --culture Ukrainian --lang es
LLM Backend Calls GPT‑4, Claude, or LLaMA via OpenAI/Anthropic/Meta APIs. curl -X POST https://api.openai.com/v1/chat/completions \ <br> -H "Authorization: Bearer $OPENAI_KEY" \ <br> -H "Content-Type: application/json" \ <br> -d '{"model":"gpt-4","messages":[{"role":"system","content":"You are a children’s author..."}]}'
Safety Filter Rejects any output containing violence, hate, or adult content. python filter.py --input story.txt --policy ./policies/child_safe.yaml
Human Review Queue (optional) Sends flagged stories to a reviewer Slack channel. slack webhook https://hooks.slack.com/services/... --payload @story.txt
Delivery Engine Sends text via Twilio SMS, WhatsApp Business API, or serves locally from an edge node. twilio sms:create --to +1234567890 --from +1987654321 --body "$(cat story.txt)"
Edge Cache Raspberry Pi Docker container that pre‑downloads a daily batch for offline use. docker run -d --restart unless‑stopped \ <br> -v $(pwd)/cache:/app/cache \ <br> storyai/edge:latest sync

Step‑by‑Step Deployment

1. Set Up the Prompt Builder

# Clone the repo and install deps
git clone https://github.com/storyai/core.git
cd storyai
pip install -r requirements.txt

# Generate a prompt for a 6‑year‑old Ukrainian child in Spanish
python build_prompt.py --age 5-7 --culture Ukrainian --lang es > prompt.txt

The resulting prompt.txt looks like:

You are a children’s author. Write a short story for a 6‑year‑old (age:5-7) in Spanish. The story must reflect Ukrainian cultural elements (e.g., sunflower fields, traditional lullabies) and contain no violence or adult themes.

2. Call the LLM

curl -s -X POST https://api.anthropic.com/v1/complete \
  -H "x-api-key: $ANTHROPIC_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "model": "claude-2.1",
  "prompt": "$(cat prompt.txt)",
  "max_tokens_to_sample": 500,
  "temperature": 0.7
}
EOF > story_raw.txt

3. Run the Safety Filter

python filter.py --input story_raw.txt --policy policies/child_safe.yaml --output story.txt
if [ $? -ne 0 ]; then
  echo "Content rejected – send to human reviewer"
  slack webhook https://hooks.slack.com/services/... --payload @story_raw.txt
  exit 1
fi

4. Deliver the Story

SMS (Twilio)

twilio sms:create \
  --to +1234567890 \
  --from +1987654321 \
  --body "$(cat story.txt)"

WhatsApp (Business API)

curl -X POST https://graph.facebook.com/v17.0/<PHONE_NUMBER_ID>/messages \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "messaging_product":"whatsapp",
        "to":"1234567890",
        "type":"text",
        "text":{"body":"'"$(cat story.txt)"'"}
      }'

Offline Edge Node

# On the Raspberry Pi in the camp
docker exec -it storyai_edge sync   # pulls the daily batch
docker exec -it storyai_edge serve  # opens a local Wi‑Fi hotspot at http://10.0.0.1

Camp volunteers can now hand out a simple QR code that points to the hotspot; families download stories directly to a cheap Android tablet.

5. Collect Usage Metrics (Privacy‑First)

# tokenized analytics – no raw phone numbers stored
from uuid import uuid5, NAMESPACE_DNS
def tokenise(phone):
    return uuid5(NAMESPACE_DNS, phone)

# Example logging
log = {
    "user_id": tokenise("+1234567890"),
    "story_id": "ukr_es_2024_04_12",
    "timestamp": datetime.utcnow().isoformat()
}
# Send to encrypted analytics endpoint
requests.post("https://analytics.storyai.org/collect", json=log, verify=True)

All data is encrypted at rest (AES‑256) and complies with GDPR and the UN Convention on the Rights of the Child.


Frequently Asked Questions

Question Practical Answer
How do I guarantee age‑appropriate content across cultures? Use the prompt tags (age, culture, language) and the built‑in safety filter. Fine‑tune the model on a curated UNESCO‑approved corpus; the filter will automatically reject any story that contains disallowed tokens.
What are the privacy requirements for phone numbers? Store only a deterministic hash (as shown above) for analytics. Keep raw numbers in a separate, encrypted table that is never queried for reporting. Record consent with a timestamped “YES” SMS reply; this single line satisfies GDPR’s consent‑record requirement.
Can the system run without internet? Yes. Deploy the Dockerized edge container on a Raspberry Pi or similar SBC. It syncs once per day when a mobile hotspot is available, then serves stories locally via Wi‑Fi or Bluetooth.
Which LLM should I start with? GPT‑4 offers the most robust safety controls out of the box, but Claude‑2.1 and LLaMA‑2‑13B are cheaper for high‑volume deployments. Test all three on a small batch and compare cost per 1 000 characters.
How do I handle audio versions for low‑literacy users? After the text is approved, pipe it through a TTS engine (e.g., Google Cloud Text‑to‑Speech) and store the MP3 alongside the text. The edge node can serve both files; the client app plays the audio automatically when the story is opened.

Why Launch Now?

  1. Rising displacement – Over 30 million children are living in refugee or IDP camps (UNHCR, 2024).
  2. Learning gaps – 53 % have missed at least one school year (UNICEF). Access to reading material is a proven mitigator of trauma and language loss.
  3. Search demand – Google Trends for “children’s stories + refugees” has spiked 220 % in the last six months, confirming a global appetite for instant, multilingual content.
  4. Tech readiness – Affordable edge hardware, mature LLM APIs, and low‑cost messaging platforms make a full‑stack solution feasible at scale today.

Next Steps for NGOs & Developers

  1. Pilot – Run a 2‑week pilot in a single camp using the edge node workflow. Collect consented usage data and iterate on cultural tags.
  2. Funding – Leverage the Product Hunt launch metrics to apply for grants from UNICEF Innovation Fund or the Gates Foundation.
  3. Community – Join the #StoryAI Slack workspace (invite@storyai.org) to share prompts, review flagged stories, and co‑author new cultural modules.
  4. Scale – Replicate the edge node across multiple sites; automate nightly syncs with a simple cron job (0 2 * * * docker exec storyai_edge sync).

With these concrete steps, you can move from a proof‑of‑concept to a reliable, privacy‑first storytelling service that reaches the children who need it most—today.


Herramienta mencionada: Groq Cloud

來源:DEV Community · dev.to