浏览代码

raising error if plugin not initialized (#15319)

tags/1.0.1
znn 7 个月前
父节点
当前提交
f8ac382072
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3
    0
      api/core/plugin/entities/plugin.py

+ 3
- 0
api/core/plugin/entities/plugin.py 查看文件

@@ -5,6 +5,7 @@ from collections.abc import Mapping
from typing import Any, Optional

from pydantic import BaseModel, Field, model_validator
from werkzeug.exceptions import NotFound

from core.agent.plugin_entities import AgentStrategyProviderEntity
from core.model_runtime.entities.provider_entities import ProviderEntity
@@ -153,6 +154,8 @@ class GenericProviderID:
return f"{self.organization}/{self.plugin_name}/{self.provider_name}"

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
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

正在加载...
取消
保存