Class VespaEmbeddingStore

java.lang.Object
dev.langchain4j.store.embedding.vespa.VespaEmbeddingStore
All Implemented Interfaces:
dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>

public class VespaEmbeddingStore extends Object implements dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
Represents the Vespa - search engine and vector database. Does not support storing Metadata yet. Example server configuration contains cosine similarity search rank profile, of course other Vespa neighbor search methods are supported too. Read more here.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    VespaEmbeddingStore(String url, String keyPath, String certPath, Duration timeout, String namespace, String documentType, String clusterName, String rankProfile, Integer targetHits, Boolean avoidDups, Boolean logRequests, Boolean logResponses)
    Creates a new VespaEmbeddingStore instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(dev.langchain4j.data.embedding.Embedding embedding)
     
    add(dev.langchain4j.data.embedding.Embedding embedding, dev.langchain4j.data.segment.TextSegment textSegment)
     
    void
    add(String id, dev.langchain4j.data.embedding.Embedding embedding)
    Adds a new embedding with provided ID to the store.
    addAll(List<dev.langchain4j.data.embedding.Embedding> embeddings)
     
    void
    addAll(List<String> ids, List<dev.langchain4j.data.embedding.Embedding> embeddings, List<dev.langchain4j.data.segment.TextSegment> embedded)
     
     
    void
     
    dev.langchain4j.store.embedding.EmbeddingSearchResult<dev.langchain4j.data.segment.TextSegment>
    search(dev.langchain4j.store.embedding.EmbeddingSearchRequest request)
    The score inside EmbeddingMatch is Vespa relevance according to provided rank profile.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface dev.langchain4j.store.embedding.EmbeddingStore

    addAll, addListener, addListeners, generateIds, remove, removeAll, removeAll
  • Constructor Details

    • VespaEmbeddingStore

      public VespaEmbeddingStore(String url, String keyPath, String certPath, Duration timeout, String namespace, String documentType, String clusterName, String rankProfile, Integer targetHits, Boolean avoidDups, Boolean logRequests, Boolean logResponses)
      Creates a new VespaEmbeddingStore instance.
      Parameters:
      url - server url, local or cloud one. The latter you can find under Endpoint of your Vespa application, e.g. https://alexey-heezer.langchain4j.mytenant346.aws-us-east-1c.dev.z.vespa-app.cloud/
      keyPath - local path to the SSL private key file in PEM format. Read docs for details. Null if there is no SSL private key file e.g. for local Vespa server.
      certPath - local path to the SSL certificate file in PEM format. Read docs for details. Null if there is no SSL certificate file e.g. for local Vespa server.
      timeout - for Vespa Java client in java.time.Duration format.
      namespace - required for document ID generation, find more details here.
      documentType - document type, used for document ID generation, find more details here and data querying
      clusterName - cluster name, used for deleting all documents, find more details here
      rankProfile - rank profile from your .sd schema. Provided example schema configures cosine similarity match
      targetHits - sets the number of hits (10 is default) exposed to the real Vespa's first-phase ranking function per content node, find more details here.
      avoidDups - if true (default), then VespaEmbeddingStore will generate a hashed ID based on provided text segment, which avoids duplicated entries in DB. If false, then random ID will be generated.
      logRequests - If true, requests to the Vespa service are logged.
      logResponses - If true, responses from the Vespa service are logged.
  • Method Details

    • builder

      public static VespaEmbeddingStore.Builder builder()
    • add

      public String add(dev.langchain4j.data.embedding.Embedding embedding)
      Specified by:
      add in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    • add

      public void add(String id, dev.langchain4j.data.embedding.Embedding embedding)
      Adds a new embedding with provided ID to the store.
      Specified by:
      add in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
      Parameters:
      id - "user-specified" part of document ID, find more details here
      embedding - the embedding to add
    • add

      public String add(dev.langchain4j.data.embedding.Embedding embedding, dev.langchain4j.data.segment.TextSegment textSegment)
      Specified by:
      add in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    • addAll

      public List<String> addAll(List<dev.langchain4j.data.embedding.Embedding> embeddings)
      Specified by:
      addAll in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    • addAll

      public void addAll(List<String> ids, List<dev.langchain4j.data.embedding.Embedding> embeddings, List<dev.langchain4j.data.segment.TextSegment> embedded)
      Specified by:
      addAll in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    • search

      public dev.langchain4j.store.embedding.EmbeddingSearchResult<dev.langchain4j.data.segment.TextSegment> search(dev.langchain4j.store.embedding.EmbeddingSearchRequest request)
      The score inside EmbeddingMatch is Vespa relevance according to provided rank profile.
      Specified by:
      search in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    • removeAll

      public void removeAll()
      Specified by:
      removeAll in interface dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>