Skip to content

Commit 8cc1558

Browse files
committed
feat: Vector retrieval matches tables
1 parent e8673c8 commit 8cc1558

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

backend/apps/chat/task/llm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def select_datasource(self):
406406
full_thinking_text = ''
407407
full_text = ''
408408
if not ignore_auto_select:
409-
if settings.EMBEDDING_ENABLED:
409+
if settings.TABLE_EMBEDDING_ENABLED:
410410
ds = get_ds_embedding(self.session, self.current_user, _ds_list, self.out_ds_instance,
411411
self.chat_question.question, self.current_assistant)
412412
yield {'content': '{"id":' + str(ds.get('id')) + '}'}
@@ -496,7 +496,7 @@ def select_datasource(self):
496496
except Exception as e:
497497
_error = e
498498

499-
if not ignore_auto_select and not settings.EMBEDDING_ENABLED:
499+
if not ignore_auto_select and not settings.TABLE_EMBEDDING_ENABLED:
500500
self.record = save_select_datasource_answer(session=self.session, record_id=self.record.id,
501501
answer=orjson.dumps({'content': full_text}).decode(),
502502
datasource=_datasource,

backend/apps/datasource/crud/datasource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from apps.db.constant import DB
1414
from apps.db.db import get_tables, get_fields, exec_sql, check_connection
1515
from apps.db.engine import get_engine_config, get_engine_conn
16+
from common.core.config import settings
1617
from common.core.deps import SessionDep, CurrentUser, Trans
1718
from common.utils.utils import deepcopy_ignore_extra
1819
from .table import get_tables_by_ds_id
@@ -402,7 +403,7 @@ def get_table_schema(session: SessionDep, current_user: CurrentUser, ds: CoreDat
402403
all_tables.append(t_obj)
403404

404405
# do table embedding
405-
if embedding and tables:
406+
if embedding and tables and settings.TABLE_EMBEDDING_ENABLED:
406407
tables = get_table_embedding(session, current_user, tables, question)
407408
# splice schema
408409
if tables:

backend/common/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str:
105105
PG_POOL_RECYCLE: int = 3600
106106
PG_POOL_PRE_PING: bool = True
107107

108+
TABLE_EMBEDDING_ENABLED = False
108109
TABLE_EMBEDDING_COUNT: int = 10
109110

110111

0 commit comments

Comments
 (0)