From 5841525b4c03a39ae072f23d2d4a091a0b4dde5a Mon Sep 17 00:00:00 2001 From: Josako Date: Thu, 31 Oct 2024 08:32:02 +0100 Subject: [PATCH] - When no explicit path is given in the browser, we automatically get redirected to the admin interface (eveai_app) - Tuning moved to Retriever iso in the configuration, as this is an attribute that should be available for all types of Retrievers --- common/langchain/eveai_retriever.py | 1 + common/models/document.py | 1 + config/retriever_types.py | 7 ----- eveai_app/views/document_forms.py | 2 ++ .../331f8100eb87_add_tuning_to_retriever.py | 29 +++++++++++++++++++ nginx/nginx.conf | 3 ++ 6 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 migrations/tenant/versions/331f8100eb87_add_tuning_to_retriever.py diff --git a/common/langchain/eveai_retriever.py b/common/langchain/eveai_retriever.py index d394920..3ce57b1 100644 --- a/common/langchain/eveai_retriever.py +++ b/common/langchain/eveai_retriever.py @@ -11,6 +11,7 @@ class EveAIRetriever(BaseModel): _configuration: Dict[str, Any] = PrivateAttr() _tenant_info: Dict[str, Any] = PrivateAttr() _model_variables: ModelVariables = PrivateAttr() + _tuning: bool = PrivateAttr() def __init__(self, catalog_id: int, user_metadata: Dict[str, Any], system_metadata: Dict[str, Any], configuration: Dict[str, Any]): diff --git a/common/models/document.py b/common/models/document.py index fc10127..4f383f9 100644 --- a/common/models/document.py +++ b/common/models/document.py @@ -47,6 +47,7 @@ class Retriever(db.Model): description = db.Column(db.Text, nullable=True) catalog_id = db.Column(db.Integer, db.ForeignKey('catalog.id'), nullable=True) type = db.Column(db.String(50), nullable=False, default="DEFAULT_RAG") + tuning = db.Column(db.Boolean, nullable=True, default=False) # Meta Data user_metadata = db.Column(JSONB, nullable=True) diff --git a/config/retriever_types.py b/config/retriever_types.py index 84c2539..2a4f1c5 100644 --- a/config/retriever_types.py +++ b/config/retriever_types.py @@ -18,13 +18,6 @@ RETRIEVER_TYPES = { "required": True, "default": 0.3, }, - "rag_tuning": { - "name": "rag_tuning", - "type": "boolean", - "description": "Whether to do tuning logging or not.", - "required": False, - "default": False, - } } } } diff --git a/eveai_app/views/document_forms.py b/eveai_app/views/document_forms.py index 8412888..021bd40 100644 --- a/eveai_app/views/document_forms.py +++ b/eveai_app/views/document_forms.py @@ -113,6 +113,7 @@ class RetrieverForm(FlaskForm): ) # Select Field for Retriever Type (Uses the RETRIEVER_TYPES defined in config) type = SelectField('Retriever Type', validators=[DataRequired()]) + tuning = BooleanField('Enable Tuning', default=False) # Metadata fields user_metadata = TextAreaField('User Metadata', validators=[Optional(), validate_json]) @@ -137,6 +138,7 @@ class EditRetrieverForm(DynamicFormBase): ) # Select Field for Retriever Type (Uses the RETRIEVER_TYPES defined in config) type = SelectField('Retriever Type', validators=[DataRequired()], render_kw={'readonly': True}) + tuning = BooleanField('Enable Tuning', default=False) # Metadata fields user_metadata = TextAreaField('User Metadata', validators=[Optional(), validate_json]) diff --git a/migrations/tenant/versions/331f8100eb87_add_tuning_to_retriever.py b/migrations/tenant/versions/331f8100eb87_add_tuning_to_retriever.py new file mode 100644 index 0000000..c88690c --- /dev/null +++ b/migrations/tenant/versions/331f8100eb87_add_tuning_to_retriever.py @@ -0,0 +1,29 @@ +"""Add tuning to Retriever + +Revision ID: 331f8100eb87 +Revises: 6c5ca750e60c +Create Date: 2024-10-31 07:17:22.579376 + +""" +from alembic import op +import sqlalchemy as sa +import pgvector + + +# revision identifiers, used by Alembic. +revision = '331f8100eb87' +down_revision = '6c5ca750e60c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('retriever', sa.Column('tuning', sa.Boolean(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('retriever', 'tuning') + # ### end Alembic commands ### diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f3fb9f5..d6fad8a 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -48,6 +48,9 @@ http { #access_log logs/host.access.log main; + location = / { + return 301 /admin/; + } location / { root /etc/nginx/public; index index.html index.htm;