GetEmbedding
Sends input data to an embedding model and returns a vector representation as container data.
Format
GetEmbedding ( account ; model ; input )
Parameters
account
- the AI account for this function to use. In the current file, use the Configure AI Account script step to set up the account and assign it this name any time before this function is used.
model
- the name of the model to generate embedding vectors. Specify the model name as a text expression, which is available from the model provider.
input
- any expression that returns text or container data to send to the model for conversion to embedding vectors.
Data type returned
container
Originated in version
21.0
Description
Similar to the Insert Embedding script step, this function gets embedding vectors for the specified input using an AI account and model. However, this function returns embedding vectors only as container data, which can be smaller than when stored as text and can improve performance in any further processing with the embedding vectors.
For image as well as text embedding vectors, you can use the models supported by the open source model server provided separately with FileMaker Pro or installed with FileMaker Server. See the Claris Engineering Blog.
This function returns "?", and the EvaluationError function returns:
-
error code 877 ("Can't find AI account") if no AI account is currently configured
-
error code 882 ("Invalid AI request") if, while performing image embedding, the image specified by
input
is an unsupported file type or the file size is too large
Example 1
Configures an AI account, goes to the Meeting Details layout, then sets the value of the Meetings::Note_Embedding container field in the current record to the binary embedding vector data for the text "Claris."
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: "sk-RZCtpWT..." ]
Go to Layout [ "Meeting Details" (Meetings) ; Animation: None ]
Set Field [ Meetings::Note_Embedding ; GetEmbedding ( "my-account" ; "text-embedding-3-small" ; "Claris" ) ]
Example 2
Configures an AI account, goes to the Meeting Details layout, and asks the user to enter text to compare with the Note field in the current record. Next, gets the embedding vectors for the input and stores them in a variable as container data, and does the same with the text in the Meetings::Note field. Then displays the cosine similarity of the embedding vectors in the two variables.
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: "sk-RZCtpWT..." ]
Go to Layout [ "Meeting Details" (Meetings) ; Animation: None ]
Show Custom Dialog [ "Compare this text to the meeting note:" ; $Input ]
Set Variable [ $Input_Embedding ; Value: GetEmbedding ( "my-account" ; "text-embedding-3-small" ; $Input ) ]
Set Variable [ $Note_Embedding ; Value: GetEmbedding ( "my-account" ; "text-embedding-3-small" ; Meetings::Note ) ]
Show Custom Dialog [ "Cosine Similarity" ; CosineSimilarity ( $Input_Embedding ; $Note_Embedding ) ]