refactor(services/tasks): Swtich to dify_config witch Pydantic (#6203)

This commit is contained in:
Waffle 2024-07-12 12:25:38 +08:00 • committed by GitHub
commit 7b225a5ab0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 51 additions and 53 deletions

View file

@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional
from flask import current_app
from pydantic import BaseModel, ConfigDict
from configs import dify_config
from core.entities.model_entities import ModelWithProviderEntity, ProviderModelWithStatusEntity
from core.entities.provider_entities import QuotaConfiguration
from core.model_runtime.entities.common_entities import I18nObject
@ -67,7 +67,7 @@ class ProviderResponse(BaseModel):
def __init__(self, **data) -> None:
super().__init__(**data)
url_prefix = (current_app.config.get("CONSOLE_API_URL")
url_prefix = (dify_config.CONSOLE_API_URL
+ f"/console/api/workspaces/current/model-providers/{self.provider}")
if self.icon_small is not None:
self.icon_small = I18nObject(
@ -96,7 +96,7 @@ class ProviderWithModelsResponse(BaseModel):
def __init__(self, **data) -> None:
super().__init__(**data)
url_prefix = (current_app.config.get("CONSOLE_API_URL")
url_prefix = (dify_config.CONSOLE_API_URL
+ f"/console/api/workspaces/current/model-providers/{self.provider}")
if self.icon_small is not None:
self.icon_small = I18nObject(
@ -119,7 +119,7 @@ class SimpleProviderEntityResponse(SimpleProviderEntity):
def __init__(self, **data) -> None:
super().__init__(**data)
url_prefix = (current_app.config.get("CONSOLE_API_URL")
url_prefix = (dify_config.CONSOLE_API_URL
+ f"/console/api/workspaces/current/model-providers/{self.provider}")
if self.icon_small is not None:
self.icon_small = I18nObject(