This folder contains a self-contained copy of the Avatar HotpotQA demo with a FastAPI backend, a lightweight frontend, and the optimized model bundle.
server.py– FastAPI app exposing/api/questionsand/api/run.frontend/– Static site (index.html,style.css,main.js).model/HotpotOptimized– Serialized Avatar agent (copied from the training run).
Install the Python dependencies (Python 3.10+ recommended):
pip install \
fastapi "uvicorn[standard]" \
datasets dspy dill \
langchain langchain-community \
arxivNotes:
- The backend tries to instantiate LangChain's
GoogleSerperAPIWrapper(web search) andArxivAPIWrapper(paper metadata). If they fail to start—because the packages or credentials are missing—it falls back to an offline cache of thetaesiri/arxiv_qadataset. Installing the packages above enables the real tools. - To let
GoogleSerperAPIWrapperrun, exportSERPER_API_KEYwith a valid Serper.dev token before startinguvicorn. - The hard-coded DashScope-compatible credentials at the top of
server.pymirror the training setup; adjustAPI_KEY,BASE, andMODELthere (or via environment variables) to match your deployment.
From the Avatar_Demo folder:
uvicorn server:app --host 127.0.0.1 --port 8000 --reloadThis serves the API at http://127.0.0.1:8000.
In a new terminal:
cd frontend
python -m http.server 5500Then open http://127.0.0.1:5500 in your browser.
Use the dropdown to pick one of the curated questions or type your own, and compare the baseline vs Avatar optimized agent outputs.