Skip to content

Commit 1169f82

Browse files
perf: Assistant model warn
1 parent 25debfb commit 1169f82

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

backend/apps/system/crud/assistant.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_simple_ds_list(self):
131131
def get_db_schema(self, ds_id: int) -> str:
132132
ds = self.get_ds(ds_id)
133133
schema_str = ""
134-
db_name = ds.schema
134+
db_name = ds.db_schema
135135
schema_str += f"【DB_ID】 {db_name}\n【Schema】\n"
136136
for table in ds.tables:
137137
schema_str += f"# Table: {db_name}.{table.name}"
@@ -159,7 +159,9 @@ def convert2schema(self, ds_dict: dict) -> AssistantOutDsSchema:
159159
if attr in ds_dict:
160160
id_marker += str(ds_dict.get(attr, '')) + '--sqlbot--'
161161
id = string_to_numeric_hash(id_marker)
162-
return AssistantOutDsSchema(**{**ds_dict, "id": id})
162+
db_schema = ds_dict.get('schema', ds_dict.get('db_schema', ''))
163+
ds_dict.pop("schema", None)
164+
return AssistantOutDsSchema(**{**ds_dict, "id": id, "db_schema": db_schema})
163165

164166
class AssistantOutDsFactory:
165167
@staticmethod
@@ -177,12 +179,12 @@ def get_ds_engine(ds: AssistantOutDsSchema) -> Engine:
177179
database=ds.dataBase,
178180
driver='',
179181
extraJdbc=ds.extraParams,
180-
dbSchema=ds.schema or ''
182+
dbSchema=ds.db_schema or ''
181183
)
182184
from apps.db.db import get_uri_from_config
183185
uri = get_uri_from_config(ds.type, conf)
184-
if ds.type == "pg" and ds.schema:
185-
connect_args.update({"options": f"-c search_path={ds.schema}"})
186+
if ds.type == "pg" and ds.db_schema:
187+
connect_args.update({"options": f"-c search_path={ds.db_schema}"})
186188
engine = create_engine(uri, connect_args=connect_args, pool_timeout=timeout, pool_size=20, max_overflow=10)
187189
return engine
188190

backend/apps/system/schemas/system_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class AssistantOutDsSchema(AssistantOutDsBase):
139139
dataBase: Optional[str] = None
140140
user: Optional[str] = None
141141
password: Optional[str] = None
142-
schema: Optional[str] = None
142+
db_schema: Optional[str] = None
143143
extraParams: Optional[str] = None
144144
tables: Optional[list[AssistantTableSchema]] = None
145145

0 commit comments

Comments
 (0)