CoolFace
Apppublic

Chikaiduma/meridian-support-bot

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes
App README

Meridian Customer Support Chatbot (AI engineer assessment)

Deployable prototype: Gradio UI, OpenAI GPT-4o-mini (low per-conversation cost), and MCP (Streamable HTTP) to Meridian’s order-mcp service (products, customers, orders, cart/checkout via tools).

Architecture

  • —meridian/config.py — environment-based settings (no secrets in code).
  • —meridian/mcp_session.py — httpx timeouts + official mcp streamable HTTP client, initialized session per request.
  • —meridian/tool_format.py — maps MCP tool JSON Schema to OpenAI function tools.
  • —meridian/agent.py — tool loop: list_tools → OpenAI with tools → call_tool until final natural-language reply.
  • —meridian/prompts.py — support persona, auth and safety instructions.
  • —app.py — Gradio chat; stores full OpenAI message history (including tool traces) in state for correct multi-turn context.

MCP tools (discovered at runtime)

The server exposes: list_products, get_product, search_products, get_customer, verify_customer_pin, list_orders, get_order, create_order. The model chooses tools from the live list_tools result.

Local run

bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # set OPENAI_API_KEY; optional OPENAI_BASE_URL (e.g. OpenRouter)
python app.py

Open the printed URL (default http://127.0.0.1:7860).

Tests

bash
pytest

Hugging Face Spaces

  1. 1.Create a Gradio Space (or Docker if you use the provided Dockerfile).
  2. 2.Set Secrets (or Variables):
  3. 3.OPENAI_API_KEY — required.
  4. 4.OPENAI_BASE_URL — optional; leave unset for api.openai.com, or set e.g. https://openrouter.ai/api/v1 for OpenRouter (use models like openai/gpt-4o-mini).
  5. 5.MCP_SERVER_URL — optional; defaults to the assessment server if unset in code.
  6. 6.Main file: app.py (Gradio default entry works with this layout).

Security notes (for production review)

  • —API keys only via environment / platform secrets.
  • —Customer PINs are redacted in server logs for verify_customer_pin.
  • —MCP is the only path to business data; the app does not talk to a database directly.
  • —Tune MAX_TOOL_ROUNDS and timeouts for abuse protection and cost control.

Cost

Default model gpt-4o-mini keeps inference cost low; override with OPENAI_MODEL if your org standardizes on another flash/mini tier.