CoolFace
Apppublic

Geraldino07/Meridian-ChatBot

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

Meridian Electronics customer support chatbot

Production-minded prototype: Gradio UI → OpenAI `gpt-4o-mini` (tool calling) → MCP Streamable HTTP → Meridian order backend (list_products, search_products, get_product, customer auth, orders, create_order, etc.).

Architecture

  • —`src/meridian_bot/mcp_client/` — Streamable HTTP session, list_tools, safe call_tool.
  • —`src/meridian_bot/llm/` — MCP tool defs → OpenAI tools; agent loop with round limits.
  • —`src/meridian_bot/agent/` — System prompt + history trim + orchestration.
  • —`app.py` — Gradio Blocks + Chatbot(type="messages").

Discovered tools are documented in `docs/MCP_TOOLS.md`.

Cost controls

  • —`gpt-4o-mini` as default LLM.
  • —Max agent rounds (default 10) to cap tool+LLM iterations.
  • —Trimmed chat history (default last 24 turns worth of messages).

Local setup

Requires Python 3.10+ (3.12 recommended).

bash
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
export OPENAI_API_KEY=sk-...
# Optional override:
# export MCP_SERVER_URL=https://order-mcp-74afyau24q-uc.a.run.app/mcp
python app.py

Open http://127.0.0.1:7860

MCP smoke test (no LLM key)

bash
python scripts/smoke_mcp.py

Tests

bash
pytest tests/ -q

Hugging Face Spaces

  1. 1.Create a Gradio Space from this repo.
  2. 2.Settings → Secrets: add OPENAI_API_KEY (required). Optionally MCP_SERVER_URL if the endpoint changes.
  3. 3.Build: default install uses requirements.txt (installs the local package per PEP 508 .).
  4. 4.Ensure the Space allows outbound HTTPS to *.run.app (default on HF).

If requirements.txt with . does not work in your Space UI, set Build command to: pip install .

Docker

bash
docker build -t meridian-bot .
docker run -e OPENAI_API_KEY=sk-... -p 7860:7860 meridian-bot

Environment variables

VariableDefaultDescription
OPENAI_API_KEY—OpenAI API key
OPENAI_MODELgpt-4o-miniChat model
MCP_SERVER_URLCloud Run URL in planStreamable HTTP MCP base URL
MAX_AGENT_ROUNDS10Max LLM↔tool iterations per message
MAX_HISTORY_MESSAGES24Max prior user+assistant messages considered
PORT7860Listen port (app.py)

License

MIT — educational / exam use.