How imrajat-sharma/learn_genai works
Purpose and Entry Points
This is a Node.js/ES-module learning repository that progressively prototypes LLM interactions using LangChain and Mistral AI. Each DayXX directory is an independently runnable exercise rather than a single integrated application. Primary entry points include Day01/chat.js, Day02/chat.js, Day03/app.js, and HTTP/server examples in Day08/server.js and Day09/server.js. A root cli.js suggests a shared or alternate command-line launcher.
Foundational LLM Chat Flow
The first stages establish terminal-based conversational interaction: collect user input, invoke an LLM, and print a response. Day01/chat.js is the baseline single-turn chat implementation. Day02/chat.js extends that loop with contextual behavior, using Day02/assistant.js and Day02/addingHistory.js to define assistant behavior and retain prior messages.
Prompt Engineering and Conversation Context
Day 02 isolates prompt strategies from the transport loop. Day02/fewshotPrompt.js captures few-shot prompting, while Day02/addingHistory.js manages conversational history before model invocation. This boundary is important: chat orchestration can change independently from prompt composition and message-state construction.
Structured Generation
Day 03 moves from free-form chat to schema-constrained output. Day03/app.js appears to drive the generation flow, and Day03/productSchema.js defines the expected product-shaped response contract. This is the repository’s main output-validation boundary between probabilistic LLM text and application-consumable data.
Browser-Facing AI Prototypes
Several later stages introduce browser clients, separating UI delivery from model execution. Day04/index.html pairs with Day04/quizGeneratorAI.js for quiz-oriented generation. Streaming/agent interfaces appear in Day07/index.html with Day07/streamAgent.js. Server-backed browser examples are represented by Day08/index.html plus Day08/server.js, and Day09/index.html plus Day09/server.js.
Agents, Streaming, and Model Capabilities
The progression expands from direct calls into orchestration patterns. Day05/llm.js centralizes a basic model interaction stage; Day06/agent.js introduces agent-style execution; Day07/streamAgent.js adds incremental response delivery. Day 10 explores advanced response handling and retrieval-adjacent concepts through Day10/embedding.js, Day10/structuredOutput.js, and Day10/stream.js.
Runtime and External Boundaries
The material runtime is JavaScript on Node.js with ES Modules. LangChain mediates application-level LLM/prompt abstractions, while Mistral AI is the external model provider, with provider-specific usage visible in Day10/mistral.js. Credentials are environment-based, indicated by .env.example; model/API access should remain outside browser code, especially for server-backed stages such as Day08/server.js and Day09/server.js.
Main entry points: chat.js Contextual chat · .env.example Environment credentials · Day08/server.js Server-backed AI · Day09/server.js Server-backed AI
Components 23
Terminal exercises
Progressive Node.js chat and generation prototypes.
- Single-turn chat
Day01/chat.js - Contextual chat
Day02/chat.js - Assistant behavior
Day02/assistant.js - Conversation history
Day02/addingHistory.js - Few-shot prompts
Day02/fewshotPrompt.js - Structured generation
Day03/app.js - Product schema · Validates LLM output into application-consumable product data.
Day03/productSchema.js
Browser prototypes
Client-facing exercises with local model or server execution.
- Quiz browser UI
Day04/index.html - Quiz generation
Day04/quizGeneratorAI.js - Streaming agent UI
Day07/index.html - Server demo UI
Day08/index.html - Server-backed AI · Keeps model access outside browser code.
Day08/server.js - Server demo UI
Day09/index.html - Server-backed AI · Keeps model access outside browser code.
Day09/server.js
Agents and advanced output
Agent, streaming, embedding, and structured-response experiments.
- Basic LLM stage
Day05/llm.js - Agent execution
Day06/agent.js - Streaming agent
Day07/streamAgent.js - Advanced response flows
Day10/structuredOutput.js - Mistral integration
Day10/mistral.js
Other components
- CLI launcher
cli.js - LangChain
- Mistral AI
- Environment credentials
.env.example
Connections 23
- Contextual chat → Assistant behavior: uses
- Contextual chat → Conversation history: retains context
- Contextual chat → Few-shot prompts: applies prompts
- Structured generation → Product schema: constrains output
- Quiz browser UI → Quiz generation: drives
- Streaming agent UI → Streaming agent: receives stream
- Server demo UI → Server-backed AI: HTTP requests
- Server demo UI → Server-backed AI: HTTP requests
- Single-turn chat → LangChain: invokes via
- Contextual chat → LangChain: invokes via
- Structured generation → LangChain: generates via
- Quiz generation → LangChain: generates via
- Basic LLM stage → LangChain: uses
- Agent execution → LangChain: orchestrates with
- Streaming agent → LangChain: streams via
- Server-backed AI → LangChain: invokes via
- Server-backed AI → LangChain: invokes via
- Advanced response flows → Mistral integration: uses provider integration
- Mistral integration → Mistral AI: API calls
- LangChain → Mistral AI: model requests
- Environment credentials → Mistral integration: supplies credentials
- Environment credentials → Server-backed AI: supplies credentials
- Environment credentials → Server-backed AI: supplies credentials