mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
fix: pydantic
This commit is contained in:
parent
4eaba3049a
commit
c472ea6c67
|
@ -42,7 +42,8 @@ class RequestInvokeLLM(BaseRequestInvokeModel):
|
|||
stream: Optional[bool] = False
|
||||
|
||||
@field_validator("prompt_messages", mode="before")
|
||||
def convert_prompt_messages(self, v):
|
||||
@classmethod
|
||||
def convert_prompt_messages(cls, v):
|
||||
if not isinstance(v, list):
|
||||
raise ValueError("prompt_messages must be a list")
|
||||
|
||||
|
|
|
@ -114,7 +114,8 @@ class ToolInvokeMessage(BaseModel):
|
|||
stream: bool = Field(default=False, description="Whether the variable is streamed")
|
||||
|
||||
@field_validator("variable_value", mode="before")
|
||||
def transform_variable_value(self, value, values) -> Any:
|
||||
@classmethod
|
||||
def transform_variable_value(cls, value, values) -> Any:
|
||||
"""
|
||||
Only basic types and lists are allowed.
|
||||
"""
|
||||
|
@ -129,7 +130,8 @@ class ToolInvokeMessage(BaseModel):
|
|||
return value
|
||||
|
||||
@field_validator("variable_name", mode="before")
|
||||
def transform_variable_name(self, value) -> str:
|
||||
@classmethod
|
||||
def transform_variable_name(cls, value) -> str:
|
||||
"""
|
||||
The variable name must be a string.
|
||||
"""
|
||||
|
|
|
@ -245,9 +245,8 @@ class ToolEngine:
|
|||
+ "you do not need to create it, just tell the user to check it now."
|
||||
)
|
||||
elif response.type == ToolInvokeMessage.MessageType.JSON:
|
||||
result += f"tool response: {
|
||||
json.dumps(cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False)
|
||||
}."
|
||||
text = json.dumps(cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False)
|
||||
result += f"tool response: {text}."
|
||||
else:
|
||||
result += f"tool response: {response.message}."
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user