LineChatbot / README.md
raystermomo's picture
Update README.md
e382c0a verified
|
Raw
History Blame Contribute Delete
2.99 kB
metadata
title: LineChatbot
emoji: πŸ’¬
colorFrom: pink
colorTo: purple
sdk: docker
app_port: 7860
pinned: false

LineChatbot

A Streamlit chat app that role-plays a conversation partner using the Claude API, with optional persona/relationship analysis from an uploaded LINE chat export.

This README's YAML header configures it as a Docker Hugging Face Space.

How access works

  • Passkey gate β€” if the APP_PASSKEY secret is set, visitors must enter it to use the app. Share the passkey with whoever you want to let in.
  • API key β€” if the ANTHROPIC_API_KEY secret is set, everyone who passes the passkey gate uses your key automatically. If it is not set, each visitor is asked to paste their own Anthropic key (kept only in their session, never saved).
  • Per-user isolation β€” every browser session gets its own data directory, so visitors never see or overwrite each other's conversations.

Deploy to Hugging Face Spaces

  1. Create a Space: https://huggingface.co/new-space β†’ SDK: Docker β†’ blank.
  2. Push this folder (romance-chatbot/) as the Space repo root. The 1.1 GB model.pt checkpoint must go through Git LFS (.gitattributes already tracks *.pt):
    cd LineChatbot
    git init
    git lfs install
    git remote add origin https://huggingface.co/spaces/<you>/<space-name>
    git add .
    git commit -m "Deploy LineChatbot"
    git push origin main
    
  3. In the Space: Settings β†’ Variables and secrets, add:
    • APP_PASSKEY = the shared passkey you'll hand out (recommended).
    • ANTHROPIC_API_KEY = your Claude key (optional β€” omit to make each visitor supply their own).
    • CHAT_MODEL (optional, default claude-haiku-4-5).
  4. The Space builds the Docker image and gives you a shareable URL. First use of the persona analysis / summarizer downloads the local models (a few GB) once.

Free CPU hardware works but the local models are slow on first use. Personality/ emotion analysis runs once at setup; summarization runs every 20 messages.

Run locally

cd romance-chatbot
pip install -r requirements.txt          # torch CPU/GPU per your platform
export ANTHROPIC_API_KEY=sk-ant-...       # or paste it in the UI
# export APP_PASSKEY=letmein               # optional gate
streamlit run core/app.py

Configuration (env vars / Space secrets)

Variable Required Purpose
APP_PASSKEY no Shared passkey gate. Unset = no gate.
ANTHROPIC_API_KEY no Server-side Claude key. Unset = visitors paste their own.
CHAT_MODEL no Claude model id (default claude-haiku-4-5).
MAX_OUTPUT_TOKENS no Max reply length (default 256).