• Define a retriever that uses vector similarity search to retrieve documents from Firestore. You must create a vector index on the associated field before you can perform nearest-neighbor search.

    Parameters

    • ai: Genkit
    • config: {
          collection?: string;
          contentField:
              | string
              | (
                  snap: QueryDocumentSnapshot<DocumentData, DocumentData>,
              ) => (
                  | { media?: undefined; text: string }
                  | { media: { contentType?: string; url: string }; text?: undefined }
              )[];
          distanceMeasure?: "EUCLIDEAN" | "COSINE" | "DOT_PRODUCT";
          embedder: EmbedderArgument<ZodTypeAny>;
          firestore: Firestore;
          label?: string;
          metadataFields?:
              | string[]
              | (
                  snap: QueryDocumentSnapshot<DocumentData, DocumentData>,
              ) => Record<string, any>;
          name: string;
          vectorField: string;
      }
      • Optionalcollection?: string

        The name of the collection from which to query.

      • contentField:
            | string
            | (
                snap: QueryDocumentSnapshot<DocumentData, DocumentData>,
            ) => (
                | { media?: undefined; text: string }
                | { media: { contentType?: string; url: string }; text?: undefined }
            )[]

        The name of the field containing the document content you wish to return.

      • OptionaldistanceMeasure?: "EUCLIDEAN" | "COSINE" | "DOT_PRODUCT"

        The distance measure to use when comparing vectors. Defaults to 'COSINE'.

      • embedder: EmbedderArgument<ZodTypeAny>

        The embedder to use with this retriever.

      • firestore: Firestore

        The Firestore database instance from which to query.

      • Optionallabel?: string

        Optional label for display in Developer UI.

      • OptionalmetadataFields?:
            | string[]
            | (
                snap: QueryDocumentSnapshot<DocumentData, DocumentData>,
            ) => Record<string, any>

        A list of fields to include in the returned document metadata. If not supplied, all fields other than the vector are included. Alternatively, provide a transform function to extract the desired metadata fields from a snapshot.

      • name: string

        The name of the retriever.

      • vectorField: string

        The name of the field within the collection containing the vector data.

    Returns RetrieverAction