Skip to content

Commit

Permalink
Include current URL in the message payload (Chainlit#1403)
Browse files Browse the repository at this point in the history
Co-authored-by: Mathijs de Bruin <[email protected]>
  • Loading branch information
fgalind1 and dokterbob authored Oct 8, 2024
1 parent 0039137 commit 938e2eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions backend/chainlit/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,17 @@ 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"],
content=_dict["output"],
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,
Expand Down
3 changes: 2 additions & 1 deletion libs/copilot/src/components/InputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions libs/react-client/src/types/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IStep {
language?: string;
streaming?: boolean;
steps?: IStep[];
metadata?: Record<string, any>;
//legacy
indent?: number;
}

0 comments on commit 938e2eb

Please sign in to comment.