AI co-pilots can be useful for summarizing local laws and regulations. I use Langchain to built a ChatGPT agent that looks up answers in the San Francisco building code as a proof of concept.
AI is extremely good at document synthesis and summarization. Laws are often extremely dense and challenging to parse. AI systems can act as a natural language interface between citizens and easier interpretation of government rules / regulations (e.g., zoning rules, building codes).
We want the AI to answer questions about local laws and regulation rather than the full corpus on which it was trained. To achieve this, we can create an index of specific local regulations that an AI agent uses: to show this, I embed the San Francisco building code in a vectorstore (Pinecone). I use Langchain as an interface for database QA on the index with the newly released ChatGPT API. ChatGPT acts as “computation” (distiller of information) on information stored in the index.
Workflow for ChatGPT QA over a set of local laws / regulations
As as test case, let’s assume we want to determine if we need a permit for a backyard shed. Section 106A.2 in the SF building code lists construction projects are exempt from a permit:
A building permit shall not be required for the following … One-story detached accessory buildings or structures used as tool and storage sheds, playhouses and similar uses, provided the projected roof area does not exceed 100 square feet
We use a simple streamlit to wrap the app and demonstrate that we can fetch the correct answer:
UI for ChatGPT operating on top of San Francisco building codes
A building permit is not required for a one-story detached accessory building or structure used as a tool and storage shed, playhouse, or similar use, provided the projected roof area does not exceed 100 square feet (9.29 m2).
More generally, AI can serve as an agent that answers questions but also interfaces with external services (e.g., search, government APIs) to produce more useful information related to search.
I make ChatGPT the Langchain agent and give it access to the vectorstore of building codes as well as and Google search. Then, we can ask the agent an open-ended question using both: