File tree Expand file tree Collapse file tree
src/agentscope_runtime/engine Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22# pylint:disable=too-many-nested-blocks, too-many-branches, too-many-statements
33# pylint:disable=line-too-long, protected-access
4+ import inspect
45import copy
56import logging
67import json
@@ -250,7 +251,12 @@ async def run_async(
250251 # We should always build a new agent since the state is manage outside
251252 # the agent
252253 if self ._attr .get ("custom_build_fn" ):
253- _agent = self ._attr ["custom_build_fn" ](as_context , ** kwargs )
254+ build_fn = self ._attr ["custom_build_fn" ]
255+
256+ if inspect .iscoroutinefunction (build_fn ):
257+ _agent = await build_fn (as_context , ** kwargs )
258+ else :
259+ _agent = build_fn (as_context , ** kwargs )
254260 else :
255261 _agent = self .build (as_context )
256262
Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22# pylint:disable=too-many-nested-blocks, too-many-branches, too-many-statements
3+ import inspect
34import json
45from typing import Optional , Type , Callable
56
@@ -164,7 +165,12 @@ async def run_async(
164165 # We should always build a new agent since the state is manage outside
165166 # the agent
166167 if self ._attr .get ("custom_build_fn" ):
167- _agent = self ._attr ["custom_build_fn" ](ag_context , ** kwargs )
168+ build_fn = self ._attr ["custom_build_fn" ]
169+
170+ if inspect .iscoroutinefunction (build_fn ):
171+ _agent = await build_fn (ag_context , ** kwargs )
172+ else :
173+ _agent = build_fn (ag_context , ** kwargs )
168174 else :
169175 _agent = self .build (ag_context )
170176
Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
2+ import inspect
23from typing import Optional , Type , Callable
34
45from autogen_core .models import ChatCompletionClient
@@ -169,7 +170,12 @@ async def run_async(
169170 # We should always build a new agent since the state is manage outside
170171 # the agent
171172 if self ._attr .get ("custom_build_fn" ):
172- _agent = self ._attr ["custom_build_fn" ](ag_context , ** kwargs )
173+ build_fn = self ._attr ["custom_build_fn" ]
174+
175+ if inspect .iscoroutinefunction (build_fn ):
176+ _agent = await build_fn (ag_context , ** kwargs )
177+ else :
178+ _agent = build_fn (ag_context , ** kwargs )
173179 else :
174180 _agent = self .build (ag_context )
175181
Original file line number Diff line number Diff line change 77from .modelstudio_deployer import (
88 ModelstudioDeployManager ,
99)
10- from .agentrun_deployer import (
11- AgentRunDeployManager ,
12- )
10+
11+ try :
12+ from .agentrun_deployer import (
13+ AgentRunDeployManager ,
14+ )
15+ except ImportError :
16+ AgentRunDeployManager = None # type: ignore
1317
1418__all__ = [
1519 "DeployManager" ,
You can’t perform that action at this time.
0 commit comments