feat: solution for 'Экзамен: Самокорректирующийся агент'
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user