TsgcAIOpenAIEmbeddingsMethods › CreateEmbeddingsFromFile

CreateEmbeddingsFromFile Method

Loads a text file and generates embeddings from its contents.

Syntax

procedure CreateEmbeddingsFromFile(const aFileName: string);

Parameters

NameTypeDescription
aFileNameconst stringFull path of the text file to read.

Remarks

Convenience wrapper around CreateEmbeddings: loads the given text file into memory and then processes the whole content using the same chunking, event and storage behaviour. The file is read with a TStringList, so any text file supported by Delphi can be used. Typical use cases are ingesting documentation, FAQ documents or transcripts into a vector database.

Example

oEmbeddings.OpenAIOptions.ApiKey := 'sk-...';
oEmbeddings.Database := oFileDB;
oEmbeddings.CreateEmbeddingsFromFile('C:\data\knowledge-base.txt');

Back to Methods