Skip to content

Repository files navigation

DocuPulse

Multi-tenant contract-analysis RAG application with human-in-the-loop approval for high-value actions.

What it does

[2-3 sentences: ingest contracts → chunk/embed → tenant-scoped retrieval → grounded agent answers with an honesty rule → gated legal-alert tool with human approval.]

Stack

  • Laravel 11 (PHP 8.4), Docker
  • Postgres + pgvector (vector(1536), cosine distance)
  • laravel/ai SDK — LLM: gpt-5.4; embeddings: text-embedding-3-small
  • Queue + cache: database driver

Architecture

  • Ingestion: [ContractChunker → embeddings → IngestContract job]
  • Retrieval: tenant-scoped nearest-neighbour (filter before distance)
  • Agent: ContractAnalyst — three-part prompt, answers only from context
  • Tools: FlagHighValueContract, SendLegalAlert (approval-gated)
  • Production: cost tracking, provider failover, semantic cache, tenant isolation
  • Eval: harness + LLM-as-judge with keyword gating
  • HITL: persisted conversations; SendLegalAlert requires human approve/reject/edit

Setup

[Verify against your actual docker-compose + .env.example:]

  1. cp .env.example .env and set: OPENAI_API_KEY, ANTHROPIC_API_KEY, DB_*
  2. docker compose up -d
  3. php artisan migrate
  4. [ingestion command — verify the actual signature]

Usage

[Verify each command signature against app/Console/Commands:]

  • Ask: php artisan docupulse:ask "question" --tenant_id=1
  • List approvals: php artisan docupulse:approvals
  • Resolve: php artisan docupulse:resolve <conv> <toolCall> approve|reject|edit
  • API: POST /api/ask, GET /api/approvals, POST /api/approvals/resolve

About

AI-powered contract analysis: RAG Q&A over legal documents with a tool-calling agent, pgvector semantic search, semantic caching, and multi-tenant isolation — built on Laravel + the laravel/ai SDK.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages