GenaiDocumentQuery

The class inherits from the GenaiVectorQuery class. It enables an API caller to query a single document and generate a response from the watsonx LLM. The Content Platform Engine server verifies whether the call has VIEW_CONTENT access for the underlying document. The document is processed by using one of the following methods:
  • Entire document processing - If the extracted text is less than 400,000 characters and no custom value is specified for GenaiRelevancyFilterLevel, the entire document text is sent directly to the LLM without querying the vector database. In this case, the relevancy score checking is also ignored. This optimization works well for large documents where relevant sections are scattered across different areas.
  • Retrieval-augmented generation (RAG) - If the extracted text exceeds 400,000 characters or a custom GenaiRelevancyFilterLevel value is specified, this method is used. A vector query retrieves the most relevant document chunks, which are then sent to the LLM along with the prompt to generate a response.
For more information, see GenaiDocumentQuery class in the FNCM documentation.
Table 1. GenaiDocumentQuery class properties
Property Data type Description
GenaiLLMPrompt String The input prompt from the user. The maximum length for the value is 4000 characters.
GenaiLLMModelName String An optional watsonx LLM model name. The maximum length for the value is 256 characters.
GenaiLLMResponse String The response from the watsonx LLM.
GenaiLLMMaxOutputTokens Integer If you set this parameter, it overrides the LLM maximum output tokens parameter, which has a default value of 4096. You cannot set a value less than 10 or greater than 8192.
GenaiVectorChunks String A JSON value that contains the document chunks that the vector search returns. If GenaiPerformLLMQuery is false, then this property holds all the vector query results. If GenaiPerformLLMQuery is true, then this property holds the chunks that were submitted to the LLM as context for the LLM query.
GenaiPerformLLMQuery Boolean If the value is true, the prompt is submitted to an LLM with the vector chunks as context.
GenaiMaxDocumentChunks Integer You can set the maximum number of document chunks that need to be returned in the GenaiVectorChunks property.
GenaiRelevancyFilterLevel Float When you set this parameter, it overrides the LLM relevancy score filter level setting in the tenant configuration, which has a default value of 0.5. You can set a value between 0.0 and 1.0.
Note: If the extracted document text is less than 400,000 characters and no custom value is specified for this parameter, the entire document text is sent directly to the LLM without relevancy score checking. In other cases, retrieval-augmented generation (RAG) is used instead, where a vector query retrieves the most relevant document chunks based on the relevancy score filter.
GenaiContextDocument Object The document that is used as context for the query.
GenaiPromptTemplate String An optional parameter that specifies the prompt template for your query operation. If you set this parameter, the template that you pass overrides all the default prompt templates that are already configured in Content Platform Engine.