Feat/model as tool (#2744)

This commit is contained in:
Yeuoly
2024-03-08 15:22:55 +08:00
committed by GitHub
parent 3231a8c51c
commit 40c646cf7a
26 changed files with 840 additions and 43 deletions

View File

@@ -8,15 +8,19 @@ class I18nObject(BaseModel):
Model class for i18n object.
"""
zh_Hans: Optional[str] = None
pt_BR: Optional[str] = None
en_US: str
def __init__(self, **data):
super().__init__(**data)
if not self.zh_Hans:
self.zh_Hans = self.en_US
if not self.pt_BR:
self.pt_BR = self.en_US
def to_dict(self) -> dict:
return {
'zh_Hans': self.zh_Hans,
'en_US': self.en_US,
}
'pt_BR': self.pt_BR
}

View File

@@ -304,4 +304,24 @@ class ToolRuntimeVariablePool(BaseModel):
value=value,
)
self.pool.append(variable)
self.pool.append(variable)
class ModelToolPropertyKey(Enum):
IMAGE_PARAMETER_NAME = "image_parameter_name"
class ModelToolConfiguration(BaseModel):
"""
Model tool configuration
"""
type: str = Field(..., description="The type of the model tool")
model: str = Field(..., description="The model")
label: I18nObject = Field(..., description="The label of the model tool")
properties: dict[ModelToolPropertyKey, Any] = Field(..., description="The properties of the model tool")
class ModelToolProviderConfiguration(BaseModel):
"""
Model tool provider configuration
"""
provider: str = Field(..., description="The provider of the model tool")
models: list[ModelToolConfiguration] = Field(..., description="The models of the model tool")
label: I18nObject = Field(..., description="The label of the model tool")

View File

@@ -13,6 +13,7 @@ class UserToolProvider(BaseModel):
BUILTIN = "builtin"
APP = "app"
API = "api"
MODEL = "model"
id: str
author: str