From 573e1fe36ea8bcb516316756f9d58a16cf763d91 Mon Sep 17 00:00:00 2001 From: huanghuoguoguo <1051233107@qq.com> Date: Sun, 7 Jun 2026 22:03:25 +0800 Subject: [PATCH] style: simplify wrapped expressions --- src/langbot/pkg/api/http/service/monitoring.py | 12 +++--------- src/langbot/pkg/pipeline/preproc/preproc.py | 6 +----- src/langbot/pkg/provider/runners/localagent.py | 8 ++------ 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/langbot/pkg/api/http/service/monitoring.py b/src/langbot/pkg/api/http/service/monitoring.py index 78761c6a..3e8e0cde 100644 --- a/src/langbot/pkg/api/http/service/monitoring.py +++ b/src/langbot/pkg/api/http/service/monitoring.py @@ -517,12 +517,8 @@ class MonitoringService: sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.total_tokens), 0), sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.duration), 0), sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.cost), 0.0), - sqlalchemy.func.sum( - sqlalchemy.case((LLMCall.status == 'success', 1), else_=0) - ), - sqlalchemy.func.sum( - sqlalchemy.case((LLMCall.status == 'error', 1), else_=0) - ), + sqlalchemy.func.sum(sqlalchemy.case((LLMCall.status == 'success', 1), else_=0)), + sqlalchemy.func.sum(sqlalchemy.case((LLMCall.status == 'error', 1), else_=0)), # Count of successful calls that nonetheless recorded zero tokens — # a data-quality signal that usage reporting may be broken upstream. sqlalchemy.func.sum( @@ -578,9 +574,7 @@ class MonitoringService: sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.total_tokens), 0), sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.duration), 0), sqlalchemy.func.coalesce(sqlalchemy.func.sum(LLMCall.cost), 0.0), - sqlalchemy.func.sum( - sqlalchemy.case((LLMCall.status == 'error', 1), else_=0) - ), + sqlalchemy.func.sum(sqlalchemy.case((LLMCall.status == 'error', 1), else_=0)), ).group_by(LLMCall.model_name) ) by_model_result = await self.ap.persistence_mgr.execute_async(by_model_query) diff --git a/src/langbot/pkg/pipeline/preproc/preproc.py b/src/langbot/pkg/pipeline/preproc/preproc.py index e180b0d2..84e9070c 100644 --- a/src/langbot/pkg/pipeline/preproc/preproc.py +++ b/src/langbot/pkg/pipeline/preproc/preproc.py @@ -159,11 +159,7 @@ class PreProcessor(stage.PipelineStage): # Check if this model supports vision, if not, remove all images # TODO this checking should be performed in runner, and in this stage, the image should be reserved - if ( - selected_runner == 'local-agent' - and llm_model - and 'vision' not in (llm_model.model_entity.abilities or []) - ): + if selected_runner == 'local-agent' and llm_model and 'vision' not in (llm_model.model_entity.abilities or []): for msg in query.messages: if isinstance(msg.content, list): for me in msg.content: diff --git a/src/langbot/pkg/provider/runners/localagent.py b/src/langbot/pkg/provider/runners/localagent.py index 11c56699..b95b77f0 100644 --- a/src/langbot/pkg/provider/runners/localagent.py +++ b/src/langbot/pkg/provider/runners/localagent.py @@ -469,9 +469,7 @@ class LocalAgentRunner(runner.RequestRunner): query, use_llm_model, req_messages, - query.use_funcs - if _model_has_ability(use_llm_model, 'func_call') - else [], + query.use_funcs if _model_has_ability(use_llm_model, 'func_call') else [], extra_args=use_llm_model.model_entity.extra_args, remove_think=remove_think, ) @@ -487,9 +485,7 @@ class LocalAgentRunner(runner.RequestRunner): query, use_llm_model, req_messages, - query.use_funcs - if _model_has_ability(use_llm_model, 'func_call') - else [], + query.use_funcs if _model_has_ability(use_llm_model, 'func_call') else [], extra_args=use_llm_model.model_entity.extra_args, remove_think=remove_think, )