-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathl4m_agent.py
31 lines (28 loc) · 1016 Bytes
/
l4m_agent.py
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
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.prompts import MessagesPlaceholder
from langchain.memory import ConversationBufferMemory
def base_agent(
llm, tools, agent_type=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION
):
"""Base agent to perform xyz slippy map tiles operations.
llm: LLM object
tools: List of tools to use by the agent
"""
# chat_history = MessagesPlaceholder(variable_name="chat_history")
# memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
agent = initialize_agent(
llm=llm,
tools=tools,
agent=agent_type,
max_iterations=5,
early_stopping_method="generate",
verbose=True,
# memory=memory,
# agent_kwargs={
# "memory_prompts": [chat_history],
# "input_variables": ["input", "agent_scratchpad", "chat_history"],
# },
)
print("agent initialized")
return agent