From faf44eca0e5ac0cd588c977f4bfe1ee58daaff37 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 13 Jun 2023 12:49:11 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20refactor(schemas.py):=20add=20op?= =?UTF-8?q?tional=20tweaks=20field=20to=20PredictRequest=20schema=20The=20?= =?UTF-8?q?PredictRequest=20schema=20now=20includes=20an=20optional=20twea?= =?UTF-8?q?ks=20field,=20which=20is=20a=20dictionary=20of=20dictionaries.?= =?UTF-8?q?=20This=20field=20allows=20for=20additional=20customization=20o?= =?UTF-8?q?f=20the=20prediction=20request,=20such=20as=20specifying=20tool?= =?UTF-8?q?=20names=20or=20descriptions.=20The=20tweaks=20field=20is=20opt?= =?UTF-8?q?ional,=20and=20if=20not=20provided,=20the=20default=20value=20i?= =?UTF-8?q?s=20an=20empty=20dictionary.=20The=20schema=5Fextra=20attribute?= =?UTF-8?q?=20has=20also=20been=20updated=20to=20include=20an=20example=20?= =?UTF-8?q?of=20the=20new=20tweaks=20field.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/schemas.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/api/v1/schemas.py b/src/backend/langflow/api/v1/schemas.py index d573a2ae2..aae4a1df3 100644 --- a/src/backend/langflow/api/v1/schemas.py +++ b/src/backend/langflow/api/v1/schemas.py @@ -1,6 +1,6 @@ -from typing import Any, Dict, List, Union +from typing import Any, Dict, List, Optional, Union from langflow.database.models.flow import FlowCreate, FlowRead -from pydantic import BaseModel, validator +from pydantic import BaseModel, Field, validator class GraphData(BaseModel): @@ -23,6 +23,23 @@ class PredictRequest(BaseModel): """Predict request schema.""" message: str + tweaks: Optional[Dict[str, Dict[str, str]]] = Field(default_factory=dict) + + class Config: + schema_extra = { + "example": { + "message": "Hello, how are you?", + "tweaks": { + "dndnode_986363f0-4677-4035-9f38-74b94af5dd78": { + "name": "A tool name", + "description": "A tool description", + }, + "dndnode_986363f0-4677-4035-9f38-74b94af57378": { + "template": "A {template}", + }, + }, + } + } class PredictResponse(BaseModel):