Sources#
ragbits.core.sources.base.Source
#
Bases: WithConstructionConfig
, BaseModel
, ABC
Base class for data sources.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
abstractmethod
async
#
list_sources
abstractmethod
async
classmethod
#
List all sources from the given storage.
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of Source objects. |
Source code in packages/ragbits-core/src/ragbits/core/sources/base.py
from_uri
abstractmethod
async
classmethod
#
Create Source instances from a URI path.
The path can contain glob patterns (asterisks) to match multiple sources, but pattern support varies by source type. Each source implementation defines which patterns it supports.
PARAMETER | DESCRIPTION |
---|---|
path |
The path part of the URI (after protocol://). Pattern support depends on source type.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of Source objects matching the path pattern. |
Source code in packages/ragbits-core/src/ragbits/core/sources/base.py
ragbits.core.sources.azure.AzureBlobStorageSource
#
Bases: Source
Source for data stored in the Azure Blob Storage.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Downloads the blob to a temporary local file and returns the file path.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
RAISES | DESCRIPTION |
---|---|
SourceNotFoundError
|
If the blob source is not available. |
SourceConnectionError
|
If the blob service connection is not available. |
Source code in packages/ragbits-core/src/ragbits/core/sources/azure.py
list_sources
async
classmethod
#
List all sources in the given Azure container, matching the prefix.
PARAMETER | DESCRIPTION |
---|---|
account_name |
The Azure storage account name.
TYPE:
|
container |
The Azure container name.
TYPE:
|
blob_name |
The prefix to match.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the Azure Blob Storage container. |
RAISES | DESCRIPTION |
---|---|
SourceConnectionError
|
If there's an error connecting to Azure |
Source code in packages/ragbits-core/src/ragbits/core/sources/azure.py
from_uri
async
classmethod
#
Create AzureBlobStorageSource instances from a URI path.
The supported URI formats:
- https://
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the Azure Blob Storage container. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the Azure Blob Storage URI is invalid. |
Source code in packages/ragbits-core/src/ragbits/core/sources/azure.py
ragbits.core.sources.gcs.GCSSource
#
Bases: Source
Source for data stored in the Google Cloud Storage.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
set_storage
classmethod
#
fetch
async
#
Fetch the file from Google Cloud Storage and store it locally.
The file is downloaded to a local directory specified by local_dir
. If the file already exists locally,
it will not be downloaded again. If the file doesn't exist locally, it will be fetched from GCS.
The local directory is determined by the environment variable LOCAL_STORAGE_DIR
. If this environment
variable is not set, a temporary directory is used.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
Source code in packages/ragbits-core/src/ragbits/core/sources/gcs.py
list_sources
async
classmethod
#
List all sources in the given GCS bucket, matching the prefix.
PARAMETER | DESCRIPTION |
---|---|
bucket |
The GCS bucket.
TYPE:
|
prefix |
The prefix to match.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the GCS bucket. |
Source code in packages/ragbits-core/src/ragbits/core/sources/gcs.py
from_uri
async
classmethod
#
Create GCSSource instances from a URI path.
The supported URI formats:
-
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the GCS bucket. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If an unsupported pattern is used |
Source code in packages/ragbits-core/src/ragbits/core/sources/gcs.py
ragbits.core.sources.git.GitSource
#
Bases: Source
Source for data stored in the Git repository.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Clone the Git repository and return the path to the specific file.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
RAISES | DESCRIPTION |
---|---|
SourceNotFoundError
|
If the repository cannot be cloned or the file doesn't exist. |
Source code in packages/ragbits-core/src/ragbits/core/sources/git.py
list_sources
async
classmethod
#
list_sources(repo_url: str, file_pattern: str = '**/*', branch: str | None = None) -> Iterable[Self]
List all files in the repository matching the pattern.
PARAMETER | DESCRIPTION |
---|---|
repo_url |
URL of the git repository.
TYPE:
|
file_pattern |
The glob pattern to match files.
TYPE:
|
branch |
Optional branch name.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the git repository. |
Source code in packages/ragbits-core/src/ragbits/core/sources/git.py
from_uri
async
classmethod
#
Create GitSource instances from a URI path.
Supported URI formats: - git://https://github.com/username/repo.git:path/to/file.txt - git://https://github.com/username/repo.git:branch:path/to/file.txt - git@github.com:username/repo.git:path/to/file.txt - git@github.com:username/repo.git:branch:path/to/file.txt
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the git repository. |
Source code in packages/ragbits-core/src/ragbits/core/sources/git.py
ragbits.core.sources.hf.HuggingFaceSource
#
Bases: Source
Source for data stored in the Hugging Face repository.
Supports two formats: 1. Complete dataset: When no row is specified, downloads the entire dataset. Used for QA datasets. 2. Single row: When a specific row is specified, downloads only that row. Used for document datasets (requires "content" and "source" columns).
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Fetch the file from Hugging Face and store it locally.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
RAISES | DESCRIPTION |
---|---|
SourceConnectionError
|
If the source connection fails. |
SourceNotFoundError
|
If the source document is not found. |
Source code in packages/ragbits-core/src/ragbits/core/sources/hf.py
list_sources
async
classmethod
#
List all sources in the Hugging Face repository.
PARAMETER | DESCRIPTION |
---|---|
path |
Path or name of the dataset.
TYPE:
|
split |
Dataset split.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the Hugging Face repository. |
Source code in packages/ragbits-core/src/ragbits/core/sources/hf.py
from_uri
async
classmethod
#
Create HuggingFaceSource instances from a URI path.
The supported URI formats:
-
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the Hugging Face repository. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the path contains patterns or has invalid format. |
Source code in packages/ragbits-core/src/ragbits/core/sources/hf.py
ragbits.core.sources.local.LocalFileSource
#
Bases: Source
Source for data stored on the local disk.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Fetch the source.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the file. |
RAISES | DESCRIPTION |
---|---|
SourceNotFoundError
|
If the source document is not found. |
Source code in packages/ragbits-core/src/ragbits/core/sources/local.py
list_sources
async
classmethod
#
List all sources in the given directory, matching the file pattern.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to the directory.
TYPE:
|
file_pattern |
The file pattern to match.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the local file system. |
Source code in packages/ragbits-core/src/ragbits/core/sources/local.py
from_uri
async
classmethod
#
Create LocalFileSource instances from a URI path.
The supported URI formats: - "/.txt" - all .txt files in any subdirectory - ".py" - all Python files in the current directory - "/*" - all files in any subdirectory - '?' matches exactly one character
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the local file system. |
Source code in packages/ragbits-core/src/ragbits/core/sources/local.py
ragbits.core.sources.s3.S3Source
#
Bases: Source
Source for data stored in the AWS S3 bucket.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Download a file in the given bucket name and key.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
RAISES | DESCRIPTION |
---|---|
ClientError
|
If the file doesn't exist or credentials are incomplete. |
NoCredentialsError
|
If no credentials are available. |
Source code in packages/ragbits-core/src/ragbits/core/sources/s3.py
list_sources
async
classmethod
#
List all files under the given bucket name and with the given prefix.
PARAMETER | DESCRIPTION |
---|---|
bucket_name |
The name of the S3 bucket to use.
TYPE:
|
prefix |
The path to the files and prefix to look for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the S3 bucket. |
RAISES | DESCRIPTION |
---|---|
ClientError
|
If the source doesn't exist. |
NoCredentialsError
|
If no credentials are available. |
PartialCredentialsError
|
If credentials are incomplete. |
Source code in packages/ragbits-core/src/ragbits/core/sources/s3.py
from_uri
async
classmethod
#
Create S3Source instances from a URI path.
The supported URI formats:
- s3://
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the S3 bucket. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the path has invalid format |
Source code in packages/ragbits-core/src/ragbits/core/sources/s3.py
ragbits.core.sources.web.WebSource
#
Bases: Source
Source for data stored in the web.
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component preferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
class_identifier
classmethod
#
source_type
#
fetch
async
#
Download a file available in the given url.
RETURNS | DESCRIPTION |
---|---|
Path
|
The local path to the downloaded file. |
RAISES | DESCRIPTION |
---|---|
SourceDownloadError
|
If the download failed. |
SourceNotFoundError
|
If the URL is invalid. |
Source code in packages/ragbits-core/src/ragbits/core/sources/web.py
list_sources
async
classmethod
#
List the file under the given URL.
PARAMETER | DESCRIPTION |
---|---|
url |
The URL to the file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the web. |
Source code in packages/ragbits-core/src/ragbits/core/sources/web.py
from_uri
async
classmethod
#
Create WebSource instances from a URI path.
The supported URI formats:
-
PARAMETER | DESCRIPTION |
---|---|
path |
The URI path in the format described above.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Self]
|
The iterable of sources from the web. |