TsgcAIOpenAIChatBotProperties › Embeddings

Embeddings Property

Optional embeddings store used to retrieve context (RAG) before a chat completion.

Syntax

property Embeddings: TsgcAI_OpenAI_Embeddings read FEmbeddings write FEmbeddings;

Default Value

Remarks

Assign a TsgcAI_OpenAI_Embeddings instance to turn the ChatBot into a Retrieval-Augmented Generation (RAG) agent. Call GetEmbedding to query the store for the nearest documents to a prompt and feed them back as system or user messages before ChatAsUser. The property is weakly owned: the ChatBot clears the reference automatically in Notification when the embeddings component is freed.

Example

sgcChatBot.Embeddings := sgcEmbeddings;
vContext := sgcChatBot.GetEmbedding('What is our refund policy?');
sgcChatBot.ChatAsSystem('Use this context: ' + vContext);
sgcChatBot.ChatAsUser('Summarise the policy in one sentence.');

Back to Properties