GetRAGSpaceInfo
Returns information about the specified RAG space or all RAG spaces, if no space ID is specified.
Format
GetRAGSpaceInfo ( ragAccountName {; spaceID } )
Parameters
ragAccountName
- a text expression for the name of the RAG account to use. In the current file, use the Configure RAG Account script step to set up the account and assign it this name any time before this function is used.
spaceID
- ID of a RAG space. If omitted, returns information about all RAG spaces for the specified account.
Parameters in braces { } are optional.
Data type returned
text
Originated in version
22.0
Description
GetRAGSpaceInfo returns information about retrieval-augmented generation (RAG) spaces on the AI Model Server specified by ragAccountName
. You can use it to verify the existence of a RAG space, monitor its content, and audit RAG operations.
If no spaceID
value is specified, the function returns a JSON object containing an array of RAG spaces available to the specified RAG account:
{
"rag_space_list": [
{
"space_id": "<string>",
"model": "<string>"
}
]
}
-
rag_space_list
is an array of RAG spaces. -
space_id
is the key for a RAG space ID. -
model
is the key for the name of the model used to generate text embedding vectors in this RAG space.
If a spaceID
value is specified, the function returns a JSON object containing information about the RAG space and the data in it:
{
"rag_space_id": "<string>",
"model": "<string>",
"entries": <number>,
"values": [
{
"id": <number>,
"filename": "<string>"
},
{
"id": <number>,
"text": "<string>"
}
]
}
-
rag_space_id
is the RAG space ID. -
model
is the name of the model used to generate text embedding vectors in this RAG space. -
entries
is the number of elements in thevalues
array. -
values
is an array of text document chunks and PDF filenames:-
id
is a numeric ID for the text document that a text chunk came from, or for a PDF file. -
filename
is the name of a PDF file added to the space. -
text
is a chunk of a text document added to the space. Chunks from the same text document have the sameid
.
-
Notes
-
A RAG account must be configured using the Configure RAG Account script step before using this function.
-
This function is useful for verifying that a RAG space exists before performing operations on it. For a valid RAG account, if a space doesn't exist or has no data in it, this function returns an error message:
[RAG Space] error. Reason: RAG space {space_id} not found
-
If the RAG account is invalid or doesn't exist, this function returns "?".
-
The function can be used for auditing and monitoring of RAG spaces within your FileMaker solution.
Example 1
Gets information about all RAG spaces for a configured account named "customer-support-rag-account".
GetRAGSpaceInfo ( "customer-support-rag-account" )
can return the following if two RAG spaces contain data:
{
"rag_space_list": [
{
"space_id": "knowledge-base",
"model": "multi-qa-MiniLM-L6-cos-v1"
},
{
"space_id": "meeting-notes",
"model": "multi-qa-MiniLM-L6-cos-v1"
}
]
}
Example 2
Gets information about a specific RAG space with ID "knowledge-base".
GetRAGSpaceInfo ( "customer-support-rag-account" ; "knowledge-base" )
can return the following JSON for a space with a PDF file named "Policies.pdf" and a text document divided into three chunks (truncated for brevity).
{
"rag_space_id": "knowledge-base",
"model": "multi-qa-MiniLM-L6-cos-v1",
"entries": 4,
"values": [
{
"id": 1,
"filename": "Policies.pdf"
},
{
"id": 2,
"text": "Customer support policies and procedures for handling returns and exchanges..."
},
{
"id": 2,
"text": "Ensure that the item you're returning is repackaged with all..."
},
{
"id": 2,
"text": "You have 14 calendar days to return an item from the date you received it..."
}
]
}
Example 3
Uses GetRAGSpaceInfo in a script to verify a RAG space exists before performing operations.
Configure RAG Account [ RAG Account Name: "customer-support-rag-account" ; Endpoint: "https://myserver.example.com/llm/v1/" ; API key: Global::RAG_API_Key ; Verify SSL Certificates ]
Set Variable [ $ragSpaceInfo ; Value: GetRAGSpaceInfo ( "customer-support-rag-account" ; "knowledge-base" ) ]
If [ PatternCount ( $ragSpaceInfo ; "[RAG Space] error" ) > 0 or PatternCount ( $ragSpaceInfo ; "?" ) > 0 ]
# RAG space doesn't exist. Handle error.
Show Custom Dialog [ "Error" ; "The specified RAG space wasn't found." ]
Else
# RAG space exists. Proceed with operations.
Set Variable [ $ragSpaceID ; Value: JSONGetElement ( $ragSpaceInfo ; "rag_space_id" ) ]
Show Custom Dialog [ "Space Found" ; "RAG space '" & $ragSpaceID & "' is available to use." ]
End If