NINU / agent.py
Ali-Developments's picture
Update agent.py
888ca1a verified
raw
history blame
726 Bytes
from langgraph.graph import StateGraph, END
from langchain_core.runnables import Runnable
from langchain_core.messages import HumanMessage, AIMessage
# عقدة ترد على المستخدم
def reply_node(state: dict) -> dict:
user_msg = state["messages"][-1].content
return {"messages": state["messages"] + [AIMessage(content=f"🤖 Agent Response: {user_msg}")]} # الرد بسيط
def ninu() -> Runnable:
graph = StateGraph()
# نحدد الحالة الابتدائية
graph.add_node("reply", reply_node)
# نحدد البداية والنهاية
graph.set_entry_point("reply")
graph.add_edge("reply", END)
# نبني النموذج النهائي
return graph.compile()