# patakrishna2006-a11y/langchain-tutorial architecture

> Architecture diagram of the GitHub repository patakrishna2006-a11y/langchain-tutorial, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/patakrishna2006-a11y/langchain-tutorial
- Repository: https://github.com/patakrishna2006-a11y/langchain-tutorial

## Overview

This repository is a collection of standalone LangChain examples, not a single integrated application. Its workflows demonstrate direct model invocation, chat prompts and messages, text embedding, and a Streamlit poem-writing chatbot. The chatbot accepts and validates user choices, formats them with a saved prompt template, invokes a configured NVIDIA chat model, and displays the response. Other scripts independently invoke Google, NVIDIA, Ollama, or Hugging Face models. Edges reflect only calls and file operations visible in the excerpts; no shared orchestration is shown.

Main entry points: [`4. Prompts/prompts_ui.py`](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompts_ui.py) (Poem Chatbot UI), [`4. Prompts/prompt.py`](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompt.py) (Prompt Template), [`5. Messages/message_placeholder.py`](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/message_placeholder.py) (History Chat Demo), [`4. Prompts/poem_chatbot_template.json`](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/poem_chatbot_template.json) (Poem Template JSON)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_llm["LLM Example"]
  node_llm_demo["LLM Demo<br/>[llm demo.py]"]
end

subgraph group_chat["Chat Examples"]
  node_chat_demo["Chat Demo<br/>[chat model demo.py]"]
  node_open_chat["Open Chat Model"]
end

subgraph group_embeddings["Embedding Examples"]
  node_nvidia_embed["NVIDIA Embeddings<br/>[embed model.py]"]
  node_hf_embed["Hugging Face Embeddings"]
  node_ollama_embed["Ollama Embeddings"]
end

subgraph group_prompts["Prompting"]
  node_prompt_template["Prompt Template<br/>[prompt.py]"]
  node_chat_prompt["Chat Prompt Demo"]
  node_poem_ui["Poem Chatbot UI<br/>[prompts_ui.py]"]
  node_json_template["Poem Template JSON"]
  node_yaml_template["Poem Template YAML"]
end

subgraph group_messages["Messages"]
  node_message_demo["Message Demo<br/>[message.py]"]
  node_history_demo["History Chat Demo"]
  node_chat_history["Chat History Text<br/>[chat_history.txt]"]
end

node_user(("User"))
node_gemini{{"Google Gemini"}}
node_nvidia{{"NVIDIA API"}}
node_ollama{{"Ollama"}}
node_huggingface{{"Hugging Face"}}

node_llm_demo -->|"invokes"| node_gemini
node_chat_demo -->|"invokes"| node_nvidia
node_open_chat -->|"invokes"| node_ollama
node_nvidia_embed -->|"embeds text"| node_nvidia
node_hf_embed -->|"embeds text"| node_huggingface
node_ollama_embed -->|"embeds text"| node_ollama
node_prompt_template -->|"saves"| node_json_template
node_prompt_template -->|"saves"| node_yaml_template
node_user -->|"submits choices"| node_poem_ui
node_poem_ui -->|"loads template"| node_json_template
node_poem_ui -->|"invokes"| node_nvidia
node_chat_prompt -->|"invokes"| node_ollama
node_message_demo -->|"invokes"| node_nvidia
node_history_demo -->|"reads"| node_chat_history
node_history_demo -->|"invokes"| node_nvidia

click node_llm_demo "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/1.%20LLMs/llm%20demo.py"
click node_chat_demo "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/2.%20ChatModels/chat%20model%20demo.py"
click node_open_chat "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/2.%20ChatModels/open%20source%20model.py"
click node_nvidia_embed "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/embed%20model.py"
click node_hf_embed "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/hugging%20face%20embed.py"
click node_ollama_embed "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/open%20source%20embed%20model.py"
click node_prompt_template "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompt.py"
click node_chat_prompt "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/chatprompttemplate.py"
click node_poem_ui "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompts_ui.py"
click node_json_template "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/poem_chatbot_template.json"
click node_yaml_template "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/poem_chatbot_template.yaml"
click node_message_demo "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/message.py"
click node_history_demo "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/message_placeholder.py"
click node_chat_history "https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/chat_history.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_llm_demo,node_user toneBlue
class node_chat_demo,node_open_chat toneAmber
class node_nvidia_embed,node_hf_embed,node_ollama_embed,node_nvidia toneMint
class node_prompt_template,node_chat_prompt,node_poem_ui,node_json_template,node_yaml_template toneRose
class node_message_demo,node_history_demo,node_chat_history,node_gemini,node_ollama,node_huggingface toneIndigo
```

## Components

### LLM Example

- [LLM Demo](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/1.%20LLMs/llm%20demo.py): `1. LLMs/llm demo.py`

### Chat Examples

- [Chat Demo](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/2.%20ChatModels/chat%20model%20demo.py): `2. ChatModels/chat model demo.py`
- [Open Chat Model](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/2.%20ChatModels/open%20source%20model.py): `2. ChatModels/open source model.py`

### Embedding Examples

- [NVIDIA Embeddings](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/embed%20model.py): `3. EmbeddingModels/embed model.py`
- [Hugging Face Embeddings](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/hugging%20face%20embed.py): `3. EmbeddingModels/hugging face embed.py`
- [Ollama Embeddings](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/3.%20EmbeddingModels/open%20source%20embed%20model.py): `3. EmbeddingModels/open source embed model.py`

### Prompting

- [Prompt Template](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompt.py): `4. Prompts/prompt.py`
- [Chat Prompt Demo](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/chatprompttemplate.py): `4. Prompts/chatprompttemplate.py`
- [Poem Chatbot UI](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/prompts_ui.py): `4. Prompts/prompts_ui.py`
- [Poem Template JSON](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/poem_chatbot_template.json): `4. Prompts/poem_chatbot_template.json`
- [Poem Template YAML](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/4.%20Prompts/poem_chatbot_template.yaml): `4. Prompts/poem_chatbot_template.yaml`

### Messages

- [Message Demo](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/message.py): `5. Messages/message.py`
- [History Chat Demo](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/message_placeholder.py): `5. Messages/message_placeholder.py`
- [Chat History Text](https://github.com/patakrishna2006-a11y/langchain-tutorial/blob/main/5.%20Messages/chat_history.txt): `5. Messages/chat_history.txt`

### Other components

- **User**
- **Google Gemini**
- **NVIDIA API**
- **Ollama**
- **Hugging Face**

## Connections

- LLM Demo → Google Gemini: invokes (evidence: `1. LLMs/llm demo.py`)
- Chat Demo → NVIDIA API: invokes (evidence: `2. ChatModels/chat model demo.py`)
- Open Chat Model → Ollama: invokes (evidence: `2. ChatModels/open source model.py`)
- NVIDIA Embeddings → NVIDIA API: embeds text (evidence: `3. EmbeddingModels/embed model.py`)
- Hugging Face Embeddings → Hugging Face: embeds text (evidence: `3. EmbeddingModels/hugging face embed.py`)
- Ollama Embeddings → Ollama: embeds text (evidence: `3. EmbeddingModels/open source embed model.py`)
- Prompt Template → Poem Template JSON: saves (evidence: `4. Prompts/prompt.py`)
- Prompt Template → Poem Template YAML: saves (evidence: `4. Prompts/prompt.py`)
- User → Poem Chatbot UI: submits choices (evidence: `4. Prompts/prompts_ui.py`)
- Poem Chatbot UI → Poem Template JSON: loads template (evidence: `4. Prompts/prompts_ui.py`)
- Poem Chatbot UI → NVIDIA API: invokes (evidence: `4. Prompts/prompts_ui.py`)
- Chat Prompt Demo → Ollama: invokes (evidence: `4. Prompts/chatprompttemplate.py`)
- Message Demo → NVIDIA API: invokes (evidence: `5. Messages/message.py`)
- History Chat Demo → Chat History Text: reads (evidence: `5. Messages/message_placeholder.py`)
- History Chat Demo → NVIDIA API: invokes (evidence: `5. Messages/message_placeholder.py`)
