Skip to content

Commit

Permalink
load data pipeline supports read config (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
paradiseHIT authored and moria97 committed Jun 20, 2024
1 parent 6823b37 commit d28f986
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/pai_rag/data/rag_datapipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from pai_rag.core.rag_configuration import RagConfiguration
from pai_rag.modules.module_registry import module_registry

_BASE_DIR = Path(__file__).parent
DEFAULT_APPLICATION_CONFIG_FILE = os.path.join(_BASE_DIR, "config/settings.toml")


class RagDataPipeline:
def __init__(self, data_loader):
Expand All @@ -14,10 +17,7 @@ async def ingest_from_folder(self, folder_path: str, enable_qa_extraction: bool)
await self.data_loader.aload(folder_path, enable_qa_extraction)


def __init_data_pipeline(use_local_qa_model):
base_dir = Path(__file__).parent.parent
config_file = os.path.join(base_dir, "config/settings.toml")

def __init_data_pipeline(config_file, use_local_qa_model):
config = RagConfiguration.from_file(config_file).get_value()
module_registry.init_modules(config)

Expand All @@ -26,6 +26,13 @@ def __init_data_pipeline(use_local_qa_model):


@click.command()
@click.option(
"-c",
"--config",
show_default=True,
help=f"Configuration file. Default: {DEFAULT_APPLICATION_CONFIG_FILE}",
default=DEFAULT_APPLICATION_CONFIG_FILE,
)
@click.option("-d", "--directory", required=True, help="directory path to ingest.")
@click.option(
"-q",
Expand All @@ -45,6 +52,6 @@ def __init_data_pipeline(use_local_qa_model):
default=False,
help="use local qa extraction model.",
)
def run(directory, extract_qa, use_local_qa_model):
data_pipeline = __init_data_pipeline(use_local_qa_model)
def run(config, directory, extract_qa, use_local_qa_model):
data_pipeline = __init_data_pipeline(config, use_local_qa_model)
asyncio.run(data_pipeline.ingest_from_folder(directory, extract_qa))

0 comments on commit d28f986

Please sign in to comment.