To use the embeddings, first we must convert our data to vectors.
Example
If you have a pdf file, first convert the pdf file to text and then use the method CreateEmbeddingsFromFile to get the vector data. Due to the OpenAI Embeddings size limitation, if the file is too big, the data will be splitted automatically in chunks, so from 1 file you can get 1 or multiple vectors.
Find below a code sample.
void ConvertFileToVector()
{
TOpenDialog* oDialog = new TOpenDialog(NULL);
try
{
oDialog->Filter = "TXT Files|*.txt";
if (oDialog->Execute())
{
TsgcAIOpenAIEmbeddings* oEmbeddings = new TsgcAIOpenAIEmbeddings(NULL);
try
{
TsgcAIDatabaseVectorFile* oFile = new TsgcAIDatabaseVectorFile(NULL);
try
{
oEmbeddings->Database = oFile;
oEmbeddings->OpenAIOptions->ApiKey = "<your api key>";
oEmbeddings->CreateEmbeddingsFromFile(oDialog->FileName);
}
__finally
{
delete oFile;
}
}
__finally
{
delete oEmbeddings;
}
}
}
__finally
{
delete oDialog;
}
}