🚀 feat(flow.py): add relationship to FlowStyle model
🚀 feat(flowstyle.py): add FlowStyle model 🚀 feat(flowstyle.py): add FlowStyleCreate and FlowStyleRead models 🐛 fix(settings.py): correct typo in database_url variable name The Flow model now has a relationship to the FlowStyle model, which allows for the creation of a FlowStyle object that is associated with a Flow object. The FlowStyle model is a new model that contains the color and emoji fields, which are used to style the Flow object. The FlowStyleCreate and FlowStyleRead models are used to create and read FlowStyle objects respectively. The typo in the database_url variable name has been corrected to ensure that the application connects to the correct database.
This commit is contained in:
parent
fbfcff74c2
commit
42c7e1c331
3 changed files with 32 additions and 2 deletions
|
|
@ -1,10 +1,15 @@
|
|||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel import Field, SQLModel, Relationship
|
||||
from uuid import UUID, uuid4
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langflow.database.models.flowstyle import FlowStyle
|
||||
|
||||
|
||||
class FlowBase(SQLModel):
|
||||
name: str = Field(index=True)
|
||||
flow: str = Field(index=False)
|
||||
style: "FlowStyle" = Relationship(back_populates="flow")
|
||||
|
||||
|
||||
class Flow(FlowBase, table=True):
|
||||
|
|
|
|||
25
src/backend/langflow/database/models/flowstyle.py
Normal file
25
src/backend/langflow/database/models/flowstyle.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from sqlmodel import Field, SQLModel, Relationship
|
||||
from uuid import UUID, uuid4
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langflow.database.models.flow import Flow
|
||||
|
||||
|
||||
class FlowStyleBase(SQLModel):
|
||||
color: str = Field(index=True)
|
||||
emoji: str = Field(index=False)
|
||||
flow_id: UUID = Field(default_factory=uuid4, foreign_key="flow.id")
|
||||
flow: "Flow" = Relationship(back_populates="style")
|
||||
|
||||
|
||||
class FlowStyle(FlowStyleBase, table=True):
|
||||
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
||||
|
||||
|
||||
class FlowStyleCreate(FlowStyleBase):
|
||||
pass
|
||||
|
||||
|
||||
class FlowStyleRead(FlowStyleBase):
|
||||
id: UUID
|
||||
|
|
@ -20,7 +20,7 @@ class Settings(BaseSettings):
|
|||
textsplitters: List[str] = []
|
||||
utilities: List[str] = []
|
||||
dev: bool = False
|
||||
dabatabase_url: str = "sqlite:///./langflow.db"
|
||||
database_url: str = "sqlite:///./langflow.db"
|
||||
|
||||
class Config:
|
||||
validate_assignment = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue