- Revisiting RAG_SPECIALIST

- Adapt Catalogs & Retrievers to use specific types, removing tagging_fields
- Adding CrewAI Implementation Guide
This commit is contained in:
Josako
2025-07-08 15:54:16 +02:00
parent 33b5742d2f
commit 509ee95d81
32 changed files with 997 additions and 825 deletions

View File

@@ -11,9 +11,9 @@ from wtforms_sqlalchemy.fields import QuerySelectField
from common.extensions import cache_manager
from common.models.document import Catalog
from common.services.user import TenantServices
from common.utils.form_assistants import validate_json
from config.type_defs.catalog_types import CATALOG_TYPES
from config.type_defs.processor_types import PROCESSOR_TYPES
from .dynamic_form_base import DynamicFormBase
@@ -45,7 +45,11 @@ class CatalogForm(FlaskForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Dynamically populate the 'type' field using the constructor
self.type.choices = [(key, value['name']) for key, value in CATALOG_TYPES.items()]
types_dict = cache_manager.catalogs_types_cache.get_types()
# Dynamically populate the 'type' field using the constructor
tenant_id = session.get('tenant').get('id')
choices = TenantServices.get_available_types_for_tenant(tenant_id, "catalogs")
self.type.choices = [(key, value['name']) for key, value in choices.items()]
class EditCatalogForm(DynamicFormBase):
@@ -55,6 +59,7 @@ class EditCatalogForm(DynamicFormBase):
# Select Field for Catalog Type (Uses the CATALOG_TYPES defined in config)
type = StringField('Catalog Type', validators=[DataRequired()], render_kw={'readonly': True})
type_version = StringField('Catalog Type Version', validators=[DataRequired()], render_kw={'readonly': True})
# Selection fields for processing & creating embeddings
min_chunk_size = IntegerField('Minimum Chunk Size (2000)', validators=[NumberRange(min=0), Optional()],
@@ -130,9 +135,21 @@ class RetrieverForm(FlaskForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
types_dict = cache_manager.retrievers_types_cache.get_types()
tenant_id = session.get('tenant').get('id')
choices = TenantServices.get_available_types_for_tenant(tenant_id, "retrievers")
current_app.logger.debug(f"Potential choices: {choices}")
# Dynamically populate the 'type' field using the constructor
self.type.choices = [(key, value['name']) for key, value in types_dict.items()]
type_choices = []
for key, value in choices.items():
valid_catalog_types = value.get('valid_catalog_types', None)
if valid_catalog_types:
catalog_type = session.get('catalog').get('type')
current_app.logger.debug(f"Check {catalog_type} in {valid_catalog_types}")
if catalog_type in valid_catalog_types:
type_choices.append((key, value['name']))
else: # Retriever type is valid for all catalog types
type_choices.append((key, value['name']))
self.type.choices = type_choices
class EditRetrieverForm(DynamicFormBase):
@@ -141,6 +158,7 @@ class EditRetrieverForm(DynamicFormBase):
# Select Field for Retriever Type (Uses the RETRIEVER_TYPES defined in config)
type = StringField('Processor Type', validators=[DataRequired()], render_kw={'readonly': True})
type_version = StringField('Retriever Type Version', validators=[DataRequired()], render_kw={'readonly': True})
tuning = BooleanField('Enable Tuning', default=False)
# Metadata fields