feat: solution for 'Экзамен: Самокорректирующийся агент'

This commit is contained in:
2026-07-01 14:28:44 +03:00
parent baf18c5876
commit f14d41830d
8 changed files with 139 additions and 174 deletions
+20 -9
View File
@@ -1,14 +1,25 @@
from langchain_openai import OpenAI
from langgraph import Graph
from langgraph.graph import StateGraph
from src.graph import build_graph
from langchain_core.messages import HumanMessage
def main():
# Initialize OpenAI LLM
llm = OpenAI(model="gpt-3.5-turbo")
# Create a simple LangGraph graph instance
graph = Graph()
print("OpenAI and LangGraph imports succeeded.")
print(f"LLM instance: {llm}")
print(f"Graph instance: {graph}")
# Build and compile the graph
graph = build_graph()
app = graph.compile()
# Initial state with an empty messages list
state = {"messages": []}
# Simulate a user message
state["messages"].append(HumanMessage(content="Hello, agent!"))
# Run the graph
result = app.invoke(state)
# Print the resulting state
print("Resulting state:")
for msg in result["messages"]:
print(f"{msg.__class__.__name__}: {msg.content}")
if __name__ == "__main__":
main()