如何为agent设置超时
本笔记本介绍如何在一定时间后限制代理执行器。这对于防止长时间运行的代理运行非常有用。
from langchain.agents import load_tools
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from langchain.llms import OpenAI
llm = OpenAI(temperature=0)tools = [Tool(name = "Jester", func=lambda x: "foo", description="useful for answer the question")]首先,让我们运行一个正常代理以展示没有此参数会发生什么。对于这个例子,我们将使用一个特别制作的对抗性例子,试图欺骗它永远继续下去。
尝试运行下面的单元格,看看会发生什么。