mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 21:37:33 +08:00
Fix deepcopy the chat model (#17560)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user