Skip to content

Commit 835cde4

Browse files
committed
fix file chat history with context window
1 parent bdd0b9a commit 835cde4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Chat/Messages/Message.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ public function addMetadata(string $key, string|array|null $value): Message
4646

4747
public function jsonSerialize(): array
4848
{
49-
return array_merge($this->meta, [
49+
return \array_merge($this->meta, [
5050
'role' => $this->getRole(),
51-
'content' => $this->getContent(),
52-
'usage' => $this->getUsage()->jsonSerialize()
53-
]);
51+
'content' => $this->getContent()
52+
], \array_filter(['usage' => $this->getUsage()?->jsonSerialize()]));
5453
}
5554
}

0 commit comments

Comments
 (0)