Skip to content

Embedding Service#1286

Draft
EmanueleDeRossi1 wants to merge 26 commits intomainfrom
feature/embedding-service
Draft

Embedding Service#1286
EmanueleDeRossi1 wants to merge 26 commits intomainfrom
feature/embedding-service

Conversation

@EmanueleDeRossi1
Copy link
Collaborator

This PR introduces changes from the feature/embedding-service branch.

📝 Summary

📁 Files Changed ( 17 files)

.github/workflows/backend-test.yml
apps/backend/pyproject.toml
apps/backend/src/rhesis/backend/alembic/versions/a1b2c3d4e5f8_create_embedding_table.py
apps/backend/src/rhesis/backend/app/models/__init__.py
apps/backend/src/rhesis/backend/app/models/embedding.py
apps/backend/src/rhesis/backend/app/models/mixins.py
apps/backend/src/rhesis/backend/app/models/source.py
apps/backend/src/rhesis/backend/app/models/test.py
apps/backend/src/rhesis/backend/app/services/async_service.py
apps/backend/src/rhesis/backend/app/services/initial_data.json
apps/backend/src/rhesis/backend/app/services/telemetry/enrichment/service.py
apps/backend/uv.lock
docker-compose.yml
docs/content/development/index.mdx
infrastructure/k8s/charts/rhesis/values.yaml
tests/README.md
tests/sdk/integration/docker-compose.yml

📋 Commit Details

ea914325f - refactor(telemetry): migrate EnrichmentService to AsyncService base (Emanuele De Rossi, 2026-02-09 11:35)
60b8f5515 - feat(services): add AsyncService base class for async/sync task orchestration (Emanuele De Rossi, 2026-02-09 11:33)
0bc7d2d43 - fix: remove ABC inheritance from EmbeddableMixin (Emanuele De Rossi, 2026-02-04 09:54)
90d40f2cc - feat: add EmbeddableMixin for searchable text generation (Emanuele De Rossi, 2026-02-04 09:03)
97c78e0bf - feat: enhance embedding table with multi-dimension support and full-text search (Emanuele De Rossi, 2026-02-03 15:44)
0bb1a9f08 - feat(db): enable pgvector extension for vector storage (Emanuele De Rossi, 2026-02-03 11:37)
616d94472 - feat: add multi-dimension embedding storage system (Emanuele De Rossi, 2026-02-02 09:14)

✅ Checklist

  • Code follows the project's style guidelines
  • Self-review of code has been performed
  • Code is commented, particularly in hard-to-understand areas
  • Corresponding changes to documentation have been made
  • Tests have been added/updated for new functionality
  • All tests pass locally

🧪 Testing

📸 Screenshots (if applicable)

🔗 Related Issues

- Rename get_model() → get_language_model() and get_embedder() → get_embedding_model()
- Rename ModelConfig → LanguageModelConfig and EmbedderConfig → EmbeddingModelConfig
- Keep deprecated aliases for backward compatibility
- Renamed get_model() to get_language_model() across SDK
- Renamed DEFAULT_MODEL_NAME to DEFAULT_LANGUAGE_MODEL_NAME in all providers
- Renamed PROVIDER_REGISTRY to LANGUAGE_MODEL_PROVIDER_REGISTRY
Rename DEFAULT_GENERATION_MODEL → DEFAULT_LANGUAGE_MODEL_PROVIDER and DEFAULT_MODEL_NAME → DEFAULT_LANGUAGE_MODEL_NAME across all services
- rename model_type to purpose in _get_user_model and related functions to avoid confusion between model_type terminology (which refers to whether model is either language/embedding model)
Add Rhesis as the default embedding model provider, following the same  pattern as the language model:

Backend changes:
- Update constants to use consistent naming (DEFAULT_EMBEDDING_MODEL_PROVIDER)
- Create default Rhesis embedding model during organization initialization
- Store both language_model_id and embedding_model_id in user settings
- Update generate/embedding endpoint to use new constants

SDK changes:
- Implement complete RhesisEmbedder class with generate() and generate_batch()
- Add factory function for Rhesis embedding model
- Register "rhesis" provider in EMBEDDING_MODEL_REGISTRY
- Update DEFAULT_EMBEDDING_MODEL_PROVIDER from "openai" to "rhesis"

This enables users to use Rhesis-hosted embeddings by default while still allowing custom embedding model configuration.
- use correct import (DEFAULT_LANGUAGE_MODEL_PROVIDER) in tests
- remove unused aliases (DEFAULT_MODELS, DEFAULT_PROVIDER)
Implement dedicated Embedding table with support for multiple vector dimensions (768, 1536, 3072) using separate columns for better performance and type safety. Embeddings have a polymorphic relationship pattern, now supporting Test and Source entities.

Key changes:
- Add Embedding model with vector_768, vector_1536, vector_3072 columns
- Add pgvector dependency for PostgreSQL vector operations
- Create Alembic migration with HNSW indexes
- Add polymorphic embeddings relationship to Test and Source models
- Add constraint ensuring exactly one vector column is populated per record
- Update PostgreSQL images from postgres:16-alpine to pgvector/pgvector:pg16 across all environments (local, k8s, CI/CD)
…ext search

Add support for 384, 768, 1024, and 1536-dimensional embeddings with pgvector HNSW indexes.
Introduce embedding configuration tracking with config_hash, text_hash, status and weight fields
Add EmbeddingConfig utility class and improved property accessors for dynamic column selection.
Update initial data
Add abstract mixin requiring entities to implement to_searchable_text() for embeddings and full-text search. Implement for Source and Test models.
This fixes the metaclass conflict where Test was inherit both from Base (which uses sqlachlemy's DeclaritiveMeta metaclass) and ABC (which uses ABCMeta metaclass)
…stration

Add reusable base class that provides:
- Celery worker availability checking with timeout
- Automatic fallback from async to sync execution
- Batch processing with single worker check optimization
- Generic typing support for different return types

This pattern enables services to seamlessly work in both production (with Celery workers) and development (without workers) environments.
- Extend AsyncService for standardized async/sync orchestration
- Replace custom worker checking with inherited implementation
- Simplify enqueue_enrichment using execute_with_fallback
- Use batch_execute for efficient multi-trace processing
- Add dimension column to Model table
- Auto-detect and store embedding dimensions during connection test
…int param

The endpoint parameter was never used for embedding models, only for LLMs. Remove it from _test_embedding_connection
Implement EmbeddingGenerator class to generate and manage embeddings for any embeddable entity in the system.

Key features:
- Generate embeddings using configurable embedding models
- Compute content and configuration hashes for deduplication
- Automatic detection and marking of stale embeddings
- Support for multiple entity types with dynamic model lookup
- Proper error handling for invalid entity types and missing entities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant