TsgcAIOpenAIEmbeddings › Methods › CreateEmbeddings
Splits the input text into chunks and generates an embedding for each chunk.
procedure CreateEmbeddings(const aInput: string);
| Name | Type | Description |
|---|---|---|
aInput | const string | Text from which the embeddings will be generated. |
Walks the input string in steps of EmbeddingsOptions.ChunkSize characters and, for each chunk, performs a call to the OpenAI embeddings endpoint using the model configured in EmbeddingsOptions. The batch is bracketed by OnCreateEmbeddingsStart and OnCreateEmbeddingsStop, and each individual chunk fires OnBeforeCreateEmbedding, OnAfterCreateEmbedding and OnCreateEmbeddingsProgress. When Database is assigned the resulting vectors are stored automatically. If WaitStoringData is greater than zero, the call sleeps for that many milliseconds between chunks.
oEmbeddings.OpenAIOptions.ApiKey := 'sk-...';
oEmbeddings.EmbeddingsOptions.Model := 'text-embedding-3-small';
oEmbeddings.EmbeddingsOptions.ChunkSize := 2048;
oEmbeddings.Database := oFileDB;
oEmbeddings.CreateEmbeddings('The quick brown fox jumps over the lazy dog.');