diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 6e1a59bd4..0fedfc130 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -29,4 +29,4 @@ jobs: pip install -U black isort - name: check the code lint run: | - black . + black . --check diff --git a/pilot/common/plugins.py b/pilot/common/plugins.py index 50ec56606..3ee5f4ac2 100644 --- a/pilot/common/plugins.py +++ b/pilot/common/plugins.py @@ -131,7 +131,6 @@ def scan_plugins(cfg: Config, debug: bool = False) -> List[AutoGPTPluginTemplate # Generic plugins plugins_path_path = Path(PLUGINS_DIR) - for plugin in plugins_path_path.glob("*.zip"): if moduleList := inspect_zip_for_modules(str(plugin), debug): for module in moduleList: diff --git a/pilot/connections/db_conn_info.py b/pilot/connections/db_conn_info.py index e1c633979..6430d0552 100644 --- a/pilot/connections/db_conn_info.py +++ b/pilot/connections/db_conn_info.py @@ -11,7 +11,7 @@ class DBConfig(BaseModel): db_pwd: str = "" comment: str = "" -class DbTypeInfo(BaseModel): - db_type:str - is_file_db: bool = False +class DbTypeInfo(BaseModel): + db_type: str + is_file_db: bool = False diff --git a/pilot/connections/manages/connect_storage_duckdb.py b/pilot/connections/manages/connect_storage_duckdb.py index 29542f6d5..acacaffd7 100644 --- a/pilot/connections/manages/connect_storage_duckdb.py +++ b/pilot/connections/manages/connect_storage_duckdb.py @@ -47,7 +47,8 @@ class DuckdbConnectConfig: except Exception as e: print("add db connect info error1!" + str(e)) - def update_db_info(self, + def update_db_info( + self, db_name, db_type, db_path: str = "", @@ -55,15 +56,20 @@ class DuckdbConnectConfig: db_port: int = 0, db_user: str = "", db_pwd: str = "", - comment: str = "" ): + comment: str = "", + ): old_db_conf = self.get_db_config(db_name) if old_db_conf: try: cursor = self.connect.cursor() if not db_path: - cursor.execute(f"UPDATE connect_config set db_type='{db_type}', db_host='{db_host}', db_port={db_port}, db_user='{db_user}', db_pwd='{db_pwd}', comment='{comment}' where db_name='{db_name}'") + cursor.execute( + f"UPDATE connect_config set db_type='{db_type}', db_host='{db_host}', db_port={db_port}, db_user='{db_user}', db_pwd='{db_pwd}', comment='{comment}' where db_name='{db_name}'" + ) else: - cursor.execute(f"UPDATE connect_config set db_type='{db_type}', db_path='{db_path}', comment='{comment}' where db_name='{db_name}'") + cursor.execute( + f"UPDATE connect_config set db_type='{db_type}', db_path='{db_path}', comment='{comment}' where db_name='{db_name}'" + ) cursor.commit() self.connect.commit() except Exception as e: @@ -79,7 +85,6 @@ class DuckdbConnectConfig: except Exception as e: raise "Unusable duckdb database path:" + path - def add_file_db(self, db_name, db_type, db_path: str, comment: str = ""): try: cursor = self.connect.cursor() diff --git a/pilot/connections/manages/connection_manager.py b/pilot/connections/manages/connection_manager.py index 2c94082e7..38d7dd9f0 100644 --- a/pilot/connections/manages/connection_manager.py +++ b/pilot/connections/manages/connection_manager.py @@ -122,14 +122,16 @@ class ConnectManager: return self.storage.delete_db(db_name) def edit_db(self, db_info: DBConfig): - return self.storage.update_db_info(db_info.db_name, - db_info.db_type, - db_info.file_path, - db_info.db_host, - db_info.db_port, - db_info.db_user, - db_info.db_pwd, - db_info.comment) + return self.storage.update_db_info( + db_info.db_name, + db_info.db_type, + db_info.file_path, + db_info.db_host, + db_info.db_port, + db_info.db_user, + db_info.db_pwd, + db_info.comment, + ) def add_db(self, db_info: DBConfig): print(f"add_db:{db_info.__dict__}") @@ -140,7 +142,6 @@ class ConnectManager: db_info.db_name, db_info.db_type, db_info.file_path ) else: - self.storage.add_url_db( db_info.db_name, db_info.db_type, @@ -151,7 +152,11 @@ class ConnectManager: db_info.comment, ) # async embedding - thread = threading.Thread(target=self.db_summary_client.db_summary_embedding(db_info.db_name, db_info.db_type)) + thread = threading.Thread( + target=self.db_summary_client.db_summary_embedding( + db_info.db_name, db_info.db_type + ) + ) thread.start() except Exception as e: raise ValueError("Add db connect info error!" + str(e)) diff --git a/pilot/connections/rdbms/conn_duckdb.py b/pilot/connections/rdbms/conn_duckdb.py index 928d3e7c0..668ee9cf6 100644 --- a/pilot/connections/rdbms/conn_duckdb.py +++ b/pilot/connections/rdbms/conn_duckdb.py @@ -30,7 +30,11 @@ class DuckDbConnect(RDBMSDatabase): return cls(create_engine("duckdb:///" + file_path, **_engine_args), **kwargs) def get_users(self): - cursor = self.session.execute(text(f"SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'duckdb_sys_users';")) + cursor = self.session.execute( + text( + f"SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'duckdb_sys_users';" + ) + ) users = cursor.fetchall() return [(user[0], user[1]) for user in users] @@ -40,6 +44,7 @@ class DuckDbConnect(RDBMSDatabase): def get_collation(self): """Get collation.""" return "UTF-8" + def get_charset(self): return "UTF-8" diff --git a/pilot/openapi/api_v1/api_v1.py b/pilot/openapi/api_v1/api_v1.py index 7c483e2e9..aa63df27f 100644 --- a/pilot/openapi/api_v1/api_v1.py +++ b/pilot/openapi/api_v1/api_v1.py @@ -121,7 +121,9 @@ async def db_support_types(): support_types = [DBType.Mysql, DBType.MSSQL, DBType.DuckDb] db_type_infos = [] for type in support_types: - db_type_infos.append(DbTypeInfo(db_type=type.value(), is_file_db=type.is_file_db())) + db_type_infos.append( + DbTypeInfo(db_type=type.value(), is_file_db=type.is_file_db()) + ) return Result[DbTypeInfo].succ(db_type_infos) @@ -169,7 +171,7 @@ async def dialogue_scenes(): @router.post("/v1/chat/dialogue/new", response_model=Result[ConversationVo]) async def dialogue_new( - chat_mode: str = ChatScene.ChatNormal.value(), user_id: str = None + chat_mode: str = ChatScene.ChatNormal.value(), user_id: str = None ): conv_vo = __new_conversation(chat_mode, user_id) return Result.succ(conv_vo) diff --git a/pilot/server/dbgpt_server.py b/pilot/server/dbgpt_server.py index 045e0981c..f061635a3 100644 --- a/pilot/server/dbgpt_server.py +++ b/pilot/server/dbgpt_server.py @@ -5,10 +5,12 @@ import shutil import argparse import sys import logging + ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(ROOT_PATH) import signal from pilot.configs.config import Config + # from pilot.configs.model_config import ( # DATASETS_DIR, # KNOWLEDGE_UPLOAD_ROOT_PATH, diff --git a/pilot/server/webserver_base.py b/pilot/server/webserver_base.py index 1d39d7bfa..279bc5209 100644 --- a/pilot/server/webserver_base.py +++ b/pilot/server/webserver_base.py @@ -7,6 +7,7 @@ import sys from pilot.summary.db_summary_client import DBSummaryClient from pilot.commands.command_mange import CommandRegistry from pilot.configs.config import Config + # from pilot.configs.model_config import ( # DATASETS_DIR, # KNOWLEDGE_UPLOAD_ROOT_PATH, diff --git a/pilot/summary/db_summary_client.py b/pilot/summary/db_summary_client.py index 2aa1b11db..fc8a874e5 100644 --- a/pilot/summary/db_summary_client.py +++ b/pilot/summary/db_summary_client.py @@ -58,8 +58,8 @@ class DBSummaryClient: ) embedding.source_embedding() for ( - table_name, - table_summary, + table_name, + table_summary, ) in db_summary_client.get_table_summary().items(): table_vector_store_config = { "vector_store_name": dbname + "_" + table_name + "_ts", diff --git a/pilot/summary/rdbms_db_summary.py b/pilot/summary/rdbms_db_summary.py index 8a3b77506..25a4b23c3 100644 --- a/pilot/summary/rdbms_db_summary.py +++ b/pilot/summary/rdbms_db_summary.py @@ -5,12 +5,13 @@ from pilot.summary.db_summary import DBSummary, TableSummary, FieldSummary, Inde CFG = Config() + class RdbmsSummary(DBSummary): """Get mysql summary template.""" def __init__(self, name, type): self.name = name - self.type = type + self.type = type self.summery = """{{"database_name": "{name}", "type": "{type}", "tables": "{tables}", "qps": "{qps}", "tps": {tps}}}""" self.tables = {} self.tables_info = [] @@ -177,4 +178,3 @@ class RdbmsIndexSummary(IndexSummary): return self.summery_template.format( name=self.name, bind_fields=self.bind_fields ) -