Skip to content

Commit

Permalink
fix json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Feb 22, 2025
1 parent c8c3d9e commit 55c99f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/Retrieval/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ public function hasEmbeddings(): bool
return \count($this->embeddings) !== 0;
}

/**
* @throws \JsonException
*/
#[\Override]
public function jsonSerialize(): string
public function jsonSerialize(): array
{
return \json_encode([
return [
'content' => $this->content,
'embeddings' => $this->embeddings,
'metadata' => $this->metadata,
], \JSON_THROW_ON_ERROR);
];
}
}
9 changes: 3 additions & 6 deletions src/Retrieval/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ public static function from(array $metadata): self
);
}

/**
* @throws \JsonException
*/
#[\Override]
public function jsonSerialize(): string
public function jsonSerialize(): array
{
return \json_encode([
return [
'hash' => $this->hash,
'sourceType' => $this->sourceType,
'sourceName' => $this->sourceName,
'chunkNumber' => $this->chunkNumber,
], \JSON_THROW_ON_ERROR);
];
}
}

0 comments on commit 55c99f5

Please sign in to comment.