Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import requests
|
|
| 6 |
from typing import Optional, List
|
| 7 |
from langchain.llms.base import LLM
|
| 8 |
from langchain.agents import initialize_agent, AgentType,load_tools
|
|
|
|
| 9 |
from langchain.tools import Tool
|
| 10 |
from langchain_experimental.tools.python.tool import PythonREPLTool
|
| 11 |
import queue
|
|
@@ -70,7 +71,8 @@ tools = load_tools(
|
|
| 70 |
# ββββββββββββββββββββββββββββββ
|
| 71 |
python_tool = PythonREPLTool()
|
| 72 |
tools.append(Tool(name="python_repl", func=python_tool.run, description="Python μ½λλ₯Ό μ€νν©λλ€."))
|
| 73 |
-
|
|
|
|
| 74 |
# ββββββββββββββββββββββββββββββ
|
| 75 |
# β
νμΌ λꡬ
|
| 76 |
# ββββββββββββββββββββββββββββββ
|
|
@@ -110,14 +112,10 @@ tools.extend(FMT(root_dir=str(os.getcwd())).get_tools())
|
|
| 110 |
# ββββββββββββββββββββββββββββββ
|
| 111 |
# β
Agent μ΄κΈ°ν
|
| 112 |
# ββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
agent = initialize_agent(
|
| 115 |
-
tools,
|
| 116 |
-
llm,
|
| 117 |
-
memory=MEM(),
|
| 118 |
-
agent_type=AgentType.STRUCTURED_CHAT_REACT_DESCRIPTION,
|
| 119 |
-
verbose=True,
|
| 120 |
-
handle_parsing_errors=True)
|
| 121 |
|
| 122 |
# ββββββββββββββββββββββββββββββ
|
| 123 |
# β
Gradio UI
|
|
|
|
| 6 |
from typing import Optional, List
|
| 7 |
from langchain.llms.base import LLM
|
| 8 |
from langchain.agents import initialize_agent, AgentType,load_tools
|
| 9 |
+
from langchain.agents import AgentExecutor, create_structured_chat_agent
|
| 10 |
from langchain.tools import Tool
|
| 11 |
from langchain_experimental.tools.python.tool import PythonREPLTool
|
| 12 |
import queue
|
|
|
|
| 71 |
# ββββββββββββββββββββββββββββββ
|
| 72 |
python_tool = PythonREPLTool()
|
| 73 |
tools.append(Tool(name="python_repl", func=python_tool.run, description="Python μ½λλ₯Ό μ€νν©λλ€."))
|
| 74 |
+
from langchain import hub
|
| 75 |
+
prompt=hub.pull("hwchase17/structured-chat-agent")
|
| 76 |
# ββββββββββββββββββββββββββββββ
|
| 77 |
# β
νμΌ λꡬ
|
| 78 |
# ββββββββββββββββββββββββββββββ
|
|
|
|
| 112 |
# ββββββββββββββββββββββββββββββ
|
| 113 |
# β
Agent μ΄κΈ°ν
|
| 114 |
# ββββββββββββββββββββββββββββββ
|
| 115 |
+
mem=MEM()
|
| 116 |
+
agent = create_structured_chat_agent(llm, tools, prompt)
|
| 117 |
+
agent= AgentExecutor(agent=agent, tools=tools,memory=mem)
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
# ββββββββββββββββββββββββββββββ
|
| 121 |
# β
Gradio UI
|