Skip to content

Commit

Permalink
Merge branch 'fix/chore-fix' into dev/plugin-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Dec 27, 2024
2 parents 4fb5cf6 + 83fdb42 commit 7122bf3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/core/tools/entities/tool_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from enum import Enum
from typing import Any, Optional, Union

from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_serializer, field_validator
from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_serializer, field_validator, model_validator

from core.entities.provider_entities import ProviderConfig
from core.plugin.entities.parameters import (
Expand Down Expand Up @@ -128,12 +128,13 @@ class VariableMessage(BaseModel):
variable_value: str = Field(..., description="The value of the variable")
stream: bool = Field(default=False, description="Whether the variable is streamed")

@field_validator("variable_value", mode="before")
@model_validator(mode="before")
@classmethod
def transform_variable_value(cls, value, values) -> Any:
def transform_variable_value(cls, values) -> Any:
"""
Only basic types and lists are allowed.
"""
value = values.get("variable_value")
if not isinstance(value, dict | list | str | int | float | bool):
raise ValueError("Only basic types and lists are allowed.")

Expand All @@ -142,7 +143,7 @@ def transform_variable_value(cls, value, values) -> Any:
if not isinstance(value, str):
raise ValueError("When 'stream' is True, 'variable_value' must be a string.")

return value
return values

@field_validator("variable_name", mode="before")
@classmethod
Expand Down

0 comments on commit 7122bf3

Please sign in to comment.