Skip to content

carp007/simple-ai-agent

Repository files navigation

title Thoughtful AI Support Agent
emoji 🤖
colorFrom blue
colorTo green
sdk gradio
app_file app.py
pinned false

Thoughtful AI Support Agent (FAQ + LLM fallback)

A simple customer support agent that:

  • answers from a hardcoded Thoughtful AI FAQ using fuzzy retrieval
  • falls back to an LLM when no FAQ match is found (optional)

Run locally

python -m venv .venv
# Windows: .venv\Scripts\activate
source .venv/bin/activate

pip install -r requirements.txt
python app.py

Open the URL printed in your terminal (usually http://127.0.0.1:7860).

Enable LLM fallback (optional)

Set an API key:

export OPENAI_API_KEY="YOUR_KEY"
# optional:
export OPENAI_MODEL="gpt-5.2"
python app.py

If OPENAI_API_KEY is not set, the app will still run and will gracefully respond when no FAQ match is found.

Deploy on Replit (preferred by prompt)

  1. Create a new Replit (Python)
  2. Add these files
  3. Add OPENAI_API_KEY (Secrets) if you want LLM fallback
  4. Run: python app.py

Replit quick-start

Option A: Import this zip

  1. Create a new Repl → choose Python
  2. Upload and extract this project zip into the Repl
  3. Click Run (the .replit file runs python app.py)

Option B: Import from GitHub

  1. Create a new Repl → Import from GitHub
  2. Paste your repo URL
  3. Click Run

Secrets (optional, for LLM fallback)

  • Add OPENAI_API_KEY in Replit → Secrets (lock icon)
  • Optionally add OPENAI_MODEL (defaults to gpt-5.2)

Notes:

  • Replit sets a PORT environment variable automatically; app.py uses it for Gradio.
  • If installs ever fail, open the Shell and run: pip install -r requirements.txt

Hugging Face Spaces deploy

  1. Create a new Space on Hugging Face and choose Gradio.
  2. Upload these files (or push via git).
  3. (Optional) Add OPENAI_API_KEY and OPENAI_MODEL under Settings → Secrets.
  4. Wait for the build and open the Space URL.

Notes for Hugging Face Spaces

This build avoids ChatInterface(type=...) for compatibility with older Gradio versions on some hosts.

Free-key LLM fallback (recommended: Groq)

For a lightweight demo without entering payment details, you can use Groq's free tier by setting:

  • GROQ_API_KEY
  • (optional) GROQ_MODEL (default: llama-3.3-70b-versatile)

On Hugging Face Spaces: Settings → Secrets.

If you set both GROQ_API_KEY and OPENAI_API_KEY, Groq is used first.

Improving Groq fallback answers about Thoughtful AI

The LLM fallback includes a short, hardcoded context summary of Thoughtful AI (derived from thoughtful.ai), plus the FAQ Q/A pairs, to keep responses grounded when a user's question doesn't match an FAQ entry.

Edit THOUGHTFUL_AI_CONTEXT in llm_fallback.py if you want to add more product/company details.

About

A lightweight Python agent that handles FAQ queries from a JSON config and falls back to OpenAI or Groq for general questions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages