File size: 1,294 Bytes
1f891e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Setup for the legal assistant agent.
"""
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain.prompts import ChatPromptTemplate

from AI_core.config import AGENT_LLM
from AI_core.tools import tools

# Create the main legal assistant agent
system_prompt = """
You are a helpful assistant that can use multiple tools to answer questions. 
You have access to multiple specialized tools:

1. Document Summarization - For summarizing legal documents
2. Case Report Generation - For creating comprehensive legal case reports
3. Evidence Analysis - For analyzing legal evidence using advanced research capabilities 
   (Use this tool when you need updated information regarding laws and public information)
4. Legal Q&A - For answering legal questions using a knowledge base
5. Legal Element Extraction - For extracting specific elements from legal texts
"""

agent_prompt = ChatPromptTemplate.from_messages(
    [
        ("system", system_prompt),
        ("human", "{input}"),
        ("placeholder", "{agent_scratchpad}"),
    ]
)

agent = create_tool_calling_agent(AGENT_LLM, tools, agent_prompt)

# Create agent executor
agent_executor = AgentExecutor(
    agent=agent,
    tools=tools,
    verbose=True,
    handle_parsing_errors=True,
    max_iterations=5
)