AI_Game / README_Deploy.md
ducnguyen1978's picture
Upload folder using huggingface_hub
815d041 verified

A newer version of the Gradio SDK is available: 6.5.1

Upgrade

AI Friends Talk - Gradio Deployment Guide

🎭 Watch 3 AI friends with different personalities debate fun topics!

🚨 IMPORTANT: Deployment Error Fix

If you get the error "It appears that one or more of your files contain valid Hugging Face secrets", follow these steps:

For Hugging Face Spaces Deployment (CORRECT WAY)

Method 1: Manual Upload (Recommended)

  1. Create a new Space at https://huggingface.co/spaces

  2. Upload ONLY these files:

    • AI_Talk_Gradio.py
    • requirements.txt
    • .gitignore (optional)
  3. DO NOT upload these files:

    • ❌ .env (contains API keys)
    • ❌ __pycache__/ folders
    • ❌ .gradio/ folders
    • ❌ Certificate files (.pem)
  4. Add API keys as Secrets in Space settings:

    • Go to your Space β†’ Settings β†’ Repository secrets
    • Add: GROQ_API_KEY = your_groq_api_key
    • Add: GOOGLE_API_KEY = your_google_api_key
  5. Space will auto-deploy with the secrets!

Method 2: Using huggingface_hub (Advanced)

from huggingface_hub import HfApi

api = HfApi()
api.upload_file(
    path_or_fileobj="AI_Talk_Gradio.py",
    path_in_repo="AI_Talk_Gradio.py", 
    repo_id="your_username/your_space_name",
    repo_type="space"
)
api.upload_file(
    path_or_fileobj="requirements.txt",
    path_in_repo="requirements.txt",
    repo_id="your_username/your_space_name", 
    repo_type="space"
)

For Local Development

  1. Install dependencies:
pip install -r requirements.txt
  1. Create .env file:
GROQ_API_KEY=your_groq_api_key_here
GOOGLE_API_KEY=your_google_api_key_here
  1. Run the app:
python AI_Talk_Gradio.py

πŸ€– AI Characters

  • 🎭 Alex (Groq llama3-70b): Witty debater
  • 🌟 Blake (Gemini 2.0): Creative optimist
  • 🧠 Charlie (Gemini 1.5): Logical analyst

✨ Features

  • 🌐 Multi-language support (English/TiαΊΏng Việt/Deutsch)
  • 🎯 Custom or predefined topics
  • πŸ’¬ Join the conversation as 4th participant
  • 🎨 Beautiful gradient UI with animations
  • πŸ“± Mobile responsive design
  • πŸ”„ Auto-conversation flow
  • ⚑ Real-time AI responses

πŸ“ Files Structure for Deployment

AI_Game/
β”œβ”€β”€ AI_Talk_Gradio.py      βœ… Main app file
β”œβ”€β”€ requirements.txt       βœ… Dependencies
β”œβ”€β”€ .gitignore            βœ… Ignore sensitive files
β”œβ”€β”€ README_Deploy.md      ℹ️  This guide
β”œβ”€β”€ .env                  ❌ DO NOT UPLOAD (contains secrets)
└── __pycache__/          ❌ DO NOT UPLOAD (Python cache)

πŸ”‘ API Keys Required

  1. Groq API Key: Get from https://console.groq.com/
  2. Google API Key: Get from https://ai.google.dev/gemini-api

πŸ”§ Troubleshooting

  • "BadRequestError: secrets detected": Remove .env file from upload
  • "Model not found": Check API keys in Space secrets
  • "Port already in use": App auto-selects available port
  • Import errors: Verify requirements.txt is uploaded

Made by Digitized Brains πŸ§