mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-09 17:57:06 +08:00
feat:Recommended questions support user configuration. (#487)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: e408f8766753
|
||||
Revises: cb12c4238120
|
||||
Create Date: 2025-11-24 17:34:04.436927
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e408f8766753'
|
||||
down_revision = 'cb12c4238120'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('ds_recommended_problem',
|
||||
sa.Column('id', sa.BIGINT(),
|
||||
sa.Identity(always=True, start=1, increment=1, minvalue=1, maxvalue=9999999999,
|
||||
cycle=False, cache=1), autoincrement=True, nullable=False),
|
||||
sa.Column('datasource_id', sa.BIGINT(), autoincrement=False, nullable=True),
|
||||
sa.Column('question', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('remark', sa.TEXT(), autoincrement=False, nullable=True),
|
||||
sa.Column('sort', sa.BIGINT(), autoincrement=False, nullable=True),
|
||||
sa.Column('create_time', postgresql.TIMESTAMP(precision=6), autoincrement=False, nullable=True),
|
||||
sa.Column('create_by', sa.BIGINT(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('ds_recommended_problem_pkey'))
|
||||
)
|
||||
op.add_column('core_datasource', sa.Column('recommended_config', sa.BigInteger(),default=0, nullable=True))
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('ds_recommended_problem')
|
||||
op.drop_column('core_datasource', 'recommended_config')
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@ from fastapi import APIRouter
|
||||
from apps.chat.api import chat
|
||||
from apps.dashboard.api import dashboard_api
|
||||
from apps.data_training.api import data_training
|
||||
from apps.datasource.api import datasource, table_relation
|
||||
from apps.datasource.api import datasource, table_relation, recommended_problem
|
||||
from apps.mcp import mcp
|
||||
from apps.system.api import login, user, aimodel, workspace, assistant
|
||||
from apps.terminology.api import terminology
|
||||
@@ -23,3 +23,5 @@ api_router.include_router(chat.router)
|
||||
api_router.include_router(dashboard_api.router)
|
||||
api_router.include_router(mcp.router)
|
||||
api_router.include_router(table_relation.router)
|
||||
|
||||
api_router.include_router(recommended_problem.router)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from apps.datasource.crud.recommended_problem import get_datasource_recommended
|
||||
from common.core.deps import SessionDep
|
||||
|
||||
router = APIRouter(tags=["recommended_problem"], prefix="/recommended_problem")
|
||||
|
||||
|
||||
@router.get("/get_datasource_recommended/{ds_id}")
|
||||
async def datasource_recommended(session: SessionDep, ds_id: int):
|
||||
return get_datasource_recommended(session, ds_id)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from sqlmodel import select
|
||||
|
||||
from common.core.deps import SessionDep
|
||||
from ..models.datasource import DsRecommendedProblem
|
||||
|
||||
|
||||
def get_datasource_recommended(session: SessionDep, ds_id: int):
|
||||
statement = select(DsRecommendedProblem).where(DsRecommendedProblem.datasource_id == ds_id)
|
||||
dsRecommendedProblem = session.exec(statement)
|
||||
return dsRecommendedProblem
|
||||
|
||||
@@ -22,6 +22,7 @@ class CoreDatasource(SQLModel, table=True):
|
||||
oid: int = Field(sa_column=Column(BigInteger()))
|
||||
table_relation: List = Field(sa_column=Column(JSONB, nullable=True))
|
||||
embedding: str = Field(sa_column=Column(Text, nullable=True))
|
||||
recommended_config: int = Field(sa_column=Column(BigInteger()))
|
||||
|
||||
|
||||
class CoreTable(SQLModel, table=True):
|
||||
@@ -34,6 +35,16 @@ class CoreTable(SQLModel, table=True):
|
||||
custom_comment: str = Field(sa_column=Column(Text))
|
||||
embedding: str = Field(sa_column=Column(Text, nullable=True))
|
||||
|
||||
class DsRecommendedProblem(SQLModel, table=True):
|
||||
__tablename__ = "ds_recommended_problem"
|
||||
id: int = Field(sa_column=Column(BigInteger, Identity(always=True), nullable=False, primary_key=True))
|
||||
datasource_id: int = Field(sa_column=Column(BigInteger()))
|
||||
question: str = Field(sa_column=Column(Text))
|
||||
remark: str = Field(sa_column=Column(Text))
|
||||
sort: int = Field(sa_column=Column(BigInteger()))
|
||||
create_time: datetime = Field(sa_column=Column(DateTime(timezone=False), nullable=True))
|
||||
create_by: int = Field(sa_column=Column(BigInteger()))
|
||||
|
||||
|
||||
class CoreField(SQLModel, table=True):
|
||||
__tablename__ = "core_field"
|
||||
@@ -61,6 +72,7 @@ class CreateDatasource(BaseModel):
|
||||
num: str = ''
|
||||
oid: int = 1
|
||||
tables: List[CoreTable] = []
|
||||
recommended_config: int = 1
|
||||
|
||||
|
||||
# edit local saved table and fields
|
||||
|
||||
Reference in New Issue
Block a user