|
| 1 | +# AGENTS.md - RedisVL Project Context |
| 2 | + |
| 3 | +## Frequently Used Commands |
| 4 | + |
| 5 | +```bash |
| 6 | +# Development workflow |
| 7 | +make install # Install dependencies |
| 8 | +make format # Format code (black + isort) |
| 9 | +make check-types # Run mypy type checking |
| 10 | +make lint # Run all linting (format + types) |
| 11 | +make test # Run tests (no external APIs) |
| 12 | +make test-all # Run all tests (includes API tests) |
| 13 | +make check # Full check (lint + test) |
| 14 | + |
| 15 | +# Redis setup |
| 16 | +make redis-start # Start Redis container |
| 17 | +make redis-stop # Stop Redis container |
| 18 | + |
| 19 | +# Documentation |
| 20 | +make docs-build # Build documentation |
| 21 | +make docs-serve # Serve docs locally |
| 22 | +``` |
| 23 | + |
| 24 | +Pre-commit hooks are also configured, which you should |
| 25 | +run before you commit: |
| 26 | +```bash |
| 27 | +pre-commit run --all-files |
| 28 | +``` |
| 29 | + |
| 30 | +## Important Architectural Patterns |
| 31 | + |
| 32 | +### Async/Sync Dual Interfaces |
| 33 | +- Most core classes have both sync and async versions (e.g., `SearchIndex` / `AsyncSearchIndex`) |
| 34 | +- Follow existing patterns when adding new functionality |
| 35 | + |
| 36 | +### Schema-Driven Design |
| 37 | +```python |
| 38 | +# Index schemas define structure |
| 39 | +schema = IndexSchema.from_yaml("schema.yaml") |
| 40 | +index = SearchIndex(schema, redis_url="redis://localhost:6379") |
| 41 | +``` |
| 42 | + |
| 43 | +## Critical Rules |
| 44 | + |
| 45 | +### Do Not Modify |
| 46 | +- **CRITICAL**: Do not change this line unless explicitly asked: |
| 47 | + ```python |
| 48 | + token.strip().strip(",").replace(""", "").replace(""", "").lower() |
| 49 | + ``` |
| 50 | + |
| 51 | +### Git Operations |
| 52 | +**CRITICAL**: NEVER use `git push` or attempt to push to remote repositories. The user will handle all git push operations. |
| 53 | + |
| 54 | +### Branch and Commit Policy |
| 55 | +**IMPORTANT**: Use conventional branch names and conventional commits. |
| 56 | + |
| 57 | +Branch naming: |
| 58 | +- Human-created branches should use `<type>/<short-kebab-description>` |
| 59 | +- Automation-created branches may use `codex/<type>/<short-kebab-description>` |
| 60 | +- Preferred branch types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `perf`, `build`, `ci` |
| 61 | +- Examples: |
| 62 | + - `feat/index-migrator` |
| 63 | + - `fix/async-sentinel-pool` |
| 64 | + - `docs/index-migrator-benchmarking` |
| 65 | + - `codex/feat/index-migrator` |
| 66 | + |
| 67 | +Commit messages: |
| 68 | +- Use Conventional Commits: `<type>(optional-scope): <summary>` |
| 69 | +- Preferred commit types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `perf`, `build`, `ci` |
| 70 | +- Examples: |
| 71 | + - `feat(migrate): add drop recreate planning docs` |
| 72 | + - `docs(index-migrator): add benchmarking guidance` |
| 73 | + - `fix(cli): validate migrate plan inputs` |
| 74 | + |
| 75 | +### Code Quality |
| 76 | +**IMPORTANT**: Always run `make format` before committing code to ensure proper formatting and linting compliance. |
| 77 | + |
| 78 | +### README.md Maintenance |
| 79 | +**IMPORTANT**: DO NOT modify README.md unless explicitly requested. |
| 80 | + |
| 81 | +**If you need to document something, use these alternatives:** |
| 82 | +- Development info → CONTRIBUTING.md |
| 83 | +- API details → docs/ directory |
| 84 | +- Examples → docs/examples/ |
| 85 | +- Project memory (explicit preferences, directives, etc.) → AGENTS.md |
| 86 | + |
| 87 | +## Code Style Preferences |
| 88 | + |
| 89 | +### Import Organization |
| 90 | +- **Prefer module-level imports** by default for clarity and standard Python conventions |
| 91 | +- **Use local/inline imports only when necessary** for specific reasons: |
| 92 | + - Avoiding circular import dependencies |
| 93 | + - Improving startup time for heavy/optional dependencies |
| 94 | + - Lazy loading for performance-critical paths |
| 95 | +- When using local imports, add a brief comment explaining why (e.g., `# Local import to avoid circular dependency`) |
| 96 | + |
| 97 | +### Comments and Output |
| 98 | +- **No emojis in code comments or print statements** |
| 99 | +- Keep comments professional and focused on technical clarity |
| 100 | +- Use emojis sparingly only in user-facing documentation (markdown files), not in Python code |
| 101 | + |
| 102 | +### General Guidelines |
| 103 | +- Follow existing patterns in the RedisVL codebase |
| 104 | +- Maintain consistency with the project's established conventions |
| 105 | +- Run `make format` before committing to ensure code quality standards |
| 106 | + |
| 107 | +## Testing Notes |
| 108 | +RedisVL uses `pytest` with `testcontainers` for testing. |
| 109 | + |
| 110 | +- `make test` - unit tests only (no external APIs) |
| 111 | +- `make test-all` - run the full suite, including tests that call external APIs |
| 112 | +- `pytest --run-api-tests` - explicitly run API-dependent tests (e.g., LangCache, |
| 113 | + external vectorizer/reranker providers). These require the appropriate API |
| 114 | + keys and environment variables to be set. |
| 115 | + |
| 116 | +## Project Structure |
| 117 | + |
| 118 | +``` |
| 119 | +redisvl/ |
| 120 | +├── cli/ # Command-line interface (rvl command) |
| 121 | +├── extensions/ # AI extensions (cache, memory, routing) |
| 122 | +│ ├── cache/ # Semantic caching for LLMs |
| 123 | +│ ├── llmcache/ # LLM-specific caching |
| 124 | +│ ├── message_history/ # Chat history management |
| 125 | +│ ├── router/ # Semantic routing |
| 126 | +│ └── session_manager/ # Session management |
| 127 | +├── index/ # SearchIndex classes (sync/async) |
| 128 | +├── query/ # Query builders (Vector, Range, Filter, Count) |
| 129 | +├── redis/ # Redis client utilities |
| 130 | +├── schema/ # Index schema definitions |
| 131 | +└── utils/ # Utilities (vectorizers, rerankers, optimization) |
| 132 | + ├── rerank/ # Result reranking |
| 133 | + └── vectorize/ # Embedding providers integration |
| 134 | +``` |
| 135 | + |
| 136 | +## Core Components |
| 137 | + |
| 138 | +### 1. Index Management |
| 139 | +- `SearchIndex` / `AsyncSearchIndex` - Main interface for Redis vector indices |
| 140 | +- `IndexSchema` - Define index structure with fields (text, tags, vectors, etc.) |
| 141 | +- Support for JSON and Hash storage types |
| 142 | + |
| 143 | +### 2. Query System |
| 144 | +- `VectorQuery` - Semantic similarity search |
| 145 | +- `RangeQuery` - Vector search within distance range |
| 146 | +- `FilterQuery` - Metadata filtering and full-text search |
| 147 | +- `CountQuery` - Count matching records |
| 148 | +- Etc. |
| 149 | + |
| 150 | +### 3. AI Extensions |
| 151 | +- `SemanticCache` - LLM response caching with semantic similarity |
| 152 | +- `EmbeddingsCache` - Cache for vector embeddings |
| 153 | +- `MessageHistory` - Chat history with recency/relevancy retrieval |
| 154 | +- `SemanticRouter` - Route queries to topics/intents |
| 155 | + |
| 156 | +### 4. Vectorizers (Optional Dependencies) |
| 157 | +- OpenAI, Azure OpenAI, Cohere, HuggingFace, Mistral, VoyageAI |
| 158 | +- Custom vectorizer support |
| 159 | +- Batch processing capabilities |
| 160 | + |
| 161 | +## Documentation |
| 162 | +- Main docs: https://docs.redisvl.com |
| 163 | +- Built with Sphinx from `docs/` directory |
| 164 | +- Includes API reference and user guides |
| 165 | +- Example notebooks in documentation `docs/user_guide/...` |
0 commit comments