Researcher & Analyst AI App (All-Purpose) using LangGraph
- Sumit Dey
- Oct 26
- 7 min read
This app is a comprehensive research and analysis platform designed for professionals and academics. It enables users to collect, organize, and analyze data efficiently. With built-in tools for literature review management, data visualization, and AI-assisted insights, This agent helps researchers make evidence-based decisions faster.
Key Features:
AI-powered data summarization and trend detection
Integration with Tavily search and OpenAI Model.
Real-time market data aggregation
Predictive modeling for sales and growth trends
Write executive summary after research and analysis.
Technical Overview
LangGraph — for orchestrating multi-agent workflows and reasoning chains
Python / FastAPI — backend service for agent coordination
OpenAI — for LLM-based analysis and report generation
Streamlit — for UI and interactive visualization
LangChain Tools — for data ingestion and retrieval-augmented generation (RAG)
Architecture Summary:
The app uses a LangGraph-based agent graph, where:
A Supervisor Agent assigning tasks to other agents.
A Research Agent gathers the research content.
1. Key facts and background 2. Current trends or developments 3. Important statistics or data points 4. Notable examples or case studies
An Analysis Agent performs comparative and statistical reasoning. 1. Key insights and patterns
2. Strategic implications
3. Risks and opportunities
4. Recommendations
A Writer Agent generates final insights, executive summary and recommendations. 1. Executive Summary
2. Key Findings
3. Analysis & Insights
4. Recommendations
5. Conclusion

Python code details # State Definition
class SupervisorState(MessagesState):
"""State for the multi-agent system"""
next_agent: str = ""
research_data: str = ""
analysis: str = ""
final_report: str = ""
task_complete: bool = False
current_task: str = ""# Define tools
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
# Using Tavily for web search
search = TavilySearchResults(max_results=3)
results = search.invoke(query)
return str(results)
@tool
def write_summary(content: str) -> str:
"""Write a summary of the provided content."""
# Simple summary generation
summary = f"Summary of findings:\n\n{content[:600]}..."
return summary# Define tools
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
# Using Tavily for web search
search = TavilySearchResults(max_results=3)
results = search.invoke(query)
return str(results)
@tool
def write_summary(content: str) -> str:
"""Write a summary of the provided content."""
# Simple summary generation
summary = f"Summary of findings:\n\n{content[:600]}..."
return summary# Call Open AI LLM
llm = ChatOpenAI(model="gpt-4o-mini")# Define tools
def supervisor_agent(state: SupervisorState) -> Dict:
"""Supervisor decides next agent using OpenAI LLM"""
.....
.....
# Determine next agent
if "done" in decision_text or has_report:
next_agent = "end"
supervisor_msg = f"**Supervisor:** All tasks complete! Great work team."
elif "researcher" in decision_text or not has_research:
next_agent = "researcher"
supervisor_msg = f"**Supervisor:** Let's start with research. Assigning to Researcher..."
elif "analyst" in decision_text or (has_research and not has_analysis):
next_agent = "analyst"
supervisor_msg = f"**Supervisor:** Research done. Time for analysis. Assigning to Analyst..."
elif "writer" in decision_text or (has_analysis and not has_report):
next_agent = "writer"
supervisor_msg = f"**Supervisor:** Analysis complete. Let's create the report. Assigning to Writer..."
else:
next_agent = "end"
supervisor_msg = f"**Supervisor:** Task seems complete."
return {
"messages": [AIMessage(content=supervisor_msg)],
"next_agent": next_agent,
"current_task": task
}# Agent 1: Researcher (using Open AI)
def researcher_agent(state: SupervisorState) -> Dict:
"""Researcher uses Open AI to gather information"""
task = state.get("current_task", "research topic")
# Create research prompt
research_prompt = f"""As a research specialist, provide comprehensive information about: {task}
# Create agent message
agent_message = f"**Researcher:** I've completed the research on '{task}'.\n\nKey findings:\n{research_data[:600]}..."
return {
"messages": [AIMessage(content=agent_message)],
"research_data": research_data,
"next_agent": "supervisor"
}# Agent 2: Analyst (using OPen AI)
def analyst_agent(state: SupervisorState) -> Dict:
"""Analyst uses Open AI to analyze the research"""
research_data = state.get("research_data", "")
task = state.get("current_task", "")
# Create analysis prompt
analysis_prompt = f"""As a data analyst, analyze this research data and provide insights"
# Get analysis from LLM
analysis_response = llm.invoke([HumanMessage(content=analysis_prompt)])
analysis = analysis_response.content
# Create agent message
agent_message = f"**Analyst:** I've completed the analysis.\n\nTop insights:\n{analysis[:600]}..."
return {
"messages": [AIMessage(content=agent_message)],
"analysis": analysis,
"next_agent": "supervisor"
}# Agent 3: Writer (using Open AI)
def writer_agent(state: SupervisorState) -> Dict:
"""Writer uses Open AI to create final report"""
research_data = state.get("research_data", "")
analysis = state.get("analysis", "")
task = state.get("current_task", "")
# Create writing prompt
writing_prompt = f"""As a professional writer, create an executive report based on:
Task: {task}
Research Findings:
{research_data[:800]}
Analysis:
{analysis[:800]}
Create a well-structured report with:
1. Executive Summary
2. Key Findings
3. Analysis & Insights
4. Recommendations
5. Conclusion
Keep it professional and concise."""
# Get report from LLM
report_response = llm.invoke([HumanMessage(content=writing_prompt)])
report = report_response.content
# Create final formatted report
final_report = f"""
**FINAL REPORT**
{'\n'}
{'='*50}
{'\n'}
Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}
{'\n'}
{'='*50}
{report}
{'='*50}
Report compiled by Multi-Agent AI System powered by Open AI
"""
return {
#"messages": [AIMessage(content=f"Writer: Report complete! See below for the full document.")],
"messages": [AIMessage(content=final_report)],
"final_report": final_report,
"next_agent": "supervisor",
"task_complete": True
}# Router Function(decide based on the state)
def router(state: SupervisorState) -> Literal["supervisor", "researcher", "analyst", "writer", "__end__"]:
"""Routes to next agent based on state"""
next_agent = state.get("next_agent", "supervisor")
if next_agent == "end" or state.get("task_complete", False):
return END
if next_agent in ["supervisor", "researcher", "analyst", "writer"]:
return next_agent
return "supervisor"# Create LangGraph workflow and compile
workflow = StateGraph(SupervisorState)
# Add nodes
workflow.add_node("supervisor", supervisor_agent)
workflow.add_node("researcher", researcher_agent)
workflow.add_node("analyst", analyst_agent)
workflow.add_node("writer", writer_agent)
# Set entry point
workflow.set_entry_point("supervisor")
# Add routing
for node in ["supervisor", "researcher", "analyst", "writer"]:
workflow.add_conditional_edges(
node,
router,
{
"supervisor": "supervisor",
"researcher": "researcher",
"analyst": "analyst",
"writer": "writer",
END: END
}
)
graph=workflow.compile()# Chat API endpoint that receives user input, processes it through an AI workflow, and returns the generated result.
@app.post("/chat")
def chat(request: ChatRequest):
result = graph.invoke({"messages": [{"role": "user", "content": request.user_input}]})
return result# Starts the FastAPI server when the Python file is run directly
if __name__ == '__main__':
uvicorn.run(app, host='127.0.0.1', port=8000)# Now time to build the UI with streamlit
import streamlit as st
import requests
# Streamlit App Configuration
st.set_page_config(page_title="LangGraph MultiAgent UI", layout="centered")
# Define API endpoint
API_URL = "http://127.0.0.1:8000/chat"
# Streamlit UI Elements
st.title("Research and Analysis Chatbot Agent")
st.write("Interact with the LangGraph-based agent using this interface.")# Finally ready for the build the final UI(textbox, submit button, result, etc.)
# Input box for user messages
user_input = st.text_area("Enter your prompt:", height=150, placeholder="Please type your prompt here...")
# Button to send the query
if st.button("Submit"):
if user_input.strip():
try:
with st.spinner("wait...", show_time=True):
# Send the input to the FastAPI backend
payload = {"user_input": user_input}
response = requests.post(API_URL, json=payload)
# Display the response
if response.status_code == 200:
response_data = response.json()
if "error" in response_data:
st.error(response_data["error"])
else:
ai_responses = [
message.get("content", "")
for message in response_data.get("messages", [])
if message.get("type") == "ai"
]
if ai_responses:
st.subheader("Agent Response:")
#st.markdown(f"**Final Response:** {ai_responses[-1]}")
for i, response_text in enumerate(ai_responses, 1):
st.markdown(f"{response_text}")
#st.markdown(f"**Response {i}:** {response_text}")
else:
st.warning("No AI response found in the agent output.")
else:
st.error(f"Request failed with status code {response.status_code}.")
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.warning("Please enter a message before clicking 'Send Query'.")Finally, it’s time to enter the prompt and get the desired output
Start with the prompt "What will be the future of quantum computing in the year 2026?"

Here is the Response Agent Response:
Supervisor: Let's start with research. Assigning to Researcher...
Researcher: I've completed the research on 'What will be the future of quantum computing in the year 2026?'.
Key findings:
Future of Quantum Computing in 2026
1. Key Facts and Background
Quantum computing leverages quantum mechanics principles to process information in fundamentally different ways than classical computing. Unlike classical bits that represent either a 0 or 1, quantum bits (qubits) can represent both simultaneously due to a phenomenon known as superposition. Quantum entanglement further allows qubits to be interconnected, exponentially increasing computational power for specific types of pr...
Supervisor: Research done. Time for analysis. Assigning to Analyst...
Analyst: I've completed the analysis.
Top insights:
Insights and Analysis of the Research Data on Quantum Computing in 2026
1. Key Insights and Patterns
Technological Shift: Quantum computing is set to fundamentally disrupt traditional computing paradigms, with significant advancements anticipated in hardware sophistication, algorithm development, and real-world application capabilities. The integration of quantum computing in vari...
Supervisor: Analysis complete. Let's create the report. Assigning to Writer...
FINAL REPORT
==================================================
Generated: 2025-10-26 13:06
==================================================
# Executive Report: Insights and Analysis of Quantum Computing in 2026Executive Summary
As quantum computing approaches a transformative threshold by 2026, this report compiles critical insights from the latest research data. The foundational technology is poised to disrupt conventional computing paradigms through advancements in hardware and algorithms, leading to real-world applications across various sectors. Investment trends indicate growing confidence in quantum technologies, with financial projections reaching 24billionandamarketsizeexpectedtogrowto24billionandamarketsizeexpectedtogrowto8 billion at a compound annual growth rate (CAGR) of over 30%. This report provides an analysis of the current state of quantum computing, future trends, and strategic recommendations for stakeholders in the industry.
Key Findings
Technological Shift:
Quantum computing is anticipated to revolutionize traditional computing, promising substantial enhancements in computational capabilities and efficiency.
Investment Trends:
Global financial investment in quantum technologies is projected to reach $24 billion by 2026, demonstrating increasing confidence from governmental and private sectors.
Market Dynamics:
The quantum computing market is expected to grow to approximately $8 billion by 2026, with a CAGR exceeding 30%, indicating broad interest and adoption across industries.
Hardware Advancements:
Significant development in qubit technologies—including superconducting qubits, trapped ions, and topological qubits—is being pursued by leading companies to improve system stability and reduce error rates.
Analysis & Insights
The analysis of the current quantum computing landscape reveals several key patterns and trends:
Disruption of Existing Paradigms: Quantum computing's ability to perform complex calculations far surpasses classical systems, paving the way for new applications in fields such as cryptography, drug discovery, and optimization problems.
Ecosystem Development: The expanding ecosystem encompassing hardware manufacturers, software developers, and research institutions signifies a collective effort to enhance the practical implementation of quantum technologies.
Skill Gap and Workforce Development: As the industry grows, the need for skilled professionals in quantum computing is becoming critical. Investments in education and training programs are necessary to cultivate a workforce capable of leveraging these technologies.
Recommendations
Increased Collaboration: Encourage collaboration between academia, industry, and government to accelerate research, share knowledge, and develop best practices in quantum computing.
Focus on Real-World Applications: Identify and prioritize specific applications with immediate potential benefits, such as optimization in logistics, materials science, and pharmaceuticals, to stimulate early adoption.
Investment in Talent Development: Launch initiatives aimed at educating and training the next generation of quantum computing professionals to address the skill gap and support industry growth.
Monitor Regulatory Developments: Stay abreast of regulatory changes that may impact the development and implementation of quantum technologies to ensure compliance and strategic alignment.
Conclusion
The landscape of quantum computing is rapidly evolving, with significant advancements anticipated by 2026. The convergence of technological developments, investment growth, and market dynamics presents considerable opportunities for businesses and researchers alike. By understanding these trends and aligning strategies accordingly, stakeholders can position themselves at the forefront of this groundbreaking field, harnessing its potential to drive innovation and efficiency across various sectors.
===========================================================
Report compiled by Multi-Agent AI System powered by Open AI


Comments