Yeuoly 9 місяців тому
батько
коміт
87c746f6bb
1 змінених файлів з 9 додано та 0 видалено
  1. 9 0
      api/core/tools/entities/tool_entities.py

+ 9 - 0
api/core/tools/entities/tool_entities.py

@@ -120,6 +120,15 @@ class ToolInvokeMessage(BaseModel):
                     raise ValueError("When 'stream' is True, 'variable_value' must be a string.")
 
             return value
+        
+        @field_validator("variable_name", mode="before")
+        def transform_variable_name(cls, value) -> str:
+            """
+            The variable name must be a string.
+            """
+            if value in ["json", "text", "files"]:
+                raise ValueError(f"The variable name '{value}' is reserved.")
+            return value
 
     class MessageType(Enum):
         TEXT = "text"