Refactor code to handle optional fields in Record and add new fields to ChatOutputResponse
This commit is contained in:
parent
5633565156
commit
2d1900d3dc
3 changed files with 7 additions and 7 deletions
|
|
@ -112,7 +112,7 @@ class CustomComponent(Component):
|
|||
return yaml.dump(self.repr_value)
|
||||
if isinstance(self.repr_value, str):
|
||||
return self.repr_value
|
||||
return str(self.repr_value)
|
||||
return self.repr_value
|
||||
|
||||
def build_config(self):
|
||||
return self.field_config
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
from langchain_core.documents import Document
|
||||
from pydantic import BaseModel
|
||||
|
|
@ -13,7 +13,7 @@ class Record(BaseModel):
|
|||
data (dict, optional): Additional data associated with the record.
|
||||
"""
|
||||
|
||||
text: str
|
||||
text: Optional[str] = ""
|
||||
data: dict = {}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -52,8 +52,6 @@ class Record(BaseModel):
|
|||
Returns the text of the record.
|
||||
|
||||
Returns:
|
||||
str: The text of the record.
|
||||
str: The text and data of the record.
|
||||
"""
|
||||
return self.text
|
||||
|
||||
|
||||
return self.model_dump_json(indent=2)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ class ChatOutputResponse(BaseModel):
|
|||
message: Union[str, List[Union[str, Dict]]]
|
||||
sender: Optional[str] = "Machine"
|
||||
sender_name: Optional[str] = "AI"
|
||||
session_id: Optional[str] = None
|
||||
stream_url: Optional[str] = None
|
||||
component_id: Optional[str] = None
|
||||
|
||||
@classmethod
|
||||
def from_message(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue