spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Refactored to optimize Document embedding reuse:

Open tzolov opened this issue 1 year ago • 1 comments
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.

tzolov avatar Mar 07 '24 13:03 tzolov