Orchestrate LangGraph Workflow and Evaluate

testingChallenge

Prompt Content

Wire together all your LangGraph nodes (DataReader, DataAnalyzer, RiskAssessor, ReportGenerator) into a cohesive workflow. Define the conditional edges to guide the flow (e.g., if risks are high, branch to a 'HumanReview' node). Instantiate and run your graph with a sample input, ensuring it produces the required JSON output for evaluation.

```python
# Build the LangGraph
workflow = StateGraph(AgentState)
workflow.add_node("data_reader", mcp_data_reader_node)
workflow.add_node("data_analyzer", data_analyzer_node)
workflow.add_node("risk_assessor", lambda state: {"risks": ["Water usage high"], "compliance_status": "FAIL"})
workflow.add_node("report_generator", report_generator_node)

workflow.set_entry_point("data_reader")
workflow.add_edge("data_reader", "data_analyzer")
workflow.add_edge("data_analyzer", "risk_assessor")
workflow.add_edge("risk_assessor", "report_generator")
workflow.add_edge("report_generator", END)

app = workflow.compile()

# Test with a sample input
initial_state = {
    "data_access_request": {"mcp_token": "valid_token_123", "data_sources": []},
    "sustainability_policies": ["Max water usage: 1000m3/month per factory"],
    "reporting_period": "Q1 2024",
    "messages": []
}
final_state = app.invoke(initial_state)

# Print the final state to inspect the generated report
import json
print(json.dumps(final_state['compliance_report'], indent=2))
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations