Skip to content

PrynAI/AgenticAI-with-LangChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agentic AI with LangChain

This repository is organized as a branch-based learning path for building AI agents and retrieval-augmented generation applications with LangChain. Each branch represents a focused milestone: starting from a Python project scaffold, then moving through model provider setup, ReAct-style agents, manual agent loops, RAG, and a Streamlit documentation assistant.

The branch list below was verified from https://github.com/PrynAI/AgenticAI-with-LangChain on May 5, 2026.

Branch Map

Branch Purpose What it builds Main files Required services
main Baseline project scaffold Minimal Python entry point managed with uv main.py, pyproject.toml None
Hello-World First LangChain model call Prompt-template chain that tests environment loading and multiple LLM provider options main.py Groq API key for the active code path; OpenAI/Ollama options are present as comments
react-search-agent Search-capable ReAct-style agent Job-search assistant using LangChain agent creation, Tavily search, and structured output react_search_agent.py OpenAI, Tavily
reactagentsdeepdive Manual agent-loop internals Three agent-loop variants that compare LangChain tool calling, raw JSON tool schemas, and prompt-only ReAct parsing agent_loop_langchain_toolcalling.py, agent_loop_raw_toolcalling.py, raw_react_prompt.py Ollama; LangSmith optional
rag RAG fundamentals Text ingestion into Weaviate plus manual and LCEL retrieval chains ingestion.py, ragwithoutLCEL.py, ragwithLCEL.PY, mediumblog.txt OpenAI, Weaviate
documentationassistantrag Documentation RAG app Streamlit assistant that crawls LangChain docs, indexes them, retrieves context, and answers with sources ingestion.py, backend/core.py, main.py OpenAI, Tavily, Weaviate, Streamlit

Common Setup

Install Python 3.13 and uv, then install dependencies from the branch you want to run:

git clone https://github.com/PrynAI/AgenticAI-with-LangChain.git
cd AgenticAI-with-LangChain
git checkout <branch-name>
uv sync

Create a .env file for the branch-specific services you use:

OPENAI_API_KEY=your_openai_api_key
GROQ_API_KEY=your_groq_api_key
TAVILY_API_KEY=your_tavily_api_key
WEAVIATE_URL=your_weaviate_cluster_url
WEAVIATE_API_KEY=your_weaviate_api_key
WEAVIATE_COLLECTION_NAME=optional_collection_name

# Optional LangSmith tracing
LANGSMITH_TRACING=true
LANGSMITH_API_KEY=your_langsmith_api_key
LANGSMITH_PROJECT=your_project_name

Dependencies change by branch, so run uv sync after switching branches.

main

The main branch is the starting point for the course. It contains a minimal Python application and the base uv project files.

What we build:

  • A simple runnable Python project.
  • A baseline main.py that prints a startup message.
  • A clean foundation for the later LangChain examples.

How it is built:

  • Define project metadata and dependencies in pyproject.toml.
  • Keep the application entry point small and direct.
  • Use this branch as the common ancestor for the learning branches.

Run it with:

uv run python main.py

Hello-World

The Hello-World branch introduces the first LLM-powered LangChain flow. It loads API keys from .env, creates a prompt template, and sends the prompt through an LLM chain.

What we build:

  • A first LangChain prompt-template chain.
  • Environment variable loading with python-dotenv.
  • Provider experimentation across Groq, OpenAI, and Ollama-oriented code paths.

How it is built:

  • Load .env values with load_dotenv().
  • Create a PromptTemplate around a short agentic AI writing prompt.
  • Pipe the prompt into a chat model using LangChain's runnable syntax.
  • Iterate through Groq model names in the active implementation and print each response.

Run it with:

git checkout Hello-World
uv sync
uv run python main.py

react-search-agent

The react-search-agent branch builds a search-enabled assistant that can look up remote AI full-stack engineering jobs. It uses LangChain's create_agent, Tavily search, and a Pydantic response schema.

What we build:

  • A ReAct-style search agent for job discovery.
  • Tavily-powered web search as an external tool.
  • Structured output containing the agent answer and source URLs.

How it is built:

  • Define Source and AgentResponse Pydantic models for the final response shape.
  • Initialize ChatOpenAI with the selected model.
  • Add TavilySearch() as the agent tool.
  • Pass a system prompt that frames the assistant as a job-site analysis expert.
  • Invoke the agent with a user query and print the final message.

Run it with:

git checkout react-search-agent
uv sync
uv run python react_search_agent.py

reactagentsdeepdive

The reactagentsdeepdive branch explains what agent frameworks do under the hood by implementing the same shopping-assistant workflow in multiple ways. The example tools look up product prices and apply discount tiers.

What we build:

  • A LangChain tool-calling loop using @tool and llm.bind_tools().
  • A raw Ollama tool-calling loop with manually defined JSON function schemas.
  • A prompt-only ReAct loop that parses Action and Action Input text with re.

How it is built:

  • Define simple Python functions for get_product_price and apply_discount.
  • In the LangChain version, let @tool and bind_tools() expose tool schemas to the model.
  • In the raw Ollama version, manually write the tool schema passed to ollama.chat().
  • In the prompt-only version, inspect function signatures, place tool descriptions in the prompt, parse model text, execute the selected function, and append observations to the scratchpad.
  • Optionally trace runs with LangSmith to compare each approach.

Run the variants with:

git checkout reactagentsdeepdive
uv sync
uv run python agent_loop_langchain_toolcalling.py
uv run python agent_loop_raw_toolcalling.py
uv run python raw_react_prompt.py

This branch expects a local Ollama model such as qwen3:1.7b to be available.

rag

The rag branch introduces retrieval-augmented generation. It ingests a local article into Weaviate, retrieves relevant chunks, and compares manual retrieval logic with an LCEL chain.

What we build:

  • A document ingestion pipeline for mediumblog.txt.
  • OpenAI embedding generation.
  • Weaviate vector storage.
  • A manual RAG flow without LCEL.
  • A composable LCEL retrieval chain.

How it is built:

  • Load the source text with TextLoader.
  • Split the document with RecursiveCharacterTextSplitter.
  • Embed chunks with OpenAIEmbeddings.
  • Store chunks in a Weaviate collection through WeaviateVectorStore.
  • Retrieve top matching chunks for a question.
  • Format retrieved documents into context and answer with ChatOpenAI.
  • Rebuild the retrieval flow with RunnablePassthrough, itemgetter, prompt templates, and StrOutputParser to show the LCEL approach.

Run it with:

git checkout rag
uv sync
uv run python ingestion.py
uv run python ragwithoutLCEL.py
uv run python ragwithLCEL.PY

documentationassistantrag

The documentationassistantrag branch turns the RAG pattern into a documentation helper app for LangChain. It crawls documentation pages, indexes them in Weaviate, retrieves relevant context through a tool, and exposes the assistant through Streamlit.

What we build:

  • A documentation ingestion pipeline for https://python.langchain.com/.
  • Async batched indexing into Weaviate.
  • A retrieval tool that returns both serialized context and source document artifacts.
  • A LangChain agent that answers questions using retrieved docs.
  • A Streamlit chat UI with source display and session history.

How it is built:

  • Use Tavily crawl/extract tooling to collect documentation content.
  • Convert crawled pages into LangChain Document objects with source metadata.
  • Split documents into larger chunks for documentation retrieval.
  • Add chunks to Weaviate asynchronously in batches.
  • Define a retrieve_context tool with response_format="content_and_artifact" so the UI can show citations.
  • Build the assistant with create_agent() and a system prompt that requires source-backed answers.
  • Use Streamlit chat components to collect user questions, call run_llm(), render the answer, and list retrieved sources.

Run ingestion and the app with:

git checkout documentationassistantrag
uv sync
uv run python ingestion.py
uv run streamlit run main.py

Learning Path

A recommended order through the repo is:

  1. main for the project scaffold.
  2. Hello-World for the first LangChain model invocation.
  3. react-search-agent for a practical tool-using agent.
  4. reactagentsdeepdive for understanding how tool-calling loops work.
  5. rag for vector search and retrieval-augmented generation.
  6. documentationassistantrag for a complete RAG-backed documentation assistant.

About

Branch-based LangChain learning path for building agentic AI apps, ReAct agents, tool calling, RAG with Weaviate, and a Streamlit documentation assistant.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages