Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from langgraph.prebuilt import create_react_agent
|
|
| 6 |
from mcp import ClientSession, StdioServerParameters
|
| 7 |
from mcp.client.stdio import stdio_client
|
| 8 |
from langchain_mcp_adapters.tools import load_mcp_tools
|
| 9 |
-
from langchain_core.messages import HumanMessage
|
| 10 |
|
| 11 |
# --- Configuration ---
|
| 12 |
NEBIUS_API_KEY = os.getenv("NEBIUS_API_KEY")
|
|
@@ -86,11 +86,18 @@ async def run_tutor_dashboard(user_message):
|
|
| 86 |
temperature=0.7
|
| 87 |
)
|
| 88 |
|
| 89 |
-
# FIXED:
|
| 90 |
-
|
|
|
|
| 91 |
|
| 92 |
# Run Agent
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
response = await agent_executor.ainvoke(inputs)
|
| 95 |
final_text = response["messages"][-1].content
|
| 96 |
|
|
|
|
| 6 |
from mcp import ClientSession, StdioServerParameters
|
| 7 |
from mcp.client.stdio import stdio_client
|
| 8 |
from langchain_mcp_adapters.tools import load_mcp_tools
|
| 9 |
+
from langchain_core.messages import HumanMessage, SystemMessage
|
| 10 |
|
| 11 |
# --- Configuration ---
|
| 12 |
NEBIUS_API_KEY = os.getenv("NEBIUS_API_KEY")
|
|
|
|
| 86 |
temperature=0.7
|
| 87 |
)
|
| 88 |
|
| 89 |
+
# FIXED: Removed 'messages_modifier' to avoid TypeError.
|
| 90 |
+
# We now pass the System Prompt manually in the inputs.
|
| 91 |
+
agent_executor = create_react_agent(llm, tools)
|
| 92 |
|
| 93 |
# Run Agent
|
| 94 |
+
# We prepend the SystemMessage to ensure the agent follows instructions
|
| 95 |
+
inputs = {
|
| 96 |
+
"messages": [
|
| 97 |
+
SystemMessage(content=SYSTEM_PROMPT),
|
| 98 |
+
HumanMessage(content=user_message)
|
| 99 |
+
]
|
| 100 |
+
}
|
| 101 |
response = await agent_executor.ainvoke(inputs)
|
| 102 |
final_text = response["messages"][-1].content
|
| 103 |
|