mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-20 23:21:06 +02:00
feat: add interface params
This commit is contained in:
parent
38b25702bc
commit
1b77269da6
5 changed files with 131 additions and 2 deletions
|
|
@ -0,0 +1,32 @@
|
||||||
|
"""add inference_params to searchspaces 2
|
||||||
|
|
||||||
|
Revision ID: 2c3ace3296c0
|
||||||
|
Revises: 9bc8b50514d0
|
||||||
|
Create Date: 2025-10-05 12:56:00.739719
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '2c3ace3296c0'
|
||||||
|
down_revision: Union[str, None] = '9bc8b50514d0'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
"""add inference_params to searchspaces
|
||||||
|
|
||||||
|
Revision ID: 4bad510c6eb4
|
||||||
|
Revises: 21
|
||||||
|
Create Date: 2025-10-05 10:19:08.790345
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '4bad510c6eb4'
|
||||||
|
down_revision: Union[str, None] = '21'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column('chats', 'type',
|
||||||
|
existing_type=postgresql.ENUM('QNA', 'REPORT_GENERAL', 'REPORT_DEEP', 'REPORT_DEEPER', name='chattype'),
|
||||||
|
nullable=False)
|
||||||
|
op.drop_index(op.f('chucks_search_index'), table_name='chunks', postgresql_using='gin')
|
||||||
|
op.drop_index(op.f('chucks_vector_index'), table_name='chunks', postgresql_using='hnsw')
|
||||||
|
op.drop_index(op.f('document_search_index'), table_name='documents', postgresql_using='gin')
|
||||||
|
op.drop_index(op.f('document_vector_index'), table_name='documents', postgresql_using='hnsw')
|
||||||
|
op.add_column('searchspaces', sa.Column('inference_params', sa.JSON(), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('searchspaces', 'inference_params')
|
||||||
|
op.create_index(op.f('document_vector_index'), 'documents', ['embedding'], unique=False, postgresql_using='hnsw')
|
||||||
|
op.create_index(op.f('document_search_index'), 'documents', [sa.literal_column("to_tsvector('english'::regconfig, content)")], unique=False, postgresql_using='gin')
|
||||||
|
op.create_index(op.f('chucks_vector_index'), 'chunks', ['embedding'], unique=False, postgresql_using='hnsw')
|
||||||
|
op.create_index(op.f('chucks_search_index'), 'chunks', [sa.literal_column("to_tsvector('english'::regconfig, content)")], unique=False, postgresql_using='gin')
|
||||||
|
op.alter_column('chats', 'type',
|
||||||
|
existing_type=postgresql.ENUM('QNA', 'REPORT_GENERAL', 'REPORT_DEEP', 'REPORT_DEEPER', name='chattype'),
|
||||||
|
nullable=True)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
"""add inference_params to searchspaces 1
|
||||||
|
|
||||||
|
Revision ID: 9bc8b50514d0
|
||||||
|
Revises: 4bad510c6eb4
|
||||||
|
Create Date: 2025-10-05 12:31:02.448057
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '9bc8b50514d0'
|
||||||
|
down_revision: Union[str, None] = '4bad510c6eb4'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
@ -27,6 +27,8 @@ from app.config import config
|
||||||
from app.retriver.chunks_hybrid_search import ChucksHybridSearchRetriever
|
from app.retriver.chunks_hybrid_search import ChucksHybridSearchRetriever
|
||||||
from app.retriver.documents_hybrid_search import DocumentHybridSearchRetriever
|
from app.retriver.documents_hybrid_search import DocumentHybridSearchRetriever
|
||||||
|
|
||||||
|
from sqlalchemy.ext.mutable import MutableDict
|
||||||
|
|
||||||
if config.AUTH_TYPE == "GOOGLE":
|
if config.AUTH_TYPE == "GOOGLE":
|
||||||
from fastapi_users.db import SQLAlchemyBaseOAuthAccountTableUUID
|
from fastapi_users.db import SQLAlchemyBaseOAuthAccountTableUUID
|
||||||
|
|
||||||
|
|
@ -204,6 +206,14 @@ class SearchSpace(BaseModel, TimestampMixin):
|
||||||
name = Column(String(100), nullable=False, index=True)
|
name = Column(String(100), nullable=False, index=True)
|
||||||
description = Column(String(500), nullable=True)
|
description = Column(String(500), nullable=True)
|
||||||
|
|
||||||
|
inference_params = Column(
|
||||||
|
MutableDict.as_mutable(JSON),
|
||||||
|
nullable=True,
|
||||||
|
server_default=text(
|
||||||
|
'\'{"temperature":0.0,"max_tokens":0,"top_k":0,"top_p":0}\'::json'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
user_id = Column(
|
user_id = Column(
|
||||||
UUID(as_uuid=True), ForeignKey("user.id", ondelete="CASCADE"), nullable=False
|
UUID(as_uuid=True), ForeignKey("user.id", ondelete="CASCADE"), nullable=False
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,21 @@
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from .base import IDModel, TimestampModel
|
from .base import IDModel, TimestampModel
|
||||||
|
|
||||||
|
class InferenceParams(BaseModel):
|
||||||
|
temperature: float | None = Field(None, ge=0.0, le=2.0)
|
||||||
|
max_tokens: int | None = Field(None, ge=0)
|
||||||
|
top_k: int | None = Field(None, ge=0)
|
||||||
|
top_p: int | None = Field(None, ge=0, le=1)
|
||||||
|
|
||||||
|
|
||||||
class SearchSpaceBase(BaseModel):
|
class SearchSpaceBase(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
description: str | None = None
|
description: str | None = None
|
||||||
|
inference_params: InferenceParams | None = None
|
||||||
|
|
||||||
|
|
||||||
class SearchSpaceCreate(SearchSpaceBase):
|
class SearchSpaceCreate(SearchSpaceBase):
|
||||||
|
|
@ -16,7 +23,9 @@ class SearchSpaceCreate(SearchSpaceBase):
|
||||||
|
|
||||||
|
|
||||||
class SearchSpaceUpdate(SearchSpaceBase):
|
class SearchSpaceUpdate(SearchSpaceBase):
|
||||||
pass
|
name: str | None = None
|
||||||
|
description: str | None = None
|
||||||
|
inference_params: InferenceParams | None = None
|
||||||
|
|
||||||
|
|
||||||
class SearchSpaceRead(SearchSpaceBase, IDModel, TimestampModel):
|
class SearchSpaceRead(SearchSpaceBase, IDModel, TimestampModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue