From fae1ca349f426875b4247e177d6fbaba097dad89 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 21 Jun 2023 14:52:40 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(schemas.py):=20add=20Strea?= =?UTF-8?q?mData=20model=20and=20=5F=5Fstr=5F=5F=20method=20to=20improve?= =?UTF-8?q?=20readability=20of=20stream=20data=20The=20StreamData=20model?= =?UTF-8?q?=20is=20added=20to=20represent=20the=20data=20that=20is=20strea?= =?UTF-8?q?med=20from=20the=20server.=20The=20=5F=5Fstr=5F=5F=20method=20i?= =?UTF-8?q?s=20added=20to=20improve=20the=20readability=20of=20the=20strea?= =?UTF-8?q?m=20data=20by=20returning=20a=20formatted=20string=20that=20inc?= =?UTF-8?q?ludes=20the=20event=20and=20data=20attributes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/schemas.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend/langflow/api/v1/schemas.py b/src/backend/langflow/api/v1/schemas.py index 714f0df7f..fc2e8c69d 100644 --- a/src/backend/langflow/api/v1/schemas.py +++ b/src/backend/langflow/api/v1/schemas.py @@ -1,6 +1,7 @@ from typing import Any, Dict, List, Optional, Union from langflow.database.models.flow import FlowCreate, FlowRead from pydantic import BaseModel, Field, validator +import json class GraphData(BaseModel): @@ -101,3 +102,11 @@ class InitResponse(BaseModel): class BuiltResponse(BaseModel): built: bool + + +class StreamData(BaseModel): + event: str + data: dict + + def __str__(self) -> str: + return f"event: {self.event}\ndata: {json.dumps(self.data)}\n\n"