🔧 chore(schemas.py): add StreamData model and __str__ method to improve readability of stream data

The StreamData model is added to represent the data that is streamed from the server. The __str__ method is added to improve the readability of the stream data by returning a formatted string that includes the event and data attributes.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-21 14:52:40 -03:00
commit fae1ca349f

View file

@ -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"