Skip to content

Commit 707756c

Browse files
committed
Add in-memory vector store demos for chat and search
Introduce two new demo scripts: `chat_with_memory.py` for simulating conversations with in-memory message storage and semantic search, and `simple_search_demo.py` for demonstrating vector search capabilities without database setup. Additionally, a README.md file is added to provide an overview of the in-memory vector store demos, including prerequisites and usage patterns. - `chat_with_memory.py`: Simulates a conversation, showcases message storage, retrieval, and semantic search. - `simple_search_demo.py`: Demonstrates basic vector search with filtering and metadata. - `README.md`: Overview of demos, installation instructions, and comparison with PostgreSQL-based solutions. These additions enhance the usability and accessibility of the in-memory vector store for prototyping and learning purposes.
1 parent bd97864 commit 707756c

File tree

14 files changed

+1320
-239
lines changed

14 files changed

+1320
-239
lines changed

CONTRIBUTING.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ uv pip install -U .
2222
# Install with all test dependencies (includes PostgreSQL/PGVector, Qdrant, etc.)
2323
uv pip install -U ".[testall]"
2424

25-
# Run tests (skips integration tests by default)
25+
# Run tests (uses in-memory stores, skips PostgreSQL integration tests)
2626
pytest test/ -v
2727

2828
# Run specific test file
2929
pytest test/test_llm_wrapper.py -v
3030

31+
# Run vector store tests (fast, no PostgreSQL needed)
32+
pytest test/store/ -v
33+
3134
# Run integration tests (requires PostgreSQL with PGVector)
3235
pytest test/ -v -m integration
3336

@@ -298,13 +301,58 @@ After the first manual upload, you can use trusted publishing for all future rel
298301
- You can't overwrite versions on PyPI
299302
- Increment the version in `pylib/__about__.py` and create a new release
300303

301-
## Testing Integration Features
304+
## Testing Strategies
305+
306+
### In-Memory Testing (Default)
307+
308+
By default, vector store tests use **in-memory implementations** requiring zero setup:
309+
310+
```bash
311+
# Fast tests, no external dependencies
312+
pytest test/store/ -v # ~0.5 seconds
313+
314+
# All tests (skips integration by default)
315+
pytest test/ -v
316+
```
317+
318+
**Benefits:**
319+
- ✅ Zero setup - works everywhere
320+
- ✅ Lightning fast execution
321+
- ✅ Perfect for CI/CD
322+
- ✅ Ideal for rapid iteration
323+
324+
The in-memory stores (`RAMDataDB`, `RAMMessageDB`) are full-featured and also available to users for prototyping. See `demo/ram-store/` for examples.
325+
326+
### Integration Testing (Optional PostgreSQL)
327+
328+
Integration tests verify behavior against real PostgreSQL with pgvector. These are **skipped by default** but useful for:
329+
- Validating database-specific features
330+
- Testing migration paths
331+
- Performance benchmarking
332+
333+
**Setup PostgreSQL for Integration Tests:**
334+
335+
```bash
336+
# Option 1: Docker (recommended)
337+
docker run -d -p 5432:5432 \
338+
-e POSTGRES_USER=mock_user \
339+
-e POSTGRES_PASSWORD=mock_password \
340+
-e POSTGRES_DB=mock_db \
341+
pgvector/pgvector:pg17
342+
343+
# Option 2: Set environment variables for existing PostgreSQL
344+
export PG_DB_HOST='localhost'
345+
export PG_DB_NAME='test_db'
346+
export PG_DB_USER='user'
347+
export PG_DB_PASSWORD='pass'
348+
export PG_DB_PORT='5432'
349+
350+
# Run integration tests
351+
pytest test/store/ -v -m integration
352+
```
302353

303-
Some features require external services:
354+
**Other Integration Tests:**
304355

305-
- **PostgreSQL with PGVector**: Required for vector store integration tests
306-
- Set environment variables: `PG_HOST`, `PG_DATABASE`, `PG_USER`, `PG_PASSWORD`, `PG_PORT`
307-
- Or use Docker: `docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=testpass pgvector/pgvector:pg16`
308356
- **Qdrant**: Required for Qdrant store tests (optional)
309357
- Can be run locally or via Docker
310358

0 commit comments

Comments
 (0)