| from typing import Any, Optional | from typing import Any, Optional | ||||
| from pydantic import BaseModel, Field, model_validator | from pydantic import BaseModel, Field, model_validator | ||||
| from werkzeug.exceptions import NotFound | |||||
| from core.agent.plugin_entities import AgentStrategyProviderEntity | from core.agent.plugin_entities import AgentStrategyProviderEntity | ||||
| from core.model_runtime.entities.provider_entities import ProviderEntity | from core.model_runtime.entities.provider_entities import ProviderEntity | ||||
| return f"{self.organization}/{self.plugin_name}/{self.provider_name}" | return f"{self.organization}/{self.plugin_name}/{self.provider_name}" | ||||
| def __init__(self, value: str, is_hardcoded: bool = False) -> None: | def __init__(self, value: str, is_hardcoded: bool = False) -> None: | ||||
| if not value: | |||||
| raise NotFound("plugin not found, please add plugin") | |||||
| # check if the value is a valid plugin id with format: $organization/$plugin_name/$provider_name | # check if the value is a valid plugin id with format: $organization/$plugin_name/$provider_name | ||||
| if not re.match(r"^[a-z0-9_-]+\/[a-z0-9_-]+\/[a-z0-9_-]+$", value): | if not re.match(r"^[a-z0-9_-]+\/[a-z0-9_-]+\/[a-z0-9_-]+$", value): | ||||
| # check if matches [a-z0-9_-]+, if yes, append with langgenius/$value/$value | # check if matches [a-z0-9_-]+, if yes, append with langgenius/$value/$value |