spring-ai
spring-ai copied to clipboard
Refactored to optimize Document embedding reuse:
trafficstars
- Introduced logic to utilize existing Document embeddings when not empty, avoiding unnecessary calls to embeddingClient.embed.
- Ensured immutability of the Document#content field by making it final.
- Implemented a default method cachedEmbed in the EmbeddingClient interface, responsible for checking existing document embeddings and adding them if absent.
- Updated all Vector Store implementations to employ cachedEmbed upon document addition.
- Ensured that embedding fields are returned with resolved documents in select Vector Store implementations for consistency.