Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
|
4 |
-
from langchain import
|
5 |
from langchain.agents import load_tools, initialize_agent
|
6 |
from langchain.agents import AgentType
|
7 |
from langchain.tools import AIPluginTool
|
@@ -9,10 +9,10 @@ from langchain.tools import AIPluginTool
|
|
9 |
def run(prompt, plugin_json, openai_api_key):
|
10 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
11 |
tool = AIPluginTool.from_plugin_url(plugin_json)
|
12 |
-
llm =
|
13 |
tools = load_tools(["requests_all"])
|
14 |
tools += [tool]
|
15 |
-
agent_chain = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=
|
16 |
return agent_chain.run(prompt)
|
17 |
|
18 |
title="""
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
|
4 |
+
from langchain.chat_agents import ChatOpenAI
|
5 |
from langchain.agents import load_tools, initialize_agent
|
6 |
from langchain.agents import AgentType
|
7 |
from langchain.tools import AIPluginTool
|
|
|
9 |
def run(prompt, plugin_json, openai_api_key):
|
10 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
11 |
tool = AIPluginTool.from_plugin_url(plugin_json)
|
12 |
+
llm = ChatOpenAI(temperature=0, max_tokens=1000)
|
13 |
tools = load_tools(["requests_all"])
|
14 |
tools += [tool]
|
15 |
+
agent_chain = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=False, reduce_k_below_max_tokens=True)
|
16 |
return agent_chain.run(prompt)
|
17 |
|
18 |
title="""
|