Add UpdateRecordComponent to helpers
This commit is contained in:
parent
6348da2de3
commit
bac1933a57
1 changed files with 38 additions and 0 deletions
38
src/backend/langflow/components/helpers/UpdateRecord.py
Normal file
38
src/backend/langflow/components/helpers/UpdateRecord.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
from langflow import CustomComponent
|
||||||
|
from langflow.schema import Record
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateRecordComponent(CustomComponent):
|
||||||
|
display_name = "Update Record"
|
||||||
|
description = "Updates a record with new data."
|
||||||
|
|
||||||
|
def build_config(self):
|
||||||
|
return {
|
||||||
|
"record": {
|
||||||
|
"display_name": "Record",
|
||||||
|
"info": "The record to update.",
|
||||||
|
},
|
||||||
|
"new_data": {
|
||||||
|
"display_name": "New Data",
|
||||||
|
"info": "The new data to update the record with.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def build(
|
||||||
|
self,
|
||||||
|
record: Record,
|
||||||
|
new_data: dict,
|
||||||
|
) -> Record:
|
||||||
|
"""
|
||||||
|
Updates a record with new data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
record (Record): The record to update.
|
||||||
|
new_data (dict): The new data to update the record with.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Record: The updated record.
|
||||||
|
"""
|
||||||
|
record.data.update(new_data)
|
||||||
|
self.status = record
|
||||||
|
return record
|
||||||
Loading…
Add table
Add a link
Reference in a new issue