コンテンツにスキップ

Craft RAG

const { rag } = MODULES;

Table of Contents


Schemas

RetrieveResultValue

Type: Object

Properties

  • filePath string Source file path.
  • text string The text chunk.
  • score number The score between the query dense embedding vector and the context text vector.

RagDataSchema

Type: Object

Properties

  • key string The metadata key name.
  • type ("INTEGER" | "FLOAT" | "STRING" | "DATETIME" | "BOOLEAN" | "LIST") The data type of the metadata key.

RagMetadata

Type: Object

Properties


Methods

retrieveContexts

Parameters

  • param Object

    • param.corpusId string RAG Id
    • param.text string The query text to get relevant contexts.
    • param.vectorDistanceThreshold number? Optional. Only contexts with a vector distance smaller than the threshold are returned.
    • param.topK number? Optional. The number of contexts to return.
    • param.llmRankerModel string? Optional. The name of the LLM ranker model to use for ranking results. Only accepts: gemini-2.5-flash, gemini-2.5-pro, gemini-2.5-flash-lite, gemini-3.5-flash, gemini-3.1-flash-lite, or gemini-3.1-pro-preview.
    • param.rankServiceModel string? Optional. The name of the rank service model to use for ranking results. Only accepts: semantic-ranker-512-003.
    • param.metadataFilter string? Optional. A metadata filter string using CEL (Common Expression Language) syntax (e.g., category == "HR").

Returns Promise<Array<RetrieveResultValue>>

createDataSchemas

Define metadata schemas for a RAG corpus.

Parameters

Returns Promise<Object>

attachMetadata

Attach metadata values to an existing RAG file.

Parameters

Returns Promise<Object>

listDataSchemas

List metadata schemas defined on a RAG corpus.

Parameters

Returns Promise<Object>

listMetadata

List metadata attached to a RAG file.

Parameters

Returns Promise<Object>