sndevBeta
Browse CategoriesDeveloper Insights
LoginGet Started
sndevBeta
Project FeedYouTube

© 2026 sndev. All rights reserved.

Agentic AI
Aug 18, 2026
s
sndev

Build an End-To-End Modular RAG LangGraph AI Agent with Web Search

GitHub RepositoryWatch on YouTube

“Build a full-stack AI agent with LangGraph, Groq LLaMA 3, Pinecone, and Tavily Search API. Features dynamic routing between PDF-grounded RAG and real-time web search with a FastAPI and Streamlit archi”

On This Page
1System Architecture and Routing Workflow2Technology Stack Summary3Key Takeaways

Static RAG pipelines struggle when user queries require information beyond the ingested documents, such as current events or real-time web verification. Pure web-search agents, on the other hand, lack grounding in proprietary internal documents.

This project implements a hybrid AI agent using LangGraph, FastAPI, and Streamlit that dynamically orchestrates document retrieval and live web search based on user intent and contextual relevance.

System Architecture and Routing Workflow

The core of the system is a stateful decision graph that manages multi-step execution paths:

                     ┌──────────────────┐
                     │    User Query    │
                     └────────┬─────────┘
                              │
                              ▼
                     ┌──────────────────┐
                     │  Router Decision │
                     └────────┬─────────┘
                              │
             ┌────────────────┴────────────────┐
             ▼                                 ▼
   [Local Knowledge Path]              [Live Web Search Path]
             │                                 │
     (Pinecone Vector DB)             (Tavily Search API)
             │                                 │
             └────────────────┬────────────────┘
                              │
                              ▼
                 ┌──────────────────────────┐
                 │ Context Synthesis & Gen  │
                 │    (Groq / LLaMA 3)      │
                 └────────────┬─────────────┘
                              │
                              ▼
                       [Final Answer]
  1. Stateful Routing: LangGraph evaluates the incoming prompt and determines whether the answer resides in the local vector store or requires external web search.

  2. Document Retrieval (RAG): For internal knowledge queries, the system searches indexed embeddings in Pinecone generated by lightweight HuggingFace MiniLM models.

  3. Live Web Search: When real-time data is needed, or if the user explicitly enables web search, the agent routes execution to the Tavily Search API.

  4. Fast Inference Synthesis: Retrieved chunks or web results are compiled into an augmented prompt and passed to Groq (LLaMA 3) for fast, grounded answer generation.

Technology Stack Summary

Component

Technology

Primary Responsibility

Agent Orchestration

LangGraph & LangChain

Graph state management, tool execution, and conditional routing

Backend API

FastAPI

Asynchronous REST endpoints, schema validation, and pipeline control

LLM Inference Engine

Groq (LLaMA 3)

Sub-second generative reasoning and synthesis

Vector Database

Pinecone

Semantic indexing and similarity retrieval for PDF documents

Embeddings

Sentence Transformers (MiniLM)

Local dense vector generation for PDF text chunks

Web Search Tool

Tavily Search API

Real-time web retrieval optimized for LLM consumption

Frontend UI

Streamlit

Traceable chat interface with toggle controls for search mode

Key Takeaways

  • Conditional Routing: By shifting from rigid linear chains to cyclic graphs with LangGraph, the agent can inspect context, evaluate retrieval quality, and fall back to web search when document context is insufficient.

  • Traceable Decision Making: Exposing agent state transitions through FastAPI and Streamlit gives users full visibility into whether the model answered from internal PDFs or live web results.

HuggingFace
Tavily
FastAPI
Pinecone
Streamlit

Community Discussion
0

Ask questions, discuss architecture, and share insights with other developers.

Sort:

Sign in to join the discussion and share your thoughts with other developers.

Sign In to Comment
Loading discussions…