Spaces:
Build error
Build error
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -458,16 +458,25 @@ wikiq_tool = wikidata_query
|
|
| 458 |
# Step 7: Create the Planner-Agent Logic
|
| 459 |
# -------------------------------
|
| 460 |
# Define the agent tool set
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
tools = [wiki_tool, calc_tool, file_tool, web_tool, arvix_tool, youtube_tool, video_tool, analyze_tool, wikiq_tool]
|
| 462 |
|
|
|
|
|
|
|
|
|
|
| 463 |
# Create an agent using the planner, task classifier, and decision logic
|
| 464 |
agent = initialize_agent(
|
| 465 |
tools=tools,
|
| 466 |
-
llm=llm,
|
| 467 |
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 468 |
verbose=True
|
| 469 |
)
|
| 470 |
|
|
|
|
|
|
|
| 471 |
# -------------------------------
|
| 472 |
# Step 8: Use the Planner, Classifier, and Decision Logic
|
| 473 |
# -------------------------------
|
|
|
|
| 458 |
# Step 7: Create the Planner-Agent Logic
|
| 459 |
# -------------------------------
|
| 460 |
# Define the agent tool set
|
| 461 |
+
from langchain.chat_models import ChatOpenAI
|
| 462 |
+
from langchain.agents import initialize_agent, AgentType
|
| 463 |
+
|
| 464 |
+
# Define the tools (as you've already done)
|
| 465 |
tools = [wiki_tool, calc_tool, file_tool, web_tool, arvix_tool, youtube_tool, video_tool, analyze_tool, wikiq_tool]
|
| 466 |
|
| 467 |
+
# Define the LLM before using it
|
| 468 |
+
llm = ChatOpenAI(temperature=0, model="gpt-4") # or "gpt-3.5-turbo"
|
| 469 |
+
|
| 470 |
# Create an agent using the planner, task classifier, and decision logic
|
| 471 |
agent = initialize_agent(
|
| 472 |
tools=tools,
|
| 473 |
+
llm=llm,
|
| 474 |
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 475 |
verbose=True
|
| 476 |
)
|
| 477 |
|
| 478 |
+
|
| 479 |
+
|
| 480 |
# -------------------------------
|
| 481 |
# Step 8: Use the Planner, Classifier, and Decision Logic
|
| 482 |
# -------------------------------
|