Versions

  • v0

    8/17/2023
    Open: Version
    +127
    -0

    const retrieverSampleSelfQuery = (async () => {
    const { AttributeInfo } = await import(
    "npm:langchain/schema/query_constructor"
    );
    const { Document } = await import("npm:langchain/document");
    const { SelfQueryRetriever } = await import(
    "npm:langchain/retrievers/self_query"
    );
    const { FunctionalTranslator } = await import(
    "npm:langchain/retrievers/self_query/functional"
    );
    /**
    * First, we create a bunch of documents. You can load your own documents here instead.
    * Each document has a pageContent and a metadata field. Make sure your metadata matches the AttributeInfo below.
    */
    const docs = [
    new Document({
    pageContent:
    "A bunch of scientists bring back dinosaurs and mayhem breaks loose",
    metadata: { year: 1993, rating: 7.7, genre: "science fiction" },
    }),
    new Document({
    pageContent:
    "Leo DiCaprio gets lost in a dream within a dream within a dream within a ...",
    metadata: { year: 2010, director: "Christopher Nolan", rating: 8.2 },
    }),
    new Document({
    pageContent:
    "A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea",
    metadata: { year: 2006, director: "Satoshi Kon", rating: 8.6 },
    }),
    new Document({
    pageContent:
    "A bunch of normal-sized women are supremely wholesome and some men pine after them",
    metadata: { year: 2019, director: "Greta Gerwig", rating: 8.3 },
    }),
2
Next
Updated: October 23, 2023