AI Deep Research & Chat
Relevant source files
The following files were used as context for generating this wiki page:
AI Deep Research & Chat is a humanitarian intelligence system designed to assist analysts, researchers, and NGO workers in synthesizing actionable insights from internal datasets and external web sources. The system utilizes an orchestrator model that coordinates specialized tools for internal database lookups, real-time web grounding, and multi-step deep investigations.
Sources: apps/server/src/agents/prompts/system.ts:1-7
The feature provides a unified interface for data exploration, allowing users to query field reports, academic publications, and real-time news. By combining semantic search against curated humanitarian data with autonomous web agents, it bridges the gap between static internal repositories and the evolving global information landscape.
Sources: apps/server/src/agents/prompts/system.ts:9-25, apps/server/src/agents/prompts/deep-research.ts:1-12
Orchestration Architecture
The system operates through a central "Orchestrator" assistant that determines the appropriate research path based on the user's query complexity. It prioritizes high-accuracy internal data before escalating to broader web research.
Search Capabilities
The orchestrator has access to three primary tools:
- searchDatabase: Performs semantic similarity searches against the Poneglyph repository of field reports and NGO datasets.
- webSearch: Utilizes Gemini for real-time Google Search grounding to provide up-to-date summaries of current events.
- deepResearch: Executes multi-step investigations using Tavily when queries require synthesis of multiple sources or fact-checking.
Sources: apps/server/src/agents/prompts/system.ts:9-25
Data Flow Diagram
The following diagram illustrates how the Orchestrator processes a user request and selects the appropriate research tool.
The Orchestrator determines tool selection based on the specific focus areas of the query.
Sources: apps/server/src/agents/prompts/system.ts:9-25
Internal Database Search (searchDatabase)
The searchDatabaseTool implements semantic search using pgvector to find relevant humanitarian datasets. It generates embeddings for user queries and calculates cosine similarity against stored dataset records.
Implementation Details
- Top-K Retrieval: The tool currently retrieves the top 5 most relevant results.
- Enrichment: Results are enriched with presigned S3 URLs for direct file access and associated tags for metadata filtering.
- SQL Execution: Uses raw SQL via
db.execute()to perform vector similarity operations (<=>operator) and join datasets with their sources and tags.
Sources: apps/server/src/agents/tools/search-db.ts:11-105
Result Schema
| Field | Type | Description |
|---|---|---|
| title | string | The name of the dataset or report |
| publisher | string | The NGO or agency that provided the data |
| relevanceScore | string | Cosine similarity score (fixed to 4 decimals) |
| files | array | List of presigned S3 URLs and keys |
| tags | string[] | Metadata tags associated with the dataset |
Sources: apps/server/src/agents/tools/search-db.ts:31-118
Deep Research Specialist
When a query is deemed complex, the system employs the Deep Research Specialist. This agent is specifically tuned for humanitarian intelligence, focusing on refugee data, displacement statistics, and NGO publications.
Research Workflow
- Multi-Query Generation: The agent generates multiple search queries to explore the topic from different angles.
- Content Extraction: It extracts and analyzes content from high-authority URLs (e.g., UN agencies, WHO, UNHCR).
- Cross-Referencing: Findings are cross-referenced across different sources to ensure accuracy.
- Confidence Assessment: Each finding is returned with a confidence level (High/Medium/Low).
Sources: apps/server/src/agents/prompts/deep-research.ts:1-19
The specialist prioritizes efficiency and authoritative sources during the extraction phase.
Sources: apps/server/src/agents/prompts/deep-research.ts:5-19
User Interface & Interaction
The research interface is divided into a conversational thread and specialized status components that track the agent's progress.
Chat Components
- ResearchInput: A specialized input field supporting model selection (GPT-4o, Claude 3.5, Gemini Pro, Llama 3.1) and toggleable "DeepMind" or "Search" modes.
- ResearchStatusLog: Displays real-time progress of the research, such as files explored, search counts, and processing duration (e.g., "Worked for 14m 22s").
- AgentPanel: A persistent or minimizable panel used for dataset uploads and direct agent interaction, supporting drag-and-drop file uploads for CSV, JSON, and Excel formats.
Sources: apps/web/src/app/research/page.tsx:14-42, apps/web/src/components/research/agent-panel.tsx:13-162, packages/ui/src/components/ai-input.tsx:47-230
File Interaction Logic
Users can upload datasets directly into the chat. The agent simulates processing the files to enable immediate analysis or visualization requests within the chat context.
Sources: apps/web/src/components/research/agent-panel.tsx:69-114
Summary of Feature Focus Areas
The AI research system focuses on specific humanitarian domains to ensure relevance for NGO decision-making.
| Focus Area | Description |
|---|---|
| Crisis Tracking | Real-time monitoring of conflict zones and disaster areas via web search. |
| Displacement Data | Analysis of refugee and internal displacement statistics from UN sources. |
| Policy Analysis | Synthesis of government responses and NGO policy documents. |
| Academic Research | Peer-reviewed studies on humanitarian topics and health trends. |
Sources: apps/server/src/agents/prompts/deep-research.ts:14-20
The AI Deep Research & Chat system serves as a mission-critical tool for humanitarian analysts by providing a structured, verifiable, and multi-modal approach to intelligence gathering. Through its use of semantic internal search and autonomous web agents, it ensures that resource allocation decisions are grounded in the best available data.