法律文档智能处理系统

AI驱动的法律文档智能处理系统,提供PDF自动处理、元数据提取、混合搜索及MCP集成功能,适用于法律案例管理和分析。

  • by Jobikinobi
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Jobikinobi/HOLE-Legal-Intelligence-alpha

使用说明

HOLE法律情报系统(阿尔法)

人工智能支持的法律文件智能-部署和运营 ✅

带电系统

🌐 工作者URL: https://legal-intelligence-alpha.joe-1a2.workers.dev
📊 状态: 检查健康状况
📂 GitHub: https://github.com/Jobikinobi/HOLE-Legal-Intelligence-alpha

这个系统做什么

核心能力(目前正在发挥作用✅)

  1. 自动PDF处理

    • 上传PDF→ 使用Unstructured.io提取结构
    • Claude AI自动提取法律元数据
    • 在PostgreSQL中存储+生成嵌入
    • 处理时间:每份文件3-9秒
  2. 智能元数据提取

    • 法院、县、管辖权
    • 案件编号和日期
    • 当事人(原告、被告等)
    • 演员(所有提及的人)
    • 法律概念(布雷迪违规、欺诈等)
    • 判例法引用
  3. 混合搜索 (已完成95%)

    • 按元数据进行SQL筛选(有效✅)
    • 语义向量搜索(待Voyage AI切换)
    • 组合:尽可能强大的法律搜索
  4. MCP集成

    • 模型上下文协议服务器
    • 基于HTTP的JSON-RPC 2.0
    • 4法律情报工具
    • 可与Claude Desktop或任何MCP客户端一起使用

快速启动(新机器)

一个命令设置

# Clone and navigate
git clone https://github.com/Jobikinobi/HOLE-Legal-Intelligence-alpha.git
cd HOLE-Legal-Intelligence-alpha

# Run verification
./scripts/verify-setup.sh

# If missing prerequisites, install them, then:
./scripts/setup-infrastructure.sh  # Creates Cloudflare resources
./scripts/deploy.sh                # Deploys Worker
./scripts/test-system.sh           # Verifies everything works

先决条件

所需工具:

  • Node.js 20+
  • pnpm
  • wrangler(Cloudflare CLI)
  • 分泌物
  • PostgreSQL客户端
  • jq,curl

在macOS上安装:

brew install node pnpm jq postgresql@15
npm install -g wrangler
cargo install --git https://github.com/ripatel-fd/secretspec

所需帐户:

  • Cloudflare(工人)
  • 霓虹灯(PostgreSQL)
  • 松果体(矢量数据库)
  • OpenAI或Voyage AI(嵌入)
  • 无烟煤(Claude API)
  • Unstructure.io(文档处理)

详细设置指南

📖 看: docs/PORTABLE_SETUP.md

建筑

┌─────────────────────────────────────────────────┐
│  Cloudflare Workers (Edge Network)              │
│  https://legal-intelligence-alpha.workers.dev   │
│                                                 │
│  ┌──────────────────────────────────────────┐  │
│  │ MCP Server (JSON-RPC 2.0 over HTTP)      │  │
│  │ - legal_track_document                   │  │
│  │ - legal_search_documents                 │  │
│  │ - legal_analyze_document                 │  │
│  │ - legal_get_document                     │  │
│  └─────────────┬────────────────────────────┘  │
│                │                                │
│    ┌───────────┼───────────────────────┐       │
│    │           │                       │       │
│    ▼           ▼                       ▼       │
│  ┌────┐    ┌─────────┐           ┌────────┐   │
│  │ R2 │    │Hyperdrive│           │   KV   │   │
│  │PDF │    │  (Neon) │           │ Cache  │   │
│  └────┘    └─────────┘           └────────┘   │
└─────────────────┼───────────────────────────────┘
                  │
        ┌─────────┴─────────┐
        │                   │
        ▼                   ▼
  ┌──────────┐       ┌──────────┐
  │   Neon   │       │ Pinecone │
  │PostgreSQL│       │ Vectors  │
  │ 3 schemas│       │1024 dims │
  └──────────┘       └──────────┘

MCP工具

1. legal_track_document

通过自动元数据提取跟踪数据库中的PDF。

输入:

{
  "title": "Motion to Dismiss - Doe v. Smith",
  "filePath": "test/motion.pdf",
  "category": "motion",
  "project": "alt"
}

输出:文档UUID+提取的元数据

2. legal_search_documents

混合SQL+向量搜索。

输入:

{
  "query": "emails about protective order coordination",
  "filters": {
    "category": ["email"],
    "actors": ["Maria dos Santos"],
    "dateRange": {"start": "2025-09-01", "end": "2025-09-30"}
  },
  "limit": 10
}

输出:使用元数据对搜索结果进行排名

3. legal_analyze_document

深入分析PDF的结构和内容。

输入:

{
  "filePath": "test/document.pdf",
  "operations": ["extract_metadata", "extract_citations"],
  "deepAnalysis": false
}

输出:完整的元数据+分析

4. legal_get_document

通过UUID检索完整的文档详细信息。

输入:

{
  "documentId": "uuid-here",
  "project": "alt"
}

输出:完整的文档记录

项目结构

HOLE-Legal-Intelligence-alpha/
├── docs/                              # 📚 All documentation
│   ├── PORTABLE_SETUP.md             # Complete setup guide
│   ├── DEPLOYMENT_CHECKLIST.md       # Step-by-step checklist
│   ├── VOYAGE_AI_SETUP.md            # Embedding model guide
│   └── API_EXAMPLES.md               # Usage examples
├── scripts/                           # 🔧 Automation scripts
│   ├── verify-setup.sh               # Check prerequisites
│   ├── setup-infrastructure.sh       # Create Cloudflare resources
│   ├── deploy.sh                     # Build and deploy
│   └── test-system.sh                # Run tests
├── migrations/                        # 🗄️ Database schema
│   └── 001_multi_tenant_schema.sql   # Initial schema
├── src/                               # 💻 Source code
│   ├── index.ts                      # Main Worker + HTTP transport
│   ├── schemas/                      # MCP tool schemas
│   ├── services/                     # Business logic
│   │   ├── neon.ts                  # PostgreSQL queries
│   │   ├── pinecone.ts              # Vector search
│   │   ├── embeddings.ts            # Embedding generation
│   │   ├── unstructured.ts          # PDF processing
│   │   └── metadata-extractor.ts    # Claude extraction
│   └── tools/                        # MCP tool handlers
├── wrangler.toml                      # Cloudflare config
├── secretspec.toml                    # Secret definitions
├── package.json                       # Dependencies
├── STATUS.md                          # Current system status
└── SESSION_SUMMARY.md                 # Quick reference

当前状态

系统:完成95%✅
部署: https://legal-intelligence-alpha.joe-1a2.workers.dev
最后更新:2025年11月8日

工作部件

  • ✅ Cloudflare Workers(已部署)
  • ✅ Neon PostgreSQL(通过Hyperdrive)
  • ✅ R2对象存储
  • ✅ 非结构化.io处理
  • ✅ 克劳德元数据提取
  • ✅ OpenAI嵌入(ada-002)
  • ✅ HTTP/JSON-RPC传输
  • ✅ 数据库查询和插入

待定(15分钟修复)

测试结果

  • 4份文件已成功处理
  • 全部存储在PostgreSQL中
  • 嵌入生成(261个令牌/文档)
  • 元数据提取工作

脚本

验证设置

./scripts/verify-setup.sh

检查所有先决条件和配置。

设置基础结构

./scripts/setup-infrastructure.sh

自动创建Cloudflare资源(Hyperdrive、R2、KV)。

部署

./scripts/deploy.sh

构建TypeScript,部署Worker,运行测试。

测试系统

./scripts/test-system.sh

进行全面的健康检查。

文档

文件 目的
状态.md 当前部署状态
会议_三月.md 最新会议记录
docs/PORTABLE_SETUP.md 完整的设置指南
docs/DEPLOYMENT_CHECKLIST.md 分步检查表
docs/VOYAGE_AI_SETUP.md 嵌入模型修复

演出

  • 处理:每份文件3-9秒
  • 工人创业:57毫秒
  • 数据库查询:<100ms
  • 包大小:已压缩645 KB

贡献

这是一个私人HOLE基金会项目。对于问题或疑问,请打开GitHub问题。

许可证

私人HOLE基金会


快速链接: