This case is based on RagPlanner and builds a simple legal consultation agent. It provides relevant legal advice by retrieving related articles from the Civil Code and Criminal Law and combining them with the case background.
This case utilizes the Qianwen large model and the DashScope embedding feature. Before using it, you need to configure the DASHSCOPE_API_KEY in your environment variables.
The legal knowledge base is based on the Knowledge Component in agentUniverse. By embedding the original text of legal articles and storing them in the ChromaDB vector database, it creates a knowledge base that the agent can easily reference and retrieve.
Original legal texts:
You can refer to the following code:
To make it convenient for you, we have placed the database files with relevant information in this directory, If you want to build the knowledge base from scratch, you can modify the following part of the code:
# Initialize the knowledge
# self.insert_knowledge()
Remove the comment from self.insert_knowledge() to rebuild the database.
This agent involves the following two files:
- law_rag_agent.py: Defines the agent's input and output
- law_rag_agent.yaml: Defines the agent's related prompts