File Vector Database Component — sgcAI | eSeGeCe

Vector Database (File)

TsgcAIDatabaseVectorFile stores embedding vectors and their source text in two local files. Assign it to an embeddings component and you have a searchable corpus that ships inside your application, with no server and no per-query cost.

TsgcAIDatabaseVectorFile

A dependency-free vector store. Vectors and their source texts are held in memory, written to disk when a batch closes, and scanned for the nearest match on query.

Component class

TsgcAIDatabaseVectorFile

Purpose

Local vector store

Platforms

Win32 and Win64

sgcAI is self-contained. This component ships inside sgcAI together with the sgcWebSockets Core runtime it is built on, so there is no base license to buy.

A searchable corpus in two files

Point the component at an input file and a vector file, assign it to an embeddings component, and it does the rest.

uses
  sgcAI, sgcAI_DB_Vector_File, sgcAI_OpenAI_Embeddings;

var
  oDB: TsgcAIDatabaseVectorFile;
  oEmbeddings: TsgcAIOpenAIEmbeddings;
begin
  oDB := TsgcAIDatabaseVectorFile.Create(nil);
  oDB.VectorFileOptions.InputFilename  := 'corpus.sgcif';
  oDB.VectorFileOptions.VectorFilename := 'corpus.sgcvf';

  oEmbeddings := TsgcAIOpenAIEmbeddings.Create(nil);
  oEmbeddings.OpenAIOptions.ApiKey := 'sk-...';
  oEmbeddings.Database := oDB;
  oEmbeddings.CreateEmbeddingsFromFile('manual.txt');

  // The store can also be driven directly.
  oDB.BeginAddData;
  oDB.AddData('Reset procedure: hold the button for 10 seconds.', vVector);
  oDB.EndAddData;

  Memo1.Text := oDB.QueryData(vQueryVector);
end;
// includes: sgcAI.hpp, sgcAI_DB_Vector_File.hpp

TsgcAIDatabaseVectorFile *oDB = new TsgcAIDatabaseVectorFile(NULL);
oDB->VectorFileOptions->InputFilename  = "corpus.sgcif";
oDB->VectorFileOptions->VectorFilename = "corpus.sgcvf";

oDB->BeginAddData();
oDB->AddData("Reset procedure: hold the button for 10 seconds.", vVector);
oDB->EndAddData();

String vBest = oDB->QueryData(vQueryVector);

Key properties & methods

The members you reach for most often.

VectorFileOptions

InputFilename holds the source texts keyed by id and VectorFilename holds the matching vectors. Ship both files with your application and the corpus is available offline.

Ingest

BeginAddData opens a batch, AddData adds one text and its vector, and EndAddData closes the batch and writes both files to disk.

Query

QueryData takes a query vector, scans the stored vectors for the closest match and returns the original text behind it.

Id control

OnBeginAddData lets you set the first id and the id label for a batch, so a second ingest can append to an existing corpus rather than overwrite it.

When to use it

Best for corpora that fit comfortably in memory and for desktop applications that must work without a network connection. For large or shared indexes use the Pinecone store instead.

Interchangeable

It implements the same interface as TsgcAIDatabaseVectorPinecone, so moving from local files to a managed index is a change of one component, not a change of code.

Keep exploring

Online HelpFull API reference and usage guide for the sgcAI components.
All sgcAI ComponentsBrowse the full feature matrix of all 15 components.
Download Free TrialBuild an offline searchable corpus in a desktop application.
PricingSingle, Team and Site licenses, full source code, no base product required.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Get Started?

Download the free trial and ship a searchable knowledge base inside your executable.