This repository provides CoW Protocol Integration Documentation chat: a RAG-based Q&A for Order Book API, order creation, approvals, and errors (aligned with the CoW Grants RFP).
Planning: docs/COW_POC_PLAN.md, docs/COW_PROPOSAL_NEXT_PHASE.md.
CoW AI is a RAG chatbot that answers integration-focused questions about CoW Protocol using CoW docs and the Order Book OpenAPI spec. Stack: file-based docs + FAISS index, Gemini for embeddings and chat, no database.
data/– Raw and processed datasets (e.g.data/cow-docs/).pkg/– Backend and RAG:cow-app(API),cow-brains(CoW RAG),rag-brains(shared RAG pipeline),cow-core(logging).scripts/– Dataset and OpenAPI scripts, tests.www/– Next.js frontend.
- Python 3.12+
- Poetry
- Node.js 20+
- Yarn
-
Clone and enter the repo:
git clone https://github.com/bleu/cow-ai-tools.git cd cow-ai-tools -
Install backend (from repo root, with Poetry in each package or use a venv and install from
pkg/cow-app):cd pkg/cow-app && poetry install cd ../cow-brains && poetry install cd ../rag-brains && poetry install cd ../cow-core && poetry install
-
Install frontend:
cd www && yarn install
From repo root:
bash scripts/test_cow_poc.sh-
Create CoW docs artifact
python scripts/cow-1-create-docs-dataset/main.py --output data/cow-docs/cow_docs.txt
-
(Optional) Fetch Order Book OpenAPI
python scripts/cow-2-fetch-openapi/main.py --output data/cow-docs/openapi.yml
-
Build FAISS index (set
GOOGLE_API_KEY)cd pkg/cow-app && OP_CHAT_BASE_PATH=../../data GOOGLE_API_KEY=... poetry run python -m cow_brains.build_faiss
-
Run the API
cd pkg/cow-app && cp .envrc.example .envrc # edit GOOGLE_API_KEY direnv allow # or source .envrc poetry run uvicorn cow_app.api:app --host 0.0.0.0 --port 8000
Or use the helper script from repo root:
bash scripts/run-backend.sh(ensure PYTHONPATH includespkg/cow-app:pkg/rag-brains:pkg/cow-brains:pkg/cow-core). -
Run the frontend
cd www && cp .envrc.example .envrc # Set NEXT_PUBLIC_CHAT_API_URL=http://localhost:8000/predict yarn dev
Golden questions: docs/cow_golden_questions.md. Evaluation: docs/cow_poc_evaluation.md. Quickstart: docs/cow_quickstart_first_order.md.
- Backend (Railway/Render): docs/deploy-backend-railway.md.
- Frontend + serverless API (Vercel): docs/deploy-vercel.md.
Open an issue on GitHub or contact the maintainers.