perf: Assistant switch online

This commit is contained in:
fit2cloud-chenyw
2025-07-27 00:56:07 +08:00
parent 5502afcae2
commit 115016c262
6 changed files with 122 additions and 7 deletions
+4 -3
View File
@@ -35,9 +35,10 @@ def get_assistant_ds(llm_service) -> list[dict]:
config: dict[any] = json.loads(configuration)
oid: str = config['oid']
stmt = select(CoreDatasource.id, CoreDatasource.name, CoreDatasource.description).where(CoreDatasource.oid == oid)
private_list:list[int] = config.get('private_list') or None
if private_list:
stmt.where(~CoreDatasource.id.in_(private_list))
if not assistant.online:
private_list:list[int] = config.get('private_list') or None
if private_list:
stmt = stmt.where(~CoreDatasource.id.in_(private_list))
db_ds_list = session.exec(stmt)
result_list = [
+3
View File
@@ -25,6 +25,9 @@ async def get_current_assistant(request: Request) -> AssistantHeader | None:
if request.headers.get("X-SQLBOT-ASSISTANT-CERTIFICATE"):
entry_certificate = request.headers['X-SQLBOT-ASSISTANT-CERTIFICATE']
base_assistant.certificate = unquote(base64.b64decode(entry_certificate).decode('utf-8'))
if request.headers.get("X-SQLBOT-ASSISTANT-ONLINE"):
entry_online = request.headers['X-SQLBOT-ASSISTANT-ONLINE']
base_assistant.online = str(entry_online).lower() == 'true' if entry_online else False
return base_assistant
CurrentAssistant = Annotated[AssistantHeader, Depends(get_current_assistant)]