code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_partial_non_existent_propagation(self, branched_pipeline, hook_manager): """A non existent dataset whose node has one unregistered input and one existent input should be recalculated correctly. """ catalog = _make_catalog(existent=["A", "C", "E", "F"], non_existent=["D"]) ...
A non existent dataset whose node has one unregistered input and one existent input should be recalculated correctly.
test_partial_non_existent_propagation
python
kedro-org/kedro
tests/pipeline/test_pipeline_from_missing.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_from_missing.py
Apache-2.0
def test_free_output(self, branched_pipeline, hook_manager): """Free outputs are the only unregistered data sources that should trigger runs. """ catalog = _make_catalog(existent=["A", "B", "C", "F"]) new_pipeline = _from_missing(branched_pipeline, catalog, hook_manager) ...
Free outputs are the only unregistered data sources that should trigger runs.
test_free_output
python
kedro-org/kedro
tests/pipeline/test_pipeline_from_missing.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_from_missing.py
Apache-2.0
def test_connect_existing_pipelines(self): """ Two pipelines exist, the dataset names do not match. We `transform` them to work together. """ cook_pipeline = pipeline( [node(defrost, "frozen_meat", "meat"), node(grill, "meat", "grilled_meat")] ) lunch...
Two pipelines exist, the dataset names do not match. We `transform` them to work together.
test_connect_existing_pipelines
python
kedro-org/kedro
tests/pipeline/test_pipeline_integration.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_integration.py
Apache-2.0
def test_reuse_same_pipeline(self): """ The same pipeline needs to be used twice in the same big pipeline. Normally dataset and node names would conflict, so we need to `transform` the pipelines. """ cook_pipeline = pipeline( [ node(defrost, "f...
The same pipeline needs to be used twice in the same big pipeline. Normally dataset and node names would conflict, so we need to `transform` the pipelines.
test_reuse_same_pipeline
python
kedro-org/kedro
tests/pipeline/test_pipeline_integration.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_integration.py
Apache-2.0
def test_transcoded_inputs_outputs(self): """Nodes must not refer to a dataset without the separator if it is referenced later on in the catalog. """ pattern = "The following datasets are used with transcoding, " pattern += "but were referenced without the separator: B." ...
Nodes must not refer to a dataset without the separator if it is referenced later on in the catalog.
test_transcoded_inputs_outputs
python
kedro-org/kedro
tests/pipeline/test_pipeline_with_transcoding.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_with_transcoding.py
Apache-2.0
def test_from_nodes_transcoded_names(self, complex_pipeline): """New pipelines contain all nodes that depend on node8 downstream.""" from_nodes_pipeline = complex_pipeline.from_nodes("node8") nodes = {node.name for node in from_nodes_pipeline.nodes} assert nodes == { "node1"...
New pipelines contain all nodes that depend on node8 downstream.
test_from_nodes_transcoded_names
python
kedro-org/kedro
tests/pipeline/test_pipeline_with_transcoding.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_with_transcoding.py
Apache-2.0
def test_to_nodes_transcoded_names(self, complex_pipeline): """New pipelines contain all nodes that depend on node7 upstream.""" to_nodes_pipeline = complex_pipeline.to_nodes("node7") nodes = {node.name for node in to_nodes_pipeline.nodes} assert nodes == {"node7", "node8", "node9"}
New pipelines contain all nodes that depend on node7 upstream.
test_to_nodes_transcoded_names
python
kedro-org/kedro
tests/pipeline/test_pipeline_with_transcoding.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_with_transcoding.py
Apache-2.0
def test_from_inputs_traverses_transcoded_on_correct_branch(self, complex_pipeline): """Test that from_inputs intercepts only the correct branch at top layer (B@node7), but traverses transcoded nodes (H) found further down the graph.""" p = complex_pipeline.from_inputs("B@node7", "L") a...
Test that from_inputs intercepts only the correct branch at top layer (B@node7), but traverses transcoded nodes (H) found further down the graph.
test_from_inputs_traverses_transcoded_on_correct_branch
python
kedro-org/kedro
tests/pipeline/test_pipeline_with_transcoding.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_with_transcoding.py
Apache-2.0
def test_to_outputs_traverses_transcoded(self, complex_pipeline): """Test that to_outputs traverses transcoded nodes (B) found further up the graph.""" p = complex_pipeline.to_outputs("H@node4", "D") assert _get_node_names(p) == {"node4", "node6", "node7", "node8", "node9"}
Test that to_outputs traverses transcoded nodes (B) found further up the graph.
test_to_outputs_traverses_transcoded
python
kedro-org/kedro
tests/pipeline/test_pipeline_with_transcoding.py
https://github.com/kedro-org/kedro/blob/master/tests/pipeline/test_pipeline_with_transcoding.py
Apache-2.0
def branchless_no_input_pipeline(): """The pipeline runs in the order A->B->C->D->E.""" return pipeline( [ node(identity, "D", "E", name="node1"), node(identity, "C", "D", name="node2"), node(identity, "A", "B", name="node3"), node(identity, "B", "C", name...
The pipeline runs in the order A->B->C->D->E.
branchless_no_input_pipeline
python
kedro-org/kedro
tests/runner/conftest.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/conftest.py
Apache-2.0
def two_branches_crossed_pipeline(): r"""A ``Pipeline`` with an X-shape (two branches with one common node): (node1_A) (node1_B) \ / (node2) / \ (node3_A) (node3_B) / \ (node4_A) (node4_B) """ return pipeline( [ ...
A ``Pipeline`` with an X-shape (two branches with one common node): (node1_A) (node1_B) \ / (node2) / \ (node3_A) (node3_B) / \ (node4_A) (node4_B)
two_branches_crossed_pipeline
python
kedro-org/kedro
tests/runner/conftest.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/conftest.py
Apache-2.0
def two_branches_crossed_pipeline_variable_inputs(request): """A ``Pipeline`` with an X-shape (two branches with one common node). Non-persistent datasets (other than parameters) are prefixed with an underscore. """ extra_inputs = list(request.param) return pipeline( [ node(firs...
A ``Pipeline`` with an X-shape (two branches with one common node). Non-persistent datasets (other than parameters) are prefixed with an underscore.
two_branches_crossed_pipeline_variable_inputs
python
kedro-org/kedro
tests/runner/conftest.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/conftest.py
Apache-2.0
def test_specified_max_workers_bellow_cpu_cores_count( self, is_async, mocker, fan_out_fan_in, catalog, cpu_cores, user_specified_number, expected_number, ): """ The system has 2 cores, but we initialize the runner with max_workers=4. ...
The system has 2 cores, but we initialize the runner with max_workers=4. `fan_out_fan_in` pipeline needs 3 processes. A pool with 3 workers should be used.
test_specified_max_workers_bellow_cpu_cores_count
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_max_worker_windows(self, mocker): """The ProcessPoolExecutor on Python 3.7+ has a quirk with the max worker number on Windows and requires it to be <=61 """ mocker.patch("os.cpu_count", return_value=100) mocker.patch("sys.platform", "win32") parallel_run...
The ProcessPoolExecutor on Python 3.7+ has a quirk with the max worker number on Windows and requires it to be <=61
test_max_worker_windows
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_task_node_validation(self, is_async, fan_out_fan_in, catalog): """ParallelRunner cannot serialise the lambda function.""" catalog.add_feed_dict({"A": 42}) test_pipeline = pipeline([fan_out_fan_in, node(lambda x: x, "Z", "X")]) with pytest.raises(AttributeError): Para...
ParallelRunner cannot serialise the lambda function.
test_task_node_validation
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_task_dataset_validation(self, is_async, fan_out_fan_in, catalog): """ParallelRunner cannot serialise datasets marked with `_SINGLE_PROCESS`.""" catalog.add("A", SingleProcessDataset()) with pytest.raises(AttributeError): ParallelRunner(is_async=is_async).run(fan_out_fan_in, ...
ParallelRunner cannot serialise datasets marked with `_SINGLE_PROCESS`.
test_task_dataset_validation
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_memory_dataset_output(self, is_async, fan_out_fan_in): """ParallelRunner does not support output to externally created MemoryDatasets. """ test_pipeline = pipeline([fan_out_fan_in]) catalog = DataCatalog({"C": MemoryDataset()}, {"A": 42}) with pytest.raises(Attri...
ParallelRunner does not support output to externally created MemoryDatasets.
test_memory_dataset_output
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_dataset_not_serialisable(self, is_async, fan_out_fan_in): """Data set A cannot be serialisable because _load and _save are not defined in global scope. """ def _load(): return 0 # pragma: no cover def _save(arg): assert arg == 0 # pragma: no c...
Data set A cannot be serialisable because _load and _save are not defined in global scope.
test_dataset_not_serialisable
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_memory_dataset_not_serialisable(self, is_async, catalog): """Memory dataset cannot be serialisable because of data it stores.""" data = return_not_serialisable(None) test_pipeline = pipeline([node(return_not_serialisable, "A", "B")]) catalog.add_feed_dict(feed_dict={"A": 42}) ...
Memory dataset cannot be serialisable because of data it stores.
test_memory_dataset_not_serialisable
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_unable_to_schedule_all_nodes( self, mocker, is_async, fan_out_fan_in, catalog ): """Test the error raised when `futures` variable is empty, but `todo_nodes` is not (can barely happen in real life). """ catalog.add_feed_dict({"A": 42}) runner = ParallelRunner(...
Test the error raised when `futures` variable is empty, but `todo_nodes` is not (can barely happen in real life).
test_unable_to_schedule_all_nodes
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_stricter_suggest_resume_scenario( self, caplog, two_branches_crossed_pipeline_variable_inputs, logging_dataset_catalog, failing_node_names, expected_pattern, ): """ Stricter version of previous test. Covers pipelines where inputs are s...
Stricter version of previous test. Covers pipelines where inputs are shared across nodes.
test_stricter_suggest_resume_scenario
python
kedro-org/kedro
tests/runner/test_parallel_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_parallel_runner.py
Apache-2.0
def test_simple_pipeline( self, pipeline_name, persistent_dataset_catalog, remaining_node_names, expected_result, request, ): """ Test suggestion for simple pipelines with a mix of persistent and memory datasets. """ test_pipeli...
Test suggestion for simple pipelines with a mix of persistent and memory datasets.
test_simple_pipeline
python
kedro-org/kedro
tests/runner/test_resume_logic.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_resume_logic.py
Apache-2.0
def test_all_datasets_persistent( self, pipeline_name, persistent_dataset_catalog, remaining_node_names, expected_result, request, ): """ Test suggestion for pipelines where all datasets are persisted: In that case, exactly the set of remaining...
Test suggestion for pipelines where all datasets are persisted: In that case, exactly the set of remaining nodes should be re-run.
test_all_datasets_persistent
python
kedro-org/kedro
tests/runner/test_resume_logic.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_resume_logic.py
Apache-2.0
def test_added_shared_input( self, pipeline_name, persistent_dataset_catalog, remaining_node_names, expected_result, extra_input, request, ): """ Test suggestion for pipelines where a single persistent dataset or parameter is shared acr...
Test suggestion for pipelines where a single persistent dataset or parameter is shared across all nodes. These do not change and therefore should not affect resume suggestion.
test_added_shared_input
python
kedro-org/kedro
tests/runner/test_resume_logic.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_resume_logic.py
Apache-2.0
def test_suggestion_consistency( self, pipeline_name, persistent_dataset_catalog, remaining_node_names, expected_result, request, ): """ Test that suggestions are internally consistent; pipeline generated from resume nodes should exactly contai...
Test that suggestions are internally consistent; pipeline generated from resume nodes should exactly contain set of all required nodes.
test_suggestion_consistency
python
kedro-org/kedro
tests/runner/test_resume_logic.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_resume_logic.py
Apache-2.0
def test_result_saved_not_returned(self, is_async, saving_result_pipeline): """The pipeline runs ds->dsX but save does not save the output.""" def _load(): return 0 def _save(arg): assert arg == 0 catalog = DataCatalog( { "ds": Lambd...
The pipeline runs ds->dsX but save does not save the output.
test_result_saved_not_returned
python
kedro-org/kedro
tests/runner/test_sequential_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_sequential_runner.py
Apache-2.0
def test_conflict_feed_catalog( self, is_async, memory_catalog, unfinished_outputs_pipeline, conflicting_feed_dict, ): """ds1 and ds3 will be replaced with new inputs.""" memory_catalog.add_feed_dict(conflicting_feed_dict, replace=True) outputs = Seque...
ds1 and ds3 will be replaced with new inputs.
test_conflict_feed_catalog
python
kedro-org/kedro
tests/runner/test_sequential_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_sequential_runner.py
Apache-2.0
def test_thread_run_with_patterns(self, catalog_type): """Test warm-up is done and patterns are resolved before running pipeline. Without the warm-up "Dataset 'dummy_1' has already been registered" error would be raised for this test. We check that the dataset was registered at the warm...
Test warm-up is done and patterns are resolved before running pipeline. Without the warm-up "Dataset 'dummy_1' has already been registered" error would be raised for this test. We check that the dataset was registered at the warm-up, and we successfully passed to loading it.
test_thread_run_with_patterns
python
kedro-org/kedro
tests/runner/test_thread_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_thread_runner.py
Apache-2.0
def test_specified_max_workers( self, mocker, fan_out_fan_in, catalog, user_specified_number, expected_number, ): """ We initialize the runner with max_workers=4. `fan_out_fan_in` pipeline needs 3 threads. A pool with 3 workers should b...
We initialize the runner with max_workers=4. `fan_out_fan_in` pipeline needs 3 threads. A pool with 3 workers should be used.
test_specified_max_workers
python
kedro-org/kedro
tests/runner/test_thread_runner.py
https://github.com/kedro-org/kedro/blob/master/tests/runner/test_thread_runner.py
Apache-2.0
def _uninstall_existing_build() -> None: """Uninstall an existing build with the same name as the build to install.""" api_client = _get_api_client() library_api = LibrariesApi(api_client) libraries = [ {"whl": f"{DBFS_UPLOAD_PATH.absolute_path}/{_get_build_file_path().name}"} ] library_...
Uninstall an existing build with the same name as the build to install.
_uninstall_existing_build
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def _restart_cluster_if_running() -> None: """Restart a Databricks cluster if it is currently running, otherwise no-op.""" api_client = _get_api_client() cluster_api = ClusterApi(api_client) if cluster_api.get_cluster(CLUSTER_ID)["state"] == "TERMINATED": logging.info( "Cluster %s is...
Restart a Databricks cluster if it is currently running, otherwise no-op.
_restart_cluster_if_running
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def _upload_build_to_dbfs() -> None: """Upload the wheel file at the given path to DBFS.""" api_client = _get_api_client() dbfs_api = DbfsApi(api_client) src_path = str(_get_build_file_path()) dbfs_api.put_file( src_path, DbfsPath(f"{DBFS_UPLOAD_PATH.absolute_path}/{_get_build_file_p...
Upload the wheel file at the given path to DBFS.
_upload_build_to_dbfs
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def _install_build() -> None: """Install Kedro on the target cluster using the uploaded wheel file""" api_client = _get_api_client() library_api = LibrariesApi(api_client) libraries = [ {"whl": f"{DBFS_UPLOAD_PATH.absolute_path}/{_get_build_file_path().name}"} ] library_api.install_libra...
Install Kedro on the target cluster using the uploaded wheel file
_install_build
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def _get_api_client() -> ApiClient: """Create an ApiClient object using the config""" config = get_config() if config.is_valid_with_token: return ApiClient(host=config.host, token=config.token) return ApiClient(user=config.username, password=config.password, host=config.host)
Create an ApiClient object using the config
_get_api_client
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def _get_build_file_path() -> Path: """Get the path of the whl file to install. If multiple whl files are found, return the file with the highest version number. """ dist_path = Path(__file__).resolve().parent.parent / "dist" whl_files = list(dist_path.glob("*.whl")) whl_files.sort() try: ...
Get the path of the whl file to install. If multiple whl files are found, return the file with the highest version number.
_get_build_file_path
python
kedro-org/kedro
tools/databricks_build.py
https://github.com/kedro-org/kedro/blob/master/tools/databricks_build.py
Apache-2.0
def set_provider_config(request: ProviderConfigRequest): """ Set configuration for a specific provider. Args: request (ProviderConfigRequest): The request containing provider configuration. Returns: dict: A dictionary containing a success message and the updated configuration. Rai...
Set configuration for a specific provider. Args: request (ProviderConfigRequest): The request containing provider configuration. Returns: dict: A dictionary containing a success message and the updated configuration. Raises: HTTPException: If setting the provider config fails...
set_provider_config
python
zilliztech/deep-searcher
main.py
https://github.com/zilliztech/deep-searcher/blob/master/main.py
Apache-2.0
def load_files( paths: Union[str, List[str]] = Body( ..., description="A list of file paths to be loaded.", examples=["/path/to/file1", "/path/to/file2", "/path/to/dir1"], ), collection_name: str = Body( None, description="Optional name for the collection.", e...
Load files into the vector database. Args: paths (Union[str, List[str]]): File paths or directories to load. collection_name (str, optional): Name for the collection. Defaults to None. collection_description (str, optional): Description for the collection. Defaults to None. bat...
load_files
python
zilliztech/deep-searcher
main.py
https://github.com/zilliztech/deep-searcher/blob/master/main.py
Apache-2.0
def load_website( urls: Union[str, List[str]] = Body( ..., description="A list of URLs of websites to be loaded.", examples=["https://milvus.io/docs/overview.md"], ), collection_name: str = Body( None, description="Optional name for the collection.", examples=...
Load website content into the vector database. Args: urls (Union[str, List[str]]): URLs of websites to load. collection_name (str, optional): Name for the collection. Defaults to None. collection_description (str, optional): Description for the collection. Defaults to None. bat...
load_website
python
zilliztech/deep-searcher
main.py
https://github.com/zilliztech/deep-searcher/blob/master/main.py
Apache-2.0
def perform_query( original_query: str = Query( ..., description="Your question here.", examples=["Write a report about Milvus."], ), max_iter: int = Query( 3, description="The maximum number of iterations for reflection.", ge=1, examples=[3], ), )...
Perform a query against the loaded data. Args: original_query (str): The user's question or query. max_iter (int, optional): Maximum number of iterations for reflection. Defaults to 3. Returns: dict: A dictionary containing the query result and token consumption. Raises: ...
perform_query
python
zilliztech/deep-searcher
main.py
https://github.com/zilliztech/deep-searcher/blob/master/main.py
Apache-2.0
def __init__(self, config_path: str = DEFAULT_CONFIG_YAML_PATH): """ Initialize the Configuration object. Args: config_path: Path to the configuration YAML file. Defaults to the config.yaml in the project root. """ # Initialize default configurations config_d...
Initialize the Configuration object. Args: config_path: Path to the configuration YAML file. Defaults to the config.yaml in the project root.
__init__
python
zilliztech/deep-searcher
deepsearcher/configuration.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/configuration.py
Apache-2.0
def set_provider_config(self, feature: FeatureType, provider: str, provider_configs: dict): """ Set the provider and its configurations for a given feature. Args: feature: The feature to configure (e.g., 'llm', 'file_loader', 'web_crawler'). provider: The provider name (...
Set the provider and its configurations for a given feature. Args: feature: The feature to configure (e.g., 'llm', 'file_loader', 'web_crawler'). provider: The provider name (e.g., 'openai', 'deepseek'). provider_configs: A dictionary with configurations specific to...
set_provider_config
python
zilliztech/deep-searcher
deepsearcher/configuration.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/configuration.py
Apache-2.0
def get_provider_config(self, feature: FeatureType): """ Get the current provider and configuration for a given feature. Args: feature: The feature to retrieve (e.g., 'llm', 'file_loader', 'web_crawler'). Returns: A dictionary with provider and its configuration...
Get the current provider and configuration for a given feature. Args: feature: The feature to retrieve (e.g., 'llm', 'file_loader', 'web_crawler'). Returns: A dictionary with provider and its configurations. Raises: ValueError: If the feature is no...
get_provider_config
python
zilliztech/deep-searcher
deepsearcher/configuration.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/configuration.py
Apache-2.0
def _create_module_instance(self, feature: FeatureType, module_name: str): """ Create an instance of a module based on the feature and module name. Args: feature: The feature type (e.g., 'llm', 'embedding'). module_name: The module name to import from. Returns: ...
Create an instance of a module based on the feature and module name. Args: feature: The feature type (e.g., 'llm', 'embedding'). module_name: The module name to import from. Returns: An instance of the specified module.
_create_module_instance
python
zilliztech/deep-searcher
deepsearcher/configuration.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/configuration.py
Apache-2.0
def init_config(config: Configuration): """ Initialize the global configuration and create instances of all required modules. This function initializes the global variables for the LLM, embedding model, file loader, web crawler, vector database, and RAG agents. Args: config: The Configurat...
Initialize the global configuration and create instances of all required modules. This function initializes the global variables for the LLM, embedding model, file loader, web crawler, vector database, and RAG agents. Args: config: The Configuration object to use for initialization.
init_config
python
zilliztech/deep-searcher
deepsearcher/configuration.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/configuration.py
Apache-2.0
def load_from_local_files( paths_or_directory: Union[str, List[str]], collection_name: str = None, collection_description: str = None, force_new_collection: bool = False, chunk_size: int = 1500, chunk_overlap: int = 100, batch_size: int = 256, ): """ Load knowledge from local files o...
Load knowledge from local files or directories into the vector database. This function processes files from the specified paths or directories, splits them into chunks, embeds the chunks, and stores them in the vector database. Args: paths_or_directory: A single path or a list of paths to fil...
load_from_local_files
python
zilliztech/deep-searcher
deepsearcher/offline_loading.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/offline_loading.py
Apache-2.0
def load_from_website( urls: Union[str, List[str]], collection_name: str = None, collection_description: str = None, force_new_collection: bool = False, chunk_size: int = 1500, chunk_overlap: int = 100, batch_size: int = 256, **crawl_kwargs, ): """ Load knowledge from websites in...
Load knowledge from websites into the vector database. This function crawls the specified URLs, processes the content, splits it into chunks, embeds the chunks, and stores them in the vector database. Args: urls: A single URL or a list of URLs to crawl. collection_name: Name of the co...
load_from_website
python
zilliztech/deep-searcher
deepsearcher/offline_loading.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/offline_loading.py
Apache-2.0
def query(original_query: str, max_iter: int = 3) -> Tuple[str, List[RetrievalResult], int]: """ Query the knowledge base with a question and get an answer. This function uses the default searcher to query the knowledge base and generate an answer based on the retrieved information. Args: ...
Query the knowledge base with a question and get an answer. This function uses the default searcher to query the knowledge base and generate an answer based on the retrieved information. Args: original_query: The question or query to search for. max_iter: Maximum number of iterations ...
query
python
zilliztech/deep-searcher
deepsearcher/online_query.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/online_query.py
Apache-2.0
def retrieve( original_query: str, max_iter: int = 3 ) -> Tuple[List[RetrievalResult], List[str], int]: """ Retrieve relevant information from the knowledge base without generating an answer. This function uses the default searcher to retrieve information from the knowledge base that is relevant to...
Retrieve relevant information from the knowledge base without generating an answer. This function uses the default searcher to retrieve information from the knowledge base that is relevant to the query. Args: original_query: The question or query to search for. max_iter: Maximum numbe...
retrieve
python
zilliztech/deep-searcher
deepsearcher/online_query.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/online_query.py
Apache-2.0
def naive_retrieve(query: str, collection: str = None, top_k=10) -> List[RetrievalResult]: """ Perform a simple retrieval from the knowledge base using the naive RAG approach. This function uses the naive RAG agent to retrieve information from the knowledge base without any advanced techniques like ite...
Perform a simple retrieval from the knowledge base using the naive RAG approach. This function uses the naive RAG agent to retrieve information from the knowledge base without any advanced techniques like iterative refinement. Args: query: The question or query to search for. collecti...
naive_retrieve
python
zilliztech/deep-searcher
deepsearcher/online_query.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/online_query.py
Apache-2.0
def naive_rag_query( query: str, collection: str = None, top_k=10 ) -> Tuple[str, List[RetrievalResult]]: """ Query the knowledge base using the naive RAG approach and get an answer. This function uses the naive RAG agent to query the knowledge base and generate an answer based on the retrieved inf...
Query the knowledge base using the naive RAG approach and get an answer. This function uses the naive RAG agent to query the knowledge base and generate an answer based on the retrieved information, without any advanced techniques. Args: query: The question or query to search for. col...
naive_rag_query
python
zilliztech/deep-searcher
deepsearcher/online_query.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/online_query.py
Apache-2.0
def describe_class(description): """ Decorator function to add a description to a class. This decorator adds a __description__ attribute to the decorated class, which can be used for documentation or introspection. Args: description: The description to add to the class. Returns: ...
Decorator function to add a description to a class. This decorator adds a __description__ attribute to the decorated class, which can be used for documentation or introspection. Args: description: The description to add to the class. Returns: A decorator function that adds the de...
describe_class
python
zilliztech/deep-searcher
deepsearcher/agent/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/base.py
Apache-2.0
def invoke(self, query: str, **kwargs) -> Any: """ Invoke the agent and return the result. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: The result of invoking the agent. """
Invoke the agent and return the result. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: The result of invoking the agent.
invoke
python
zilliztech/deep-searcher
deepsearcher/agent/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/base.py
Apache-2.0
def retrieve(self, query: str, **kwargs) -> Tuple[List[RetrievalResult], int, dict]: """ Retrieve document results from the knowledge base. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: ...
Retrieve document results from the knowledge base. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: - the retrieved results - the total number of token usages of the LLM ...
retrieve
python
zilliztech/deep-searcher
deepsearcher/agent/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/base.py
Apache-2.0
def query(self, query: str, **kwargs) -> Tuple[str, List[RetrievalResult], int]: """ Query the agent and return the answer. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: - the resu...
Query the agent and return the answer. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: - the result generated from LLM - the retrieved document results - the...
query
python
zilliztech/deep-searcher
deepsearcher/agent/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/base.py
Apache-2.0
def __init__( self, llm: BaseLLM, embedding_model: BaseEmbedding, vector_db: BaseVectorDB, max_iter: int = 4, early_stopping: bool = False, route_collection: bool = True, text_window_splitter: bool = True, **kwargs, ): """ Initi...
Initialize the ChainOfRAG agent with configuration parameters. Args: llm (BaseLLM): The language model to use for generating answers. embedding_model (BaseEmbedding): The embedding model to use for embedding queries. vector_db (BaseVectorDB): The vector database to ...
__init__
python
zilliztech/deep-searcher
deepsearcher/agent/chain_of_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/chain_of_rag.py
Apache-2.0
def retrieve(self, query: str, **kwargs) -> Tuple[List[RetrievalResult], int, dict]: """ Retrieves relevant documents based on the input query and iteratively refines the search. This method iteratively refines the search query based on intermediate results, retrieves documents, and fil...
Retrieves relevant documents based on the input query and iteratively refines the search. This method iteratively refines the search query based on intermediate results, retrieves documents, and filters out supported documents. It keeps track of the intermediate contexts and token usage. ...
retrieve
python
zilliztech/deep-searcher
deepsearcher/agent/chain_of_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/chain_of_rag.py
Apache-2.0
def query(self, query: str, **kwargs) -> Tuple[str, List[RetrievalResult], int]: """ Executes a query and returns the final answer along with all retrieved results and total token usage. This method initiates a query, retrieves relevant documents, and then summarizes the answer based on the ret...
Executes a query and returns the final answer along with all retrieved results and total token usage. This method initiates a query, retrieves relevant documents, and then summarizes the answer based on the retrieved documents and intermediate contexts. It logs the final answer and returns the answer ...
query
python
zilliztech/deep-searcher
deepsearcher/agent/chain_of_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/chain_of_rag.py
Apache-2.0
def __init__(self, llm: BaseLLM, vector_db: BaseVectorDB, dim: int, **kwargs): """ Initialize the CollectionRouter. Args: llm: The language model to use for analyzing queries. vector_db: The vector database containing the collections. dim: The dimension of th...
Initialize the CollectionRouter. Args: llm: The language model to use for analyzing queries. vector_db: The vector database containing the collections. dim: The dimension of the vector space to search in.
__init__
python
zilliztech/deep-searcher
deepsearcher/agent/collection_router.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/collection_router.py
Apache-2.0
def invoke(self, query: str, dim: int, **kwargs) -> Tuple[List[str], int]: """ Determine which collections are relevant for the given query. This method analyzes the query content and selects collections that are most likely to contain information relevant to answering the query. ...
Determine which collections are relevant for the given query. This method analyzes the query content and selects collections that are most likely to contain information relevant to answering the query. Args: query (str): The query to analyze. dim (int): The dim...
invoke
python
zilliztech/deep-searcher
deepsearcher/agent/collection_router.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/collection_router.py
Apache-2.0
def __init__( self, llm: BaseLLM, embedding_model: BaseEmbedding, vector_db: BaseVectorDB, max_iter: int = 3, route_collection: bool = True, text_window_splitter: bool = True, **kwargs, ): """ Initialize the DeepSearch agent. A...
Initialize the DeepSearch agent. Args: llm: The language model to use for generating answers. embedding_model: The embedding model to use for query embedding. vector_db: The vector database to search for relevant documents. max_iter: The maximum number o...
__init__
python
zilliztech/deep-searcher
deepsearcher/agent/deep_search.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/deep_search.py
Apache-2.0
def query(self, query: str, **kwargs) -> Tuple[str, List[RetrievalResult], int]: """ Query the agent and generate an answer based on retrieved documents. This method retrieves relevant documents and uses the language model to generate a comprehensive answer to the query. Args: ...
Query the agent and generate an answer based on retrieved documents. This method retrieves relevant documents and uses the language model to generate a comprehensive answer to the query. Args: query (str): The query to answer. **kwargs: Additional keyword argum...
query
python
zilliztech/deep-searcher
deepsearcher/agent/deep_search.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/deep_search.py
Apache-2.0
def __init__( self, llm: BaseLLM, embedding_model: BaseEmbedding, vector_db: BaseVectorDB, top_k: int = 10, route_collection: bool = True, text_window_splitter: bool = True, **kwargs, ): """ Initialize the NaiveRAG agent. Args:...
Initialize the NaiveRAG agent. Args: llm: The language model to use for generating answers. embedding_model: The embedding model to use for query embedding. vector_db: The vector database to search for relevant documents. **kwargs: Additional keyword arg...
__init__
python
zilliztech/deep-searcher
deepsearcher/agent/naive_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/naive_rag.py
Apache-2.0
def retrieve(self, query: str, **kwargs) -> Tuple[List[RetrievalResult], int, dict]: """ Retrieve relevant documents from the knowledge base for the given query. This method performs a basic search through the vector database to find documents relevant to the query. Args: ...
Retrieve relevant documents from the knowledge base for the given query. This method performs a basic search through the vector database to find documents relevant to the query. Args: query (str): The query to search for. **kwargs: Additional keyword arguments ...
retrieve
python
zilliztech/deep-searcher
deepsearcher/agent/naive_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/naive_rag.py
Apache-2.0
def query(self, query: str, **kwargs) -> Tuple[str, List[RetrievalResult], int]: """ Query the agent and generate an answer based on retrieved documents. This method retrieves relevant documents and uses the language model to generate a simple answer to the query. Args: ...
Query the agent and generate an answer based on retrieved documents. This method retrieves relevant documents and uses the language model to generate a simple answer to the query. Args: query (str): The query to answer. **kwargs: Additional keyword arguments fo...
query
python
zilliztech/deep-searcher
deepsearcher/agent/naive_rag.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/naive_rag.py
Apache-2.0
def __init__( self, llm: BaseLLM, rag_agents: List[RAGAgent], agent_descriptions: Optional[List[str]] = None, ): """ Initialize the RAGRouter. Args: llm: The language model to use for analyzing queries. rag_agents: A list of RAGAgent i...
Initialize the RAGRouter. Args: llm: The language model to use for analyzing queries. rag_agents: A list of RAGAgent instances. agent_descriptions (list, optional): A list of descriptions for each agent.
__init__
python
zilliztech/deep-searcher
deepsearcher/agent/rag_router.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/agent/rag_router.py
Apache-2.0
def embed_chunks(self, chunks: List[Chunk], batch_size: int = 256) -> List[Chunk]: """ Embed a list of Chunk objects. This method extracts the text from each chunk, embeds it in batches, and updates the chunks with their embeddings. Args: chunks: A list of Chunk obj...
Embed a list of Chunk objects. This method extracts the text from each chunk, embeds it in batches, and updates the chunks with their embeddings. Args: chunks: A list of Chunk objects to embed. batch_size: The number of chunks to process in each batch. ...
embed_chunks
python
zilliztech/deep-searcher
deepsearcher/embedding/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/base.py
Apache-2.0
def __init__(self, model: str = DEFAULT_MODEL_ID, region_name: str = "us-east-1", **kwargs): """ Initialize the Amazon Bedrock embedding model. Args: model (str): The model identifier to use for embeddings. Default is "amazon.titan-embed-text-v2:0". ...
Initialize the Amazon Bedrock embedding model. Args: model (str): The model identifier to use for embeddings. Default is "amazon.titan-embed-text-v2:0". **kwargs: Additional keyword arguments. - aws_access_key_id (str, optional): AWS acc...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/bedrock_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/bedrock_embedding.py
Apache-2.0
def embed_query(self, text: str) -> List[float]: """ Embed a single query text using Amazon Bedrock. Args: text (str): The query text to embed. Returns: List[float]: A list of floats representing the embedding vector. """ response = self.client.i...
Embed a single query text using Amazon Bedrock. Args: text (str): The query text to embed. Returns: List[float]: A list of floats representing the embedding vector.
embed_query
python
zilliztech/deep-searcher
deepsearcher/embedding/bedrock_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/bedrock_embedding.py
Apache-2.0
def __init__(self, model="BAAI/bge-small-en-v1.5", **kwargs): """ Initialize the Fastembed embedding model. Args: model (str): The name of the model to use. Defaults is "BAAI/bge-small-en-v1.5". **kwargs: Additional keyword arguments for TextEmbe...
Initialize the Fastembed embedding model. Args: model (str): The name of the model to use. Defaults is "BAAI/bge-small-en-v1.5". **kwargs: Additional keyword arguments for TextEmbedding.
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/fastembed_embdding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/fastembed_embdding.py
Apache-2.0
def _ensure_model_loaded(self): """ Lazily load the embedding model when first needed. """ from fastembed import TextEmbedding if self._embedding_model is None: self._embedding_model = TextEmbedding(model_name=self.model, **self._kwargs)
Lazily load the embedding model when first needed.
_ensure_model_loaded
python
zilliztech/deep-searcher
deepsearcher/embedding/fastembed_embdding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/fastembed_embdding.py
Apache-2.0
def embed_query(self, text: str) -> List[float]: """ Embed a single query text. Args: text (str): The query text to embed. Returns: List[float]: A list of floats representing the embedding vector. """ self._ensure_model_loaded() embeddin...
Embed a single query text. Args: text (str): The query text to embed. Returns: List[float]: A list of floats representing the embedding vector.
embed_query
python
zilliztech/deep-searcher
deepsearcher/embedding/fastembed_embdding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/fastembed_embdding.py
Apache-2.0
def embed_documents(self, texts: List[str]) -> List[List[float]]: """ Embed a list of document texts. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for each input text. """ ...
Embed a list of document texts. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for each input text.
embed_documents
python
zilliztech/deep-searcher
deepsearcher/embedding/fastembed_embdding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/fastembed_embdding.py
Apache-2.0
def dimension(self) -> int: """ Get the dimensionality of the embeddings. Returns: int: The number of dimensions in the embedding vectors. """ self._ensure_model_loaded() sample_embedding = self.embed_query("SAMPLE TEXT") return len(sample_embedding...
Get the dimensionality of the embeddings. Returns: int: The number of dimensions in the embedding vectors.
dimension
python
zilliztech/deep-searcher
deepsearcher/embedding/fastembed_embdding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/fastembed_embdding.py
Apache-2.0
def __init__(self, model: str = "text-embedding-004", **kwargs): """ Initialize the Gemini embedding model. Args: model (str): The model identifier to use for embeddings. Default is "text-embedding-004". **kwargs: Additional keyword arguments. - api_key (...
Initialize the Gemini embedding model. Args: model (str): The model identifier to use for embeddings. Default is "text-embedding-004". **kwargs: Additional keyword arguments. - api_key (str, optional): The Gemini API key. If not provided, it wi...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/gemini_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/gemini_embedding.py
Apache-2.0
def _embed_content(self, texts: List[str]): """ Embed a list of content texts. Args: texts (List[str]): A list of texts to embed. Returns: List: A list of embeddings corresponding to the input texts. """ from google.genai import types re...
Embed a list of content texts. Args: texts (List[str]): A list of texts to embed. Returns: List: A list of embeddings corresponding to the input texts.
_embed_content
python
zilliztech/deep-searcher
deepsearcher/embedding/gemini_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/gemini_embedding.py
Apache-2.0
def __init__(self, model: str = None, **kwargs) -> None: """ Initialize the Milvus embedding model. Args: model (str, optional): The model identifier to use for embeddings. If None, the default model will be used. **kwargs: Additional ke...
Initialize the Milvus embedding model. Args: model (str, optional): The model identifier to use for embeddings. If None, the default model will be used. **kwargs: Additional keyword arguments passed to the underlying embedding function. ...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/milvus_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/milvus_embedding.py
Apache-2.0
def embed_documents(self, texts: List[str]) -> List[List[float]]: """ Embed a list of document texts. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for each input text. Note: ...
Embed a list of document texts. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for each input text. Note: This method handles conversion from numpy arrays to lists if needed....
embed_documents
python
zilliztech/deep-searcher
deepsearcher/embedding/milvus_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/milvus_embedding.py
Apache-2.0
def __init__(self, model="baai/bge-m3", batch_size=32, **kwargs): """ Initialize the Novita AI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "baai/bge-m3". batch_size (int): Maximum number of texts to process in a single batch...
Initialize the Novita AI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "baai/bge-m3". batch_size (int): Maximum number of texts to process in a single batch. Default is 32. **kwargs: Additional keyword arguments. ...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/novita_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/novita_embedding.py
Apache-2.0
def embed_documents(self, texts: List[str]) -> List[List[float]]: """ Embed a list of document texts. This method handles batching of document embeddings based on the configured batch size to optimize API calls. Args: texts (List[str]): A list of document texts to e...
Embed a list of document texts. This method handles batching of document embeddings based on the configured batch size to optimize API calls. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding ve...
embed_documents
python
zilliztech/deep-searcher
deepsearcher/embedding/novita_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/novita_embedding.py
Apache-2.0
def _embed_input(self, input: Union[str, List[str]]) -> List[List[float]]: """ Internal method to handle the API call for embedding inputs. Args: input (Union[str, List[str]]): Either a single text string or a list of text strings to embed. Returns: List[List[fl...
Internal method to handle the API call for embedding inputs. Args: input (Union[str, List[str]]): Either a single text string or a list of text strings to embed. Returns: List[List[float]]: A list of embedding vectors for the input(s). Raises: HTTP...
_embed_input
python
zilliztech/deep-searcher
deepsearcher/embedding/novita_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/novita_embedding.py
Apache-2.0
def __init__(self, model="bge-m3", batch_size=32, **kwargs): """ Initialize the Ollama embedding model. Args: model (str): The model identifier to use for embeddings. Default is "bge-m3". **kwargs: Additional keyword arguments. - base_url (str, optional):...
Initialize the Ollama embedding model. Args: model (str): The model identifier to use for embeddings. Default is "bge-m3". **kwargs: Additional keyword arguments. - base_url (str, optional): The base URL for the Ollama API. If not provided, def...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/ollama_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/ollama_embedding.py
Apache-2.0
def __init__(self, model: str = "text-embedding-ada-002", **kwargs): """ Initialize the OpenAI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "text-embedding-ada-002". **kwargs: Additional keyword arguments. - a...
Initialize the OpenAI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "text-embedding-ada-002". **kwargs: Additional keyword arguments. - api_key (str, optional): The OpenAI API key. If not provided, i...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/openai_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/openai_embedding.py
Apache-2.0
def __init__(self, model="baai/bge-m3", batch_size=32, **kwargs): """ Initialize the PPIO embedding model. Args: model (str): The model identifier to use for embeddings. Default is "baai/bge-m3". batch_size (int): Maximum number of texts to process in a single batch. Def...
Initialize the PPIO embedding model. Args: model (str): The model identifier to use for embeddings. Default is "baai/bge-m3". batch_size (int): Maximum number of texts to process in a single batch. Default is 32. **kwargs: Additional keyword arguments. ...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/ppio_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/ppio_embedding.py
Apache-2.0
def __init__(self, model="BAAI/bge-m3", batch_size=32, **kwargs): """ Initialize the SentenceTransformer embedding model. Args: model (str): The model identifier to use for embeddings. Default is "BAAI/bge-m3". batch_size (int): Maximum number of texts to process in a si...
Initialize the SentenceTransformer embedding model. Args: model (str): The model identifier to use for embeddings. Default is "BAAI/bge-m3". batch_size (int): Maximum number of texts to process in a single batch. Default is 32. **kwargs: Additional keyword arguments...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/sentence_transformer_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/sentence_transformer_embedding.py
Apache-2.0
def __init__(self, model="BAAI/bge-m3", batch_size=32, **kwargs): """ Initialize the SiliconFlow embedding model. Args: model (str): The model identifier to use for embeddings. Default is "BAAI/bge-m3". batch_size (int): Maximum number of texts to process in a single bat...
Initialize the SiliconFlow embedding model. Args: model (str): The model identifier to use for embeddings. Default is "BAAI/bge-m3". batch_size (int): Maximum number of texts to process in a single batch. Default is 32. **kwargs: Additional keyword arguments. ...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/siliconflow_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/siliconflow_embedding.py
Apache-2.0
def __init__(self, model="doubao-embedding-large-text-240915", batch_size=256, **kwargs): """ Initialize the Volcengine embedding model. Args: model (str): The model identifier to use for embeddings. Default is "doubao-embedding-large-text-240915". batch_size (int): Maxi...
Initialize the Volcengine embedding model. Args: model (str): The model identifier to use for embeddings. Default is "doubao-embedding-large-text-240915". batch_size (int): Maximum number of texts to process in a single batch. Default is 256. **kwargs: Additional ke...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/volcengine_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/volcengine_embedding.py
Apache-2.0
def __init__(self, model="voyage-3", **kwargs): """ Initialize the Voyage AI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "voyage-3". **kwargs: Additional keyword arguments. - api_key (str, optional): The Voya...
Initialize the Voyage AI embedding model. Args: model (str): The model identifier to use for embeddings. Default is "voyage-3". **kwargs: Additional keyword arguments. - api_key (str, optional): The Voyage AI API key. If not provided, it will b...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/voyage_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/voyage_embedding.py
Apache-2.0
def __init__(self, model: str = "ibm/slate-125m-english-rtrvr-v2", **kwargs): """ Initialize the watsonx.ai embedding model. Args: model (str): The model identifier to use for embeddings. Default is "ibm/slate-125m-english-rtrvr-v2". **kwargs: Add...
Initialize the watsonx.ai embedding model. Args: model (str): The model identifier to use for embeddings. Default is "ibm/slate-125m-english-rtrvr-v2". **kwargs: Additional keyword arguments for WatsonX configuration. - url (str): WatsonX...
__init__
python
zilliztech/deep-searcher
deepsearcher/embedding/watsonx_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/watsonx_embedding.py
Apache-2.0
def _get_dim(self): """ Get the dimensionality of embeddings for the current model. Returns: int: The number of dimensions in the embedding vectors. """ # Common WatsonX embedding model dimensions model_dimensions = { "ibm/granite-embedding-278m-m...
Get the dimensionality of embeddings for the current model. Returns: int: The number of dimensions in the embedding vectors.
_get_dim
python
zilliztech/deep-searcher
deepsearcher/embedding/watsonx_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/watsonx_embedding.py
Apache-2.0
def _count_tokens(self, text: str) -> int: """ Count the number of tokens in the text. Args: text (str): The input text. Returns: int: The number of tokens. """ if self.use_tokenizer and self.tokenizer: return len(self.tokenizer.encod...
Count the number of tokens in the text. Args: text (str): The input text. Returns: int: The number of tokens.
_count_tokens
python
zilliztech/deep-searcher
deepsearcher/embedding/watsonx_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/watsonx_embedding.py
Apache-2.0
def _embed_documents_individually(self, texts: List[str]) -> List[List[float]]: """ Embed documents one by one, skipping problematic ones. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for...
Embed documents one by one, skipping problematic ones. Args: texts (List[str]): A list of document texts to embed. Returns: List[List[float]]: A list of embedding vectors, one for each input text.
_embed_documents_individually
python
zilliztech/deep-searcher
deepsearcher/embedding/watsonx_embedding.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/embedding/watsonx_embedding.py
Apache-2.0
def __init__(self, model: str = "deepseek-r1", **kwargs): """ Initialize an Aliyun language model client. Args: model (str, optional): The model identifier to use. Defaults to "deepseek-r1". **kwargs: Additional keyword arguments to pass to the OpenAI client. ...
Initialize an Aliyun language model client. Args: model (str, optional): The model identifier to use. Defaults to "deepseek-r1". **kwargs: Additional keyword arguments to pass to the OpenAI client. - api_key: Aliyun bailian API key. If not provided, uses DASHSCO...
__init__
python
zilliztech/deep-searcher
deepsearcher/llm/aliyun.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/aliyun.py
Apache-2.0
def chat(self, messages: List[Dict]) -> ChatResponse: """ Send a chat message to the Aliyun model and get a response. Args: messages (List[Dict]): A list of message dictionaries, typically in the format [{"role": "system", "content": "..."}, ...
Send a chat message to the Aliyun model and get a response. Args: messages (List[Dict]): A list of message dictionaries, typically in the format [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}] ...
chat
python
zilliztech/deep-searcher
deepsearcher/llm/aliyun.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/aliyun.py
Apache-2.0
def __init__(self, model: str = "claude-sonnet-4-0", max_tokens: int = 8192, **kwargs): """ Initialize an Anthropic language model client. Args: model (str, optional): The model identifier to use. Defaults to "claude-sonnet-4-0". max_tokens (int, optional): The maximum n...
Initialize an Anthropic language model client. Args: model (str, optional): The model identifier to use. Defaults to "claude-sonnet-4-0". max_tokens (int, optional): The maximum number of tokens to generate. Defaults to 8192. **kwargs: Additional keyword arguments t...
__init__
python
zilliztech/deep-searcher
deepsearcher/llm/anthropic_llm.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/anthropic_llm.py
Apache-2.0
def chat(self, messages: List[Dict]) -> ChatResponse: """ Send a chat message to the Anthropic model and get a response. Args: messages (List[Dict]): A list of message dictionaries, typically in the format [{"role": "system", "content": "..."}, ...
Send a chat message to the Anthropic model and get a response. Args: messages (List[Dict]): A list of message dictionaries, typically in the format [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}...
chat
python
zilliztech/deep-searcher
deepsearcher/llm/anthropic_llm.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/anthropic_llm.py
Apache-2.0
def __init__( self, model: str, azure_endpoint: str = None, api_key: str = None, api_version: str = None, **kwargs, ): """ Initialize the AzureOpenAI client. Args: model (str): The name of the model to use for chat completions. ...
Initialize the AzureOpenAI client. Args: model (str): The name of the model to use for chat completions. azure_endpoint (str, optional): The Azure OpenAI endpoint URL. If None, will use AZURE_OPENAI_ENDPOINT environment variable. api_key (str, optional): The API key...
__init__
python
zilliztech/deep-searcher
deepsearcher/llm/azure_openai.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/azure_openai.py
Apache-2.0
def chat(self, messages: List[Dict]) -> ChatResponse: """ Send a chat completion request to Azure OpenAI. Args: messages (List[Dict]): A list of message dictionaries in the format expected by the OpenAI API. Each message should have a 'role' and 'content' key. ...
Send a chat completion request to Azure OpenAI. Args: messages (List[Dict]): A list of message dictionaries in the format expected by the OpenAI API. Each message should have a 'role' and 'content' key. Returns: ChatResponse: An object containing the re...
chat
python
zilliztech/deep-searcher
deepsearcher/llm/azure_openai.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/azure_openai.py
Apache-2.0
def __init__(self, content: str, total_tokens: int) -> None: """ Initialize a ChatResponse object. Args: content: The text content of the response. total_tokens: The total number of tokens used in the request and response. """ self.content = content ...
Initialize a ChatResponse object. Args: content: The text content of the response. total_tokens: The total number of tokens used in the request and response.
__init__
python
zilliztech/deep-searcher
deepsearcher/llm/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/base.py
Apache-2.0
def literal_eval(response_content: str): """ Parse a string response into a Python object using ast.literal_eval. This method attempts to extract and parse JSON or Python literals from the response content, handling various formats like code blocks and special tags. Args: ...
Parse a string response into a Python object using ast.literal_eval. This method attempts to extract and parse JSON or Python literals from the response content, handling various formats like code blocks and special tags. Args: response_content: The string content to parse...
literal_eval
python
zilliztech/deep-searcher
deepsearcher/llm/base.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/base.py
Apache-2.0
def __init__( self, model: str = "us.deepseek.r1-v1:0", max_tokens: int = 20000, region_name: str = "us-west-2", **kwargs, ): """ Initialize an AWS Bedrock language model client. Args: model (str, optional): The model identifier to use. De...
Initialize an AWS Bedrock language model client. Args: model (str, optional): The model identifier to use. Defaults to "us.deepseek.r1-v1:0". max_tokens (int, optional): The maximum number of tokens to generate. Defaults to 2000. region_name (str, optional): AWS reg...
__init__
python
zilliztech/deep-searcher
deepsearcher/llm/bedrock.py
https://github.com/zilliztech/deep-searcher/blob/master/deepsearcher/llm/bedrock.py
Apache-2.0