Skip to content

Commit

Permalink
fix: deep copy of model-tool label (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly authored Mar 11, 2024
1 parent 3c91f9b commit 53cd125
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions api/core/tools/provider/model_tool_provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import deepcopy
from typing import Any

from core.entities.model_entities import ModelStatus
Expand Down Expand Up @@ -59,23 +60,29 @@ def from_db(configuration: ProviderConfiguration = None) -> 'ModelToolProviderCo

# override the configuration
if model_tool_configuration.label:
if model_tool_configuration.label.en_US:
configuration.provider.label.en_US = model_tool_configuration.label.en_US
if model_tool_configuration.label.zh_Hans:
configuration.provider.label.zh_Hans = model_tool_configuration.label.zh_Hans
label = deepcopy(model_tool_configuration.label)
if label.en_US:
label.en_US = model_tool_configuration.label.en_US
if label.zh_Hans:
label.zh_Hans = model_tool_configuration.label.zh_Hans
else:
label = I18nObject(
en_US=configuration.provider.label.en_US,
zh_Hans=configuration.provider.label.zh_Hans
)

return ModelToolProviderController(
is_active=is_active,
identity=ToolProviderIdentity(
author='Dify',
name=configuration.provider.provider,
description=I18nObject(
zh_Hans=f'{configuration.provider.label.zh_Hans} 模型能力提供商',
en_US=f'{configuration.provider.label.en_US} model capability provider'
zh_Hans=f'{label.zh_Hans} 模型能力提供商',
en_US=f'{label.en_US} model capability provider'
),
label=I18nObject(
zh_Hans=configuration.provider.label.zh_Hans,
en_US=configuration.provider.label.en_US
zh_Hans=label.zh_Hans,
en_US=label.en_US
),
icon=configuration.provider.icon_small.en_US,
),
Expand Down

0 comments on commit 53cd125

Please sign in to comment.