URL: Live App on Streamlit
Repository: GitHub
Naija Data Intelligence Assistant (9jaAssist) is a multi-agent, retrieval-augmented generation (RAG) system designed to extract, summarize, and analyze data about Nigeria from the web in response to natural language queries. Leveraging LangGraph for agent orchestration, OpenAI for language modeling, Tavily for real-time search, and Streamlit for deployment, the system provides structured answers, insight summaries, and source traceability.
Despite increasing data publication from Nigerian institutions, there's a gap in accessibility, contextualization, and actionable understanding for non-technical users. Government reports are fragmented; real-time data is locked in articles or PDFs. Analysts and citizens alike struggle to:
Goal: Build a plug-and-play, RAG-based web assistant that answers questions like:
"What's the trend of maternal mortality in Nigeria from 2010 to 2020?"
And returns:
User --> Streamlit UI --> LangGraph (state machine) --> Multi-Agent Flow
|
|--> [Tavily Search] --> Result chunks
|--> [Answer Synthesis Agent] --> Final summary
|--> [Insight Extraction Agent] --> Bullet pattern report
Each node in the graph is stateless but processes typed, structured memory passed across the system.
search_node
)Uses TavilySearchResults with explicit API key
Extracts top 3 result chunks (content, title, URL)
Stores:
search_text
(concatenated plain text for LLM)source_links
(dict with title
, url
)summarize_node
)LangChain PromptTemplate
:
Uses ChatOpenAI(gpt-4)
with deterministic temperature=0
insight_node
)Accepts the output from summarization
Extracts:
class AgentState(TypedDict): question: str search_text: Optional[str] source_links: List[Dict[str, str]] # title + url answer: Optional[str] insights: Optional[str]
This enforces schema consistency and enables traceability across LangGraph nodes.
Component | Purpose |
---|---|
Streamlit | UI and frontend API |
LangGraph | Agentic pipeline with state persistence |
LangChain | LLM chaining and prompt abstraction |
OpenAI (GPT-4) | Natural language generation |
Tavily | Fast search results from the open web |
Streamlit Secrets | Deployment-friendly API key management |
config.py supports hybrid local/dev mode:
import os, streamlit as st OPENAI_API_KEY = st.secrets.get("OPENAI_API_KEY", os.getenv("OPENAI_API_KEY")) TAVILY_API_KEY = st.secrets.get("TAVILY_API_KEY", os.getenv("TAVILY_API_KEY"))
secrets.toml:
OPENAI_API_KEY = "sk-..." TAVILY_API_KEY = "tvly_..."
Q: What is Nigeria's maternal mortality rate?
Answer: As of 2020, the maternal mortality rate in Nigeria is 1047 deaths per 100,000 live births, one of the highest globally.
Insights:
Sources:
Stakeholder | Application |
---|---|
Journalists | Real-time factual grounding for articles |
Policy Analysts | Identify root-cause trends from summarized sources |
Educators | Teach civic & public health data via AI Q&A |
Citizens | Get digestible facts about governance, economy, services |
NaijaAssist represents a powerful demonstration of agent-based reasoning over open-world information grounded in Nigerian data. By coupling LangGraph's modular flow with the retrieval abilities of Tavily and the summarization strength of GPT-4, this assistant bridges the gap between data and decisions for Nigerian users.
Whether you're a data scientist, student, or citizenβinsight is just one question away.