law-cn-ai  by lvwzhen

AI legal assistant for Chinese law leveraging vector search

created 2 years ago
4,900 stars

Top 10.4% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides an AI legal assistant that leverages custom knowledge bases to enhance OpenAI's text completion capabilities. It's designed for developers and researchers looking to build domain-specific AI applications, offering a streamlined approach to integrating external data with large language models.

How It Works

The system follows a four-step process, separating knowledge base preprocessing from runtime query execution. At build time, .mdx files are chunked, converted into embeddings using OpenAI's API, and stored in a PostgreSQL database with the pgvector extension. Checksums are used to efficiently update embeddings only when source files change. At runtime, user queries are also embedded, and a similarity search is performed against the stored vectors to retrieve relevant document chunks. These chunks are then injected into an OpenAI GPT-3 prompt, and the response is streamed back to the client.

Quick Start & Requirements

  • Install/Run: Deploy to Vercel. Local development requires Docker for Supabase.
  • Prerequisites: OpenAI API Key, Node.js, pnpm, Docker.
  • Setup: Local setup involves configuring .env with OPENAI_KEY, starting Supabase via npx supabase start, and running the Next.js app with pnpm dev.
  • Links: Docs, pgvector, YouTube

Highlighted Details

  • Utilizes pgvector for efficient similarity search within PostgreSQL.
  • Implements a build-time embedding generation process for optimized knowledge base updates.
  • Streams responses from OpenAI for a more interactive user experience.
  • Leverages Vercel for simplified deployment and Supabase for database management.

Maintenance & Community

The project is based on a Supabase community template. Further community engagement or roadmap details are not explicitly provided in the README.

Licensing & Compatibility

The repository's license is not specified in the README. Compatibility for commercial use or closed-source linking would depend on the underlying licenses of its dependencies (OpenAI API, Next.js, Supabase, etc.).

Limitations & Caveats

The project relies heavily on the OpenAI API, incurring associated costs. The effectiveness of the legal assistant is directly tied to the quality and comprehensiveness of the provided .mdx legal documents.

Health Check
Last commit

2 years ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
1
Star History
26 stars in the last 90 days

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(Ex-VP of AI at Vercel; Founder of Turborepo; Author of Formik, TSDX).

chatgpt-pgvector by gannonh

0%
938
Domain-specific chat completions app
created 2 years ago
updated 2 years ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems) and Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind).

LightRAG by HKUDS

1.0%
19k
RAG framework for fast, simple retrieval-augmented generation
created 10 months ago
updated 21 hours ago
Feedback? Help us improve.