File size: 2,490 Bytes
b44bcb9
 
 
 
 
 
059d9b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b44bcb9
 
 
 
059d9b6
b44bcb9
 
 
059d9b6
 
 
 
b44bcb9
 
 
 
 
 
 
 
 
 
 
059d9b6
b44bcb9
 
059d9b6
 
 
 
 
 
 
b44bcb9
 
 
 
059d9b6
 
 
 
 
 
b44bcb9
059d9b6
b44bcb9
059d9b6
 
 
b44bcb9
 
 
 
 
059d9b6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# πŸ› οΈ Developer Documentation

## πŸ“¦ Project Structure

```
.
β”œβ”€β”€ app.py                # Main Chainlit application
β”œβ”€β”€ app_simple_rag.py     # Simplified RAG application 
β”œβ”€β”€ pyproject.toml        # Project configuration and dependencies
β”œβ”€β”€ pstuts_rag/           # Core package
β”‚   └── pstuts_rag/       # Source code
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ datastore.py  # Vector database management
β”‚       β”œβ”€β”€ loader.py     # Data loading utilities
β”‚       β”œβ”€β”€ rag.py        # RAG implementation
β”‚       β”œβ”€β”€ agents.py     # Team agent implementation
β”‚       └── ...
β”œβ”€β”€ data/                 # Dataset files
└── README.md             # User documentation
```

## 🧩 Dependency Structure

Dependencies are organized into logical groups:

- **Core**: Basic dependencies needed for the RAG system (includes Jupyter support)
- **Dev**: Development tools (linting, testing, etc.)
- **Web**: Dependencies for web server functionality
- **Extras**: Additional optional packages (numpy, ragas, tavily)

You can install different combinations using pip's extras syntax:
```bash
pip install -e ".[dev,web]"  # Install core + dev + web dependencies
```

## πŸ”§ Technical Details

The application uses LangChain, LangGraph, and Chainlit to create an agentic RAG system:

### Key Components

- **DatastoreManager**: Manages the Qdrant vector store and document retrieval
- **RAGChainFactory**: Creates retrieval-augmented generation chains
- **PsTutsTeamState**: Manages the state of the agent-based system
- **Langgraph**: Implements the routing logic between different agents

## πŸš€ Running Locally

1. Create a virtual environment (recommended):
```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

2. Install dependencies:
```bash
pip install -e ".[dev]"  # Install with development tools
```

3. Set up API keys:
```bash
export OPENAI_API_KEY="your-openai-key"
export TAVILY_API_KEY="your-tavily-key"  # Optional, for web search
```

4. Run the application:
```bash
chainlit run app.py
```

## πŸ§ͺ Code Quality

To check for dependency issues:
```bash
deptry .
```

For linting:
```bash
black .
ruff check .
mypy .
```

## πŸ“š Resources

- [Chainlit Documentation](https://docs.chainlit.io)
- [LangChain Documentation](https://python.langchain.com/docs/get_started/introduction)
- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)