🔧 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:
parent
22e24226a3
commit
fae1ca349f
1 changed files with 9 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue