Spaces:
Build error
Build error
Update agent/planning_agent.py
Browse files- agent/planning_agent.py +7 -5
agent/planning_agent.py
CHANGED
|
@@ -24,6 +24,7 @@ llm = None
|
|
| 24 |
chat_memory = None
|
| 25 |
query_memory = None
|
| 26 |
agent = None
|
|
|
|
| 27 |
|
| 28 |
def initialize_planning_agent(llm_instance, chat_memory_instance, query_memory_instance, clearml_instance):
|
| 29 |
global llm, chat_memory, query_memory, agent, clearml_callback
|
|
@@ -145,7 +146,7 @@ def summarize_chat_history():
|
|
| 145 |
except Exception as e:
|
| 146 |
logger.error(f"Error summarizing chat history: {str(e)}")
|
| 147 |
|
| 148 |
-
def route_query(query):
|
| 149 |
# Summarize chat history before routing
|
| 150 |
summarize_chat_history()
|
| 151 |
# Get original query from memory if needed
|
|
@@ -185,10 +186,11 @@ def compose_response(response):
|
|
| 185 |
def execute(query):
|
| 186 |
try:
|
| 187 |
# Store original query
|
| 188 |
-
query_memory.memories['original_query'] = query
|
| 189 |
-
|
| 190 |
-
f"Process this user query: {query}"
|
| 191 |
-
)
|
|
|
|
| 192 |
except Exception as e:
|
| 193 |
logger.error(f"Error in planning agent: {str(e)}")
|
| 194 |
return f"Error in planning agent: {str(e)}"
|
|
|
|
| 24 |
chat_memory = None
|
| 25 |
query_memory = None
|
| 26 |
agent = None
|
| 27 |
+
clearml_callback = None
|
| 28 |
|
| 29 |
def initialize_planning_agent(llm_instance, chat_memory_instance, query_memory_instance, clearml_instance):
|
| 30 |
global llm, chat_memory, query_memory, agent, clearml_callback
|
|
|
|
| 146 |
except Exception as e:
|
| 147 |
logger.error(f"Error summarizing chat history: {str(e)}")
|
| 148 |
|
| 149 |
+
def route_query(query, callback):
|
| 150 |
# Summarize chat history before routing
|
| 151 |
summarize_chat_history()
|
| 152 |
# Get original query from memory if needed
|
|
|
|
| 186 |
def execute(query):
|
| 187 |
try:
|
| 188 |
# Store original query
|
| 189 |
+
query_memory.memories['original_query'] = query
|
| 190 |
+
response = agent.run(
|
| 191 |
+
f"Process this user query: {query}")
|
| 192 |
+
clearml_callback.flush_tracker(langchain_asset=planning_agent, name="Planning agent", finish=True)
|
| 193 |
+
return response
|
| 194 |
except Exception as e:
|
| 195 |
logger.error(f"Error in planning agent: {str(e)}")
|
| 196 |
return f"Error in planning agent: {str(e)}"
|