Method CreateFileDataSource
CreateFileDataSource(string, string, LM, MetadataCollection, bool)
Creates a new file-backed DataSource instance with the specified identifier and language model. This method creates a new file at the given path and opens it with read-write access. The resulting DataSource is initially created in-memory and then associated with the backing file stream, enabling future updates to be synchronized with the file.
public static DataSource CreateFileDataSource(string path, string identifier, LM model, MetadataCollection metadata = null, bool overwrite = false)
Parameters
pathstringThe file path where the data source will be created. This must be a valid path and the file must not already exist.
identifierstringThe unique identifier for the data source.
modelLMThe language model associated with the data source.
metadataMetadataCollectionOptional metadata to be associated with the data source.
overwriteboolIf
true, an existing file atpathwill be deleted before creating a new one. Iffalseand the file already exists, no action is taken on the file system and creation will fail in Create(string, string, int, MetadataCollection).
Returns
- DataSource
A new DataSource instance that is backed by a file.
Exceptions
- ArgumentNullException
Thrown if
pathis null, empty, or consists solely of white-space characters.
CreateFileDataSource(string, string, int, MetadataCollection, bool)
Creates a new file-backedDataSource instance with the specified identifier and embedding size.
This method creates a new file at the given path (deleting any existing file if overwrite is true)
and then invokes Create(string, string, int, MetadataCollection) to initialize the in-memory data source and link it to the file.
public static DataSource CreateFileDataSource(string path, string identifier, int embeddingSize, MetadataCollection metadata = null, bool overwrite = false)
Parameters
pathstringThe file path where the data source will be created. Must be non-null, non-empty, and not consist solely of white-space.
identifierstringThe unique identifier for the data source. Used to distinguish this source in logs and lookups.
embeddingSizeintThe dimensionality of the vector embeddings stored by this data source. Must match the size expected by downstream searches.
metadataMetadataCollectionOptional MetadataCollection to associate with the data source. Pass
nullif no metadata is required.overwriteboolIf
true, any existing file atpathwill be deleted before creation. Iffalseand the file already exists, the file is left untouched and Create(string, string, int, MetadataCollection) will fail if it cannot open the existing file for writing.
Returns
- DataSource
A new DataSource instance that is backed by the specified file path.
Exceptions
- ArgumentNullException
Thrown if
pathisnull, empty, or consists solely of white-space characters.