Back to prompt library
Build Multi-LLM Data Analysis and Reporting Agents
Linked challenge: MCP Server for Enterprise Sustainability Reporting
Prompt source
implementation28 lines5 sectionsNo variables1 code block
Create the 'DataAnalyzer' and 'ReportGenerator' nodes. The 'DataAnalyzer' should use Claude Opus 4.1 for complex interpretation of raw data and potentially call the TorchServe tool. The 'ReportGenerator' should use GPT-4o for structuring and summarizing findings, risks, and recommendations into the final report format. Design clear communication protocols between these agents in your LangGraph workflow.
```python
from langchain_anthropic import ChatAnthropic
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import ToolExecutor, ToolNode
# Initialize LLMs
claude = ChatAnthropic(model="claude-3-opus-20240229", temperature=0.2, anthropic_api_key="YOUR_ANTHROPIC_API_KEY")
gpt_4o = ChatOpenAI(model="gpt-4o", temperature=0.2, openai_api_key="YOUR_OPENAI_API_KEY")
# Data Analyzer node (simplified)
def data_analyzer_node(state: AgentState):
print("---DATA ANALYZER---")
raw_data = state["raw_data"]
# Use Claude Opus 4.1 to analyze raw_data and identify patterns/metrics
analysis_prompt = f"Analyze this raw operational data for sustainability metrics: {raw_data}. Identify key consumption figures (water, energy)."
analysis_result = claude.invoke(analysis_prompt).content
# Call TorchServe tool here if needed, e.g., for anomaly_detection
return {"metrics": {"water": 1150.5, "energy": 9500.2}, "messages": [("ai", analysis_result)]}
# Report Generator node (simplified)
def report_generator_node(state: AgentState):
print("---REPORT GENERATOR---")
metrics = state["metrics"]
risks = state["risks"]
recs = state["recommendations"]
# Use GPT-4o to compile a structured report
report_prompt = f"Generate a detailed sustainability report summary based on metrics: {metrics}, identified risks: {risks}, and recommendations: {recs}."
report_summary = gpt_4o.invoke(report_prompt).content
return {"compliance_report": {"report_summary": report_summary}, "messages": [("ai", report_summary)]}
```