Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: azure customize model name duplicate (#2073)

takatost1d91535ba645
diff --git a/api/core/model_runtime/model_providers/azure_openai/llm/llm.py b/api/core/model_runtime/model_providers/azure_openai/llm/llm.py
index 55f0a9408fd..c1a5e23bc2c 100644
--- a/api/core/model_runtime/model_providers/azure_openai/llm/llm.py
+++ b/api/core/model_runtime/model_providers/azure_openai/llm/llm.py
@@ -1,3 +1,4 @@
+import copy
import logging
from typing import Generator, List, Optional, Union, cast
@@ -625,9 +626,10 @@ class AzureOpenAILargeLanguageModel(_CommonAzureOpenAI, LargeLanguageModel):
def _get_ai_model_entity(base_model_name: str, model: str) -> AzureBaseModel:
for ai_model_entity in LLM_BASE_MODELS:
if ai_model_entity.base_model_name == base_model_name:
- ai_model_entity.entity.model = model
- ai_model_entity.entity.label.en_US = model
- ai_model_entity.entity.label.zh_Hans = model
- return ai_model_entity
+ ai_model_entity_copy = copy.deepcopy(ai_model_entity)
+ ai_model_entity_copy.entity.model = model
+ ai_model_entity_copy.entity.label.en_US = model
+ ai_model_entity_copy.entity.label.zh_Hans = model
+ return ai_model_entity_copy
return None
diff --git a/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py
index 06897a6c450..227cd64fbad 100644
--- a/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py
+++ b/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py
@@ -1,4 +1,5 @@
import base64
+import copy
import time
from typing import Optional, Tuple
@@ -186,9 +187,10 @@ class AzureOpenAITextEmbeddingModel(_CommonAzureOpenAI, TextEmbeddingModel):
def _get_ai_model_entity(base_model_name: str, model: str) -> AzureBaseModel:
for ai_model_entity in EMBEDDING_BASE_MODELS:
if ai_model_entity.base_model_name == base_model_name:
- ai_model_entity.entity.model = model
- ai_model_entity.entity.label.en_US = model
- ai_model_entity.entity.label.zh_Hans = model
- return ai_model_entity
+ ai_model_entity_copy = copy.deepcopy(ai_model_entity)
+ ai_model_entity_copy.entity.model = model
+ ai_model_entity_copy.entity.label.en_US = model
+ ai_model_entity_copy.entity.label.zh_Hans = model
+ return ai_model_entity_copy
return None