Refactor SharedState build method to accept optional record parameter
This commit is contained in:
parent
569be9e080
commit
5ebcdf5d52
1 changed files with 7 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Union
|
||||
from typing import Optional
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import Text
|
||||
|
|
@ -20,12 +20,13 @@ class SharedState(CustomComponent):
|
|||
}
|
||||
|
||||
def build(
|
||||
self, name: str, record: Union[Text, Record], append: bool = False
|
||||
self, name: str, record: Optional[Record] = None, append: bool = False
|
||||
) -> Record:
|
||||
if append:
|
||||
self.append_state(name, record)
|
||||
else:
|
||||
self.update_state(name, record)
|
||||
if record:
|
||||
if append:
|
||||
self.append_state(name, record)
|
||||
else:
|
||||
self.update_state(name, record)
|
||||
|
||||
state = self.get_state(name)
|
||||
if state and not isinstance(state, Record):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue