Spaces:
Sleeping
Sleeping
doc: reorganize and update DEVELOPER.md for codebase accuracy, module coverage, and theming details
Browse files- docs/DEVELOPER.md +39 -29
docs/DEVELOPER.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
# π οΈ Developer Documentation
|
| 2 |
|
|
|
|
|
|
|
| 3 |
## π¦ Project Structure
|
| 4 |
|
| 5 |
```
|
|
@@ -13,10 +15,11 @@
|
|
| 13 |
βββ pstuts_rag/ # Package directory
|
| 14 |
β βββ pstuts_rag/ # Source code
|
| 15 |
β β βββ __init__.py # Package initialization
|
| 16 |
-
β β βββ configuration.py
|
| 17 |
β β βββ datastore.py # Vector database and document management
|
| 18 |
β β βββ rag.py # RAG chain implementation and factories
|
| 19 |
-
β β βββ
|
|
|
|
| 20 |
β β βββ state.py # Team state management for agents
|
| 21 |
β β βββ prompts.py # System prompts for different agents
|
| 22 |
β β βββ evaluator_utils.py # RAG evaluation utilities
|
|
@@ -44,6 +47,7 @@
|
|
| 44 |
β βββ TODO.md # Development TODO list
|
| 45 |
β βββ chainlit.md # Chainlit welcome message
|
| 46 |
βββ scripts/ # Utility scripts (currently empty)
|
|
|
|
| 47 |
βββ README.md # User-facing documentation
|
| 48 |
```
|
| 49 |
|
|
@@ -82,6 +86,8 @@ pip install -e ".[dev,web]" # Core + dev + web server
|
|
| 82 |
- **`DatastoreManager`** (`datastore.py`): Manages Qdrant vector store, document loading, and semantic chunking
|
| 83 |
- **`RAGChainFactory`** (`rag.py`): Creates retrieval-augmented generation chains with reference compilation
|
| 84 |
- **`RAGChainInstance`** (`rag.py`): Encapsulates complete RAG instances with embeddings and vector stores
|
|
|
|
|
|
|
| 85 |
|
| 86 |
#### πΈοΈ Multi-Agent System
|
| 87 |
- **`PsTutsTeamState`** (`state.py`): TypedDict managing multi-agent conversation state
|
|
@@ -138,49 +144,28 @@ This feature enables controlled access to external resources while maintaining a
|
|
| 138 |
|
| 139 |
### Sepia Theme Implementation πΌοΈ
|
| 140 |
|
| 141 |
-
The application features a custom **sepia-toned color scheme** implemented
|
| 142 |
|
| 143 |
#### π Theme Files
|
| 144 |
-
- **`public/
|
| 145 |
-
- **`.chainlit/config.toml`**: Configuration enabling
|
| 146 |
|
| 147 |
#### π¨ Color Palette Design
|
| 148 |
-
|
| 149 |
-
/* Light Sepia Colors */
|
| 150 |
-
--sepia-lightest: #faf6f0 /* Warm cream background */
|
| 151 |
-
--sepia-lighter: #f4ede1 /* Secondary background */
|
| 152 |
-
--sepia-light: #e8d5b7 /* Tertiary background */
|
| 153 |
-
--sepia-medium: #d4b896 /* Border and accent */
|
| 154 |
-
--sepia-dark: #c19a6b /* Darker accents */
|
| 155 |
-
--sepia-darker: #a67c52 /* Strong borders */
|
| 156 |
-
--sepia-darkest: #8b5a3c /* Deep contrast */
|
| 157 |
-
|
| 158 |
-
/* Dark Sepia Colors */
|
| 159 |
-
--sepia-dark-bg: #2c1810 /* Rich coffee background */
|
| 160 |
-
--sepia-dark-bg-secondary: #3a2318 /* Warmer secondary */
|
| 161 |
-
--sepia-dark-bg-tertiary: #4a2d20 /* Amber tertiary */
|
| 162 |
-
```
|
| 163 |
-
|
| 164 |
-
#### π§ Technical Implementation
|
| 165 |
-
- **CSS Variables**: Dynamic theming with `--custom-property` pattern
|
| 166 |
-
- **Theme Detection**: `[data-theme="light"]` and `[data-theme="dark"]` selectors
|
| 167 |
-
- **Smooth Transitions**: `transition` properties for seamless theme switching
|
| 168 |
-
- **Component Styling**: Custom styling for chat messages, buttons, inputs, sidebar
|
| 169 |
-
- **Image Treatment**: Subtle `filter: sepia(20%)` on images for visual consistency
|
| 170 |
|
| 171 |
#### βοΈ Configuration Setup
|
| 172 |
```toml
|
| 173 |
# .chainlit/config.toml
|
| 174 |
[UI]
|
| 175 |
default_theme = "light" # Set light theme as default
|
| 176 |
-
|
| 177 |
```
|
| 178 |
|
| 179 |
#### π― Features
|
| 180 |
- **Responsive Design**: Adapts to both light and dark preferences
|
| 181 |
- **Accessibility**: Maintains sufficient contrast ratios in both themes
|
| 182 |
- **Visual Cohesion**: Unified sepia treatment across all UI elements
|
| 183 |
-
- **Performance**:
|
| 184 |
- **User Control**: Native Chainlit theme switcher toggles between variants
|
| 185 |
|
| 186 |
The sepia theme creates a warm, nostalgic atmosphere perfect for Adobe Photoshop tutorials, giving the application a distinctive visual identity that stands out from standard blue/gray interfaces. πΈβ¨
|
|
@@ -297,6 +282,31 @@ When LangGraph Studio accesses the `graph` function, it automatically triggers l
|
|
| 297 |
- **State management**: LangGraph for multi-agent coordination
|
| 298 |
- **Evaluation**: RAGAS framework for retrieval and generation metrics
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
## π Resources
|
| 301 |
|
| 302 |
- [Chainlit Documentation](https://docs.chainlit.io) π
|
|
|
|
| 1 |
# π οΈ Developer Documentation
|
| 2 |
|
| 3 |
+
> **Note:** The root-level `DEVELOPER.md` is deprecated. This is the canonical developer documentation. π¦
|
| 4 |
+
|
| 5 |
## π¦ Project Structure
|
| 6 |
|
| 7 |
```
|
|
|
|
| 15 |
βββ pstuts_rag/ # Package directory
|
| 16 |
β βββ pstuts_rag/ # Source code
|
| 17 |
β β βββ __init__.py # Package initialization
|
| 18 |
+
β β βββ configuration.py # Application configuration settings
|
| 19 |
β β βββ datastore.py # Vector database and document management
|
| 20 |
β β βββ rag.py # RAG chain implementation and factories
|
| 21 |
+
β β βββ rag_for_transcripts.py# RAG chain for video transcripts (reference packing)
|
| 22 |
+
β β βββ graph.py # Agent node creation and LangGraph assembly
|
| 23 |
β β βββ state.py # Team state management for agents
|
| 24 |
β β βββ prompts.py # System prompts for different agents
|
| 25 |
β β βββ evaluator_utils.py # RAG evaluation utilities
|
|
|
|
| 47 |
β βββ TODO.md # Development TODO list
|
| 48 |
β βββ chainlit.md # Chainlit welcome message
|
| 49 |
βββ scripts/ # Utility scripts (currently empty)
|
| 50 |
+
βββ public/ # Theme and static files (see theming section)
|
| 51 |
βββ README.md # User-facing documentation
|
| 52 |
```
|
| 53 |
|
|
|
|
| 86 |
- **`DatastoreManager`** (`datastore.py`): Manages Qdrant vector store, document loading, and semantic chunking
|
| 87 |
- **`RAGChainFactory`** (`rag.py`): Creates retrieval-augmented generation chains with reference compilation
|
| 88 |
- **`RAGChainInstance`** (`rag.py`): Encapsulates complete RAG instances with embeddings and vector stores
|
| 89 |
+
- **`RAG for Transcripts`** (`rag_for_transcripts.py`): Implements the RAG chain for searching video transcripts, including reference packing and post-processing for AIMessage responses. Used for context-rich, reference-annotated answers from video data. π¬
|
| 90 |
+
- **`Graph Assembly`** (`graph.py`): Handles agent node creation, LangGraph assembly, and integration of multi-agent workflows. Provides utilities for building, initializing, and running the agentic graph. πΈοΈ
|
| 91 |
|
| 92 |
#### πΈοΈ Multi-Agent System
|
| 93 |
- **`PsTutsTeamState`** (`state.py`): TypedDict managing multi-agent conversation state
|
|
|
|
| 144 |
|
| 145 |
### Sepia Theme Implementation πΌοΈ
|
| 146 |
|
| 147 |
+
The application features a custom **sepia-toned color scheme** implemented via `public/theme.json` and Chainlit's theme configuration:
|
| 148 |
|
| 149 |
#### π Theme Files
|
| 150 |
+
- **`public/theme.json`**: Defines the sepia color palette and theme variables
|
| 151 |
+
- **`.chainlit/config.toml`**: Configuration enabling the sepia theme as default
|
| 152 |
|
| 153 |
#### π¨ Color Palette Design
|
| 154 |
+
Theme colors are defined in `theme.json` and applied through Chainlit's theming system. There is no custom CSS file; all theming is handled via JSON and Chainlit configuration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
#### βοΈ Configuration Setup
|
| 157 |
```toml
|
| 158 |
# .chainlit/config.toml
|
| 159 |
[UI]
|
| 160 |
default_theme = "light" # Set light theme as default
|
| 161 |
+
custom_theme = "/public/theme.json" # Enable custom sepia theme
|
| 162 |
```
|
| 163 |
|
| 164 |
#### π― Features
|
| 165 |
- **Responsive Design**: Adapts to both light and dark preferences
|
| 166 |
- **Accessibility**: Maintains sufficient contrast ratios in both themes
|
| 167 |
- **Visual Cohesion**: Unified sepia treatment across all UI elements
|
| 168 |
+
- **Performance**: JSON-based theme for minimal runtime overhead
|
| 169 |
- **User Control**: Native Chainlit theme switcher toggles between variants
|
| 170 |
|
| 171 |
The sepia theme creates a warm, nostalgic atmosphere perfect for Adobe Photoshop tutorials, giving the application a distinctive visual identity that stands out from standard blue/gray interfaces. πΈβ¨
|
|
|
|
| 282 |
- **State management**: LangGraph for multi-agent coordination
|
| 283 |
- **Evaluation**: RAGAS framework for retrieval and generation metrics
|
| 284 |
|
| 285 |
+
## π Recent Refactors & Enhancements (Spring 2024)
|
| 286 |
+
|
| 287 |
+
### ποΈ Modular App Structure & Async Initialization
|
| 288 |
+
- The main application (`app.py`) is now more modular and async-friendly! Initialization of the datastore, agent graph, and session state is handled with care for concurrency and user experience.
|
| 289 |
+
- The agent graph is now referenced as `ai_graph` (formerly `compiled_graph`) for clarity and onboarding ease.
|
| 290 |
+
- Chainlit session and callback management is improved, making it easier to hook into events and extend the app. π¦
|
| 291 |
+
|
| 292 |
+
### π€ Robust API/Model Selection Logic
|
| 293 |
+
- All API/model selection (for LLMs and embeddings) is now centralized in `utils.py` via `get_chat_api` and `get_embeddings_api`.
|
| 294 |
+
- These functions robustly parse string input to the `ModelAPI` enum, so you can use any case or format (e.g., "openai", "OPENAI", "Ollama") and it will Just Workβ’.
|
| 295 |
+
- This eliminates a whole class of bugs from mismatched config strings! π
|
| 296 |
+
|
| 297 |
+
### π Smarter Search Phrase Generation
|
| 298 |
+
- The search phrase generation logic (in `prompts.py` and node code) now uses previous queries and conversation history to generate unique, context-aware search phrases.
|
| 299 |
+
- This means less repetition, more relevance, and a more natural research workflow for the agents. π§ β¨
|
| 300 |
+
|
| 301 |
+
### βοΈ Enhanced LLM API & Configuration
|
| 302 |
+
- The `Configuration` class (`configuration.py`) now supports robust environment variable overrides and easy conversion to/from `RunnableConfig`.
|
| 303 |
+
- All config parameters are logged and managed with dataclass fields, making debugging and onboarding a breeze.
|
| 304 |
+
|
| 305 |
+
### π¨ Sepia Theme Update
|
| 306 |
+
- The UI now features a beautiful sepia color palette for a warm, inviting look (see above for details!).
|
| 307 |
+
- Theme files and configuration have been updated for seamless switching between light and dark sepia modes.
|
| 308 |
+
- Perfect for those late-night Photoshop tutorial sessions! βπΌοΈ
|
| 309 |
+
|
| 310 |
## π Resources
|
| 311 |
|
| 312 |
- [Chainlit Documentation](https://docs.chainlit.io) π
|