Spaces:
Build error
Build error
Update agent/planning_agent.py
Browse files- agent/planning_agent.py +18 -3
agent/planning_agent.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
from langchain_openai import ChatOpenAI
|
| 2 |
from langchain.agents import initialize_agent, AgentType
|
|
|
|
| 3 |
from langchain.tools import Tool
|
| 4 |
from langchain.memory import ConversationBufferMemory, SimpleMemory
|
|
|
|
|
|
|
| 5 |
import agent.router_agent as router_agent
|
| 6 |
import agent.product_review_agent as product_review_agent
|
| 7 |
import agent.generic_agent as generic_agent
|
|
@@ -22,14 +25,26 @@ chat_memory = None
|
|
| 22 |
query_memory = None
|
| 23 |
agent = None
|
| 24 |
|
| 25 |
-
def initialize_planning_agent(llm_instance, chat_memory_instance, query_memory_instance
|
| 26 |
-
global llm, chat_memory, query_memory, agent
|
| 27 |
|
| 28 |
llm = llm_instance
|
| 29 |
chat_memory = chat_memory_instance
|
| 30 |
query_memory = query_memory_instance
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
|
|
|
|
|
|
| 33 |
# Initialize agents
|
| 34 |
router_agent.initialize_router_agent(llm, chat_memory)
|
| 35 |
product_review_agent.initialize_product_review_agent(llm, chat_memory)
|
|
|
|
| 1 |
from langchain_openai import ChatOpenAI
|
| 2 |
from langchain.agents import initialize_agent, AgentType
|
| 3 |
+
from langchain.agents import AgentType, initialize_agent, load_tools
|
| 4 |
from langchain.tools import Tool
|
| 5 |
from langchain.memory import ConversationBufferMemory, SimpleMemory
|
| 6 |
+
from langchain_community.callbacks import ClearMLCallbackHandler
|
| 7 |
+
from langchain_core.callbacks import StdOutCallbackHandler
|
| 8 |
import agent.router_agent as router_agent
|
| 9 |
import agent.product_review_agent as product_review_agent
|
| 10 |
import agent.generic_agent as generic_agent
|
|
|
|
| 25 |
query_memory = None
|
| 26 |
agent = None
|
| 27 |
|
| 28 |
+
def initialize_planning_agent(llm_instance, chat_memory_instance, query_memory_instance):
|
| 29 |
+
global llm, chat_memory, query_memory, agent
|
| 30 |
|
| 31 |
llm = llm_instance
|
| 32 |
chat_memory = chat_memory_instance
|
| 33 |
query_memory = query_memory_instance
|
| 34 |
+
|
| 35 |
+
# Setup and use the ClearML Callback
|
| 36 |
+
clearml_callback = ClearMLCallbackHandler(
|
| 37 |
+
task_type="inference",
|
| 38 |
+
project_name="langchain_callback_demo",
|
| 39 |
+
task_name="llm",
|
| 40 |
+
tags=["test"],
|
| 41 |
+
# Change the following parameters based on the amount of detail you want tracked
|
| 42 |
+
visualize=True,
|
| 43 |
+
complexity_metrics=True,
|
| 44 |
+
stream_logs=True,)
|
| 45 |
|
| 46 |
+
callbacks = [StdOutCallbackHandler(), clearml_callback]
|
| 47 |
+
|
| 48 |
# Initialize agents
|
| 49 |
router_agent.initialize_router_agent(llm, chat_memory)
|
| 50 |
product_review_agent.initialize_product_review_agent(llm, chat_memory)
|