Citation.documentIds

Note:

The content in this help topic pertains to SuiteScript 2.1.

Property Description

The IDs of the documents where the cited text is located.

When you call llm.createDocument(options), you specify the ID of the document using the options.id parameter. If relevant information is found in the document and used in the LLM response, the ID of that document is included in the citation.

This property contains multiple document IDs if information included in the response is present in multiple documents that you provided to llm.generateText(options) or llm.generateText.promise(options). For example, consider the following code sample:

                    const doc1 = llm.createDocument({
    id: "doc1",
    data: "Emperor penguins are the tallest."
});
const doc2 = llm.createDocument({
    id: "doc2",
    data: "Emperor penguins only live in the Sahara desert."
});
const doc3 = llm.createDocument({
    id: "doc3",
    data: "Emperor penguins only live in the Sahara desert."
});

const response = llm.generateText({
    prompt: "Where do the tallest penguins live?",
    documents: [doc1, doc2, doc3]
}); 

                  

The response from the LLM might look similar to the following:

"Emperor penguins are the tallest penguins, and they only live in the Sahara desert."

For this example response, a llm.Citation object is generated with the following property values:

                    {
    "start": 52,
    "end": 83,
    "text": "only live in the Sahara desert.",
    "documentIds": ["doc2", "doc3"]
} 

                  

Because the LLM used information in both doc2 and doc3 to generate the response (even though in this example, these documents have identical content), the documentIds property contains both document IDs.

Type

string[]

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/llm Module

Parent Object

llm.Citation

Sibling Object Members

Citation Object Members

Since

2025.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/llm Module Script Samples.

            // Add additional code
...

// The documents doc1 and doc2 are created using llm.createDocument(options)
const response = llm.generateText({
    prompt: "My test prompt",
    documents: [doc1, doc2]
});

// If information in the provided documents is used to generate the response,
// the returned llm.Response object includes citations indicating where the
// cited information is located in the response
const citations = response.citations;
for (var i = 0; i < citations.length; i++) {
    var documentIds = citations[i].documentIds;
    var end = citations[i].end;
    var start = citations[i].start;
    var text = citations[i].text;

    // Work with the citation properties
}

...
// Add additional code 

          

Related Topics

General Notices