@@ -53,6 +53,8 @@ class AgentRuntime(
5353 delete, update, query, and endpoint/version management.
5454 """
5555
56+ _data_api : Dict [str , AgentRuntimeDataAPI ] = {}
57+
5658 @classmethod
5759 def __get_client (cls ):
5860 """获取客户端实例 / Get client instance
@@ -867,17 +869,20 @@ async def invoke_openai_async(
867869 cfg = Config .with_configs (self ._config , kwargs .get ("config" ))
868870 kwargs ["config" ] = cfg
869871
870- if not self .__data_api :
871- self .__data_api : Dict [str , AgentRuntimeDataAPI ] = {}
872+ if not self ._data_api :
873+ self ._data_api : Dict [str , AgentRuntimeDataAPI ] = {}
872874
873- if self .__data_api [agent_runtime_endpoint_name ] is None :
874- self .__data_api [agent_runtime_endpoint_name ] = AgentRuntimeDataAPI (
875+ if (
876+ agent_runtime_endpoint_name in self ._data_api
877+ and self ._data_api [agent_runtime_endpoint_name ] is None
878+ ):
879+ self ._data_api [agent_runtime_endpoint_name ] = AgentRuntimeDataAPI (
875880 agent_runtime_name = self .agent_runtime_name or "" ,
876881 agent_runtime_endpoint_name = agent_runtime_endpoint_name or "" ,
877882 config = cfg ,
878883 )
879884
880- return await self .__data_api [
885+ return await self ._data_api [
881886 agent_runtime_endpoint_name
882887 ].invoke_openai_async (** kwargs )
883888
@@ -889,16 +894,19 @@ def invoke_openai(
889894 cfg = Config .with_configs (self ._config , kwargs .get ("config" ))
890895 kwargs ["config" ] = cfg
891896
892- if not self .__data_api :
893- self .__data_api : Dict [str , AgentRuntimeDataAPI ] = {}
897+ if not self ._data_api :
898+ self ._data_api : Dict [str , AgentRuntimeDataAPI ] = {}
894899
895- if self .__data_api [agent_runtime_endpoint_name ] is None :
896- self .__data_api [agent_runtime_endpoint_name ] = AgentRuntimeDataAPI (
900+ if (
901+ agent_runtime_endpoint_name not in self ._data_api
902+ or self ._data_api [agent_runtime_endpoint_name ] is None
903+ ):
904+ self ._data_api [agent_runtime_endpoint_name ] = AgentRuntimeDataAPI (
897905 agent_runtime_name = self .agent_runtime_name or "" ,
898906 agent_runtime_endpoint_name = agent_runtime_endpoint_name or "" ,
899907 config = cfg ,
900908 )
901909
902- return self .__data_api [agent_runtime_endpoint_name ].invoke_openai (
910+ return self ._data_api [agent_runtime_endpoint_name ].invoke_openai (
903911 ** kwargs
904912 )
0 commit comments