Fix deepcopy the chat model (#17560)

This commit is contained in:
Wang Qi
2026-07-30 14:29:24 +08:00
committed by GitHub
parent 493f605889
commit 4592d06a67
4 changed files with 17 additions and 5 deletions

View File

@@ -86,6 +86,18 @@ class LLMBundle(LLM4Tenant):
"""Release resources held by this LLMBundle instance."""
super().close()
def clone(self):
kwargs = {
"trace_context": dict(self.trace_context or {}),
"langfuse_session_id": self.langfuse_session_id,
"verbose_tool_use": self.verbose_tool_use,
}
for attr, key in (("max_retries", "max_retries"), ("base_delay", "retry_interval"), ("max_rounds", "max_rounds")):
value = getattr(self.mdl, attr, None)
if value is not None:
kwargs[key] = value
return LLMBundle(self.tenant_id, dict(self.model_config), lang=getattr(self, "lang", "Chinese"), **kwargs)
def __enter__(self):
"""Enter context manager."""
return self

View File

@@ -508,6 +508,7 @@ class LLM4Tenant:
self.trace_context = kwargs.pop("trace_context", None) or {}
self.langfuse_session_id = kwargs.pop("langfuse_session_id", None)
self.tenant_id = tenant_id
self.lang = lang
self.llm_name = model_config["llm_name"]
self.model_config = model_config
self.mdl = TenantLLMService.model_instance(model_config, lang=lang, **kwargs)