diff --git a/backend/chainlit/message.py b/backend/chainlit/message.py index 7bb590f8be..051089c119 100644 --- a/backend/chainlit/message.py +++ b/backend/chainlit/message.py @@ -59,7 +59,7 @@ def __post_init__(self) -> None: @classmethod def from_dict(self, _dict: StepDict): type = _dict.get("type", "assistant_message") - message = Message( + return Message( id=_dict["id"], parent_id=_dict.get("parentId"), created_at=_dict["createdAt"], @@ -67,10 +67,9 @@ def from_dict(self, _dict: StepDict): author=_dict.get("name", config.ui.name), type=type, # type: ignore language=_dict.get("language"), + metadata=_dict.get("metadata", {}), ) - return message - def to_dict(self) -> StepDict: _dict: StepDict = { "id": self.id, diff --git a/libs/copilot/src/components/InputBox.tsx b/libs/copilot/src/components/InputBox.tsx index e9c31150f4..054cc61bbc 100644 --- a/libs/copilot/src/components/InputBox.tsx +++ b/libs/copilot/src/components/InputBox.tsx @@ -45,7 +45,8 @@ const InputBox = memo( name: user?.identifier || 'User', type: 'user_message', output: msg, - createdAt: new Date().toISOString() + createdAt: new Date().toISOString(), + metadata: {location: window.location.href}, }; setInputHistory((old) => { diff --git a/libs/react-client/src/types/step.ts b/libs/react-client/src/types/step.ts index c631aab088..7ef69c89d4 100644 --- a/libs/react-client/src/types/step.ts +++ b/libs/react-client/src/types/step.ts @@ -30,6 +30,7 @@ export interface IStep { language?: string; streaming?: boolean; steps?: IStep[]; + metadata?: Record; //legacy indent?: number; }