Skip to content

Commit dd6ed2a

Browse files
committed
style: fix wrapping in async code for improved readability and alignment
1 parent ecbfe00 commit dd6ed2a

8 files changed

Lines changed: 32 additions & 18 deletions

File tree

agents/matmaster_agent/base_agents/job_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,9 @@ async def _run_async_impl(
870870

871871
if not params_check_completed:
872872
# Call ParamsCheckInfoAgent to generate params needing check
873-
async for params_check_info_event in self.params_check_info_agent.run_async(
874-
ctx
875-
):
873+
async for (
874+
params_check_info_event
875+
) in self.params_check_info_agent.run_async(ctx):
876876
yield params_check_info_event
877877
else:
878878
async for submit_event in self.submit_agent.run_async(ctx):

agents/matmaster_agent/callback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ async def matmaster_check_job_status(
149149
llm_response.content = None
150150
break
151151
if not reset:
152-
callback_context.state[
153-
'special_llm_response'
154-
] = True # 标记开始处理原来消息的非流式版本
152+
callback_context.state['special_llm_response'] = (
153+
True # 标记开始处理原来消息的非流式版本
154+
)
155155
llm_response.content.parts = []
156156
reset = True
157157
function_call_id = f"call_{str(uuid.uuid4()).replace('-', '')[:24]}"

agents/matmaster_agent/chembrain_agent/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ async def _run_async_impl(
147147
and event.content.parts
148148
and event.content.parts[0].function_response
149149
):
150-
logger.info(f"{event.content.parts[0].function_response.name} 调用结束")
150+
logger.info(
151+
f"{event.content.parts[0].function_response.name} 调用结束"
152+
)
151153
yield Event(
152154
author=self.name,
153155
actions=EventActions(

agents/matmaster_agent/chembrain_agent/smiles_conversion_agent/callback.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ async def smiles_conversion_after_tool(
2626
'after': {
2727
'tool_name': tool.name,
2828
'tool_args': args,
29-
'tool_response': tool_response.content[0].text
30-
if (tool_response and len(tool_response.content))
31-
else None,
29+
'tool_response': (
30+
tool_response.content[0].text
31+
if (tool_response and len(tool_response.content))
32+
else None
33+
),
3234
}
3335
}
3436

agents/matmaster_agent/ssebrain_agent/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ async def _run_async_impl(
144144
and event.content.parts
145145
and event.content.parts[0].function_response
146146
):
147-
logger.info(f"{event.content.parts[0].function_response.name} 调用结束")
147+
logger.info(
148+
f"{event.content.parts[0].function_response.name} 调用结束"
149+
)
148150
yield Event(
149151
author=self.name,
150152
actions=EventActions(

agents/matmaster_agent/ssebrain_agent/callback.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ async def ssebrain_before_agent(
5454
callback_context.state['current_time'] = datetime.now().strftime(
5555
'%Y-%m-%d %H:%M:%S'
5656
)
57-
callback_context.state['db_name'] = 'solid_state_electrolyte_db' # 使用默认数据库
57+
callback_context.state['db_name'] = (
58+
'solid_state_electrolyte_db' # 使用默认数据库
59+
)
5860
db_manager = DatabaseManager('solid_state_electrolyte_db')
5961
await db_manager.async_init() # Call the async init method
6062
callback_context.state['available_tables'] = db_manager.table_schema

agents/matmaster_agent/utils/helper_func.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ async def update_session_state(ctx: InvocationContext, author: str):
3434
author=f"{filename}:{lineno}",
3535
actions=actions_with_update,
3636
)
37-
await ctx.session_service.append_event(ctx.session, system_event) # 会引入一个空消息
37+
await ctx.session_service.append_event(
38+
ctx.session, system_event
39+
) # 会引入一个空消息
3840

3941

4042
def update_llm_response(
@@ -339,7 +341,9 @@ def get_new_function_call_indices(
339341

340342
def check_None_wrapper(func):
341343
def wrapper(*args, **kwargs):
342-
result = func(*args, **kwargs) # 注意这里应该是 *args, **kwargs 而不是 args, kwargs
344+
result = func(
345+
*args, **kwargs
346+
) # 注意这里应该是 *args, **kwargs 而不是 args, kwargs
343347
if result is None:
344348
raise ValueError(
345349
f"'{func.__name__.replace('_get_', '')}' was not found, please provide it!"

evaluate/base/human_simulator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ def _generate_user_response(self, agent_message: str) -> Tuple[str, bool]:
115115
user_response = result.get('response', '我理解了。')
116116
should_continue = result.get('continue', True)
117117

118-
logger.info(f"用户响应生成 - 轮次: {self.turn_count}, 继续: {should_continue}")
118+
logger.info(
119+
f"用户响应生成 - 轮次: {self.turn_count}, 继续: {should_continue}"
120+
)
119121

120122
return user_response, should_continue
121123

@@ -199,9 +201,9 @@ def get_conversation_summary(self) -> Dict[str, Any]:
199201
'goal': self.goal.initial_question if self.goal else None,
200202
'total_turns': self.turn_count,
201203
'final_state': self.current_state.value,
202-
'duration_minutes': ((time.time() - self.start_time) / 60)
203-
if self.start_time
204-
else 0,
204+
'duration_minutes': (
205+
((time.time() - self.start_time) / 60) if self.start_time else 0
206+
),
205207
'conversation_history': self.conversation_history,
206208
}
207209

0 commit comments

Comments
 (0)