nat.builder.child_builder#
Classes#
Helper class that provides a standard way to create an ABC using |
Module Contents#
- class ChildBuilder(workflow_builder: nat.builder.builder.Builder)#
Bases:
nat.builder.builder.BuilderHelper class that provides a standard way to create an ABC using inheritance.
- _workflow_builder#
- _dependencies#
- property sync_builder: nat.builder.sync_builder.SyncBuilder#
Get the synchronous version of the builder.
- Returns:
The SyncBuilder object (synchronous wrapper).
- property dependencies: nat.data_models.function_dependencies.FunctionDependencies#
- async add_function(
- name: str,
- config: nat.data_models.function.FunctionBaseConfig,
Add a function to the builder.
- Args:
name: The name or reference for the function config: The configuration for the function
- Returns:
The built function instance
- async add_function_group(
- name: str,
- config: nat.data_models.function.FunctionGroupBaseConfig,
Add a function group to the builder.
- Args:
name: The name or reference for the function group config: The configuration for the function group
- Returns:
The built function group instance
- async get_function(name: str) nat.builder.function.Function#
Get a function by name.
- Args:
name: The name or reference of the function
- Returns:
The built function instance
- async get_function_group(name: str) nat.builder.function.FunctionGroup#
Get a function group by name.
- Args:
name: The name or reference of the function group
- Returns:
The built function group instance
- get_function_config(
- name: str,
Get the configuration for a function.
- Args:
name: The name or reference of the function
- Returns:
The configuration for the function
- get_function_group_config(
- name: str,
Get the configuration for a function group.
- Args:
name: The name or reference of the function group
- Returns:
The configuration for the function group
- async set_workflow( ) nat.builder.function.Function#
Set the workflow function.
- Args:
config: The configuration for the workflow function
- Returns:
The built workflow function instance
- get_workflow() nat.builder.function.Function#
Get the workflow function.
- Returns:
The workflow function instance
- get_workflow_config() nat.data_models.function.FunctionBaseConfig#
Get the configuration for the workflow.
- Returns:
The configuration for the workflow function
- async get_tools(
- tool_names: collections.abc.Sequence[str | nat.data_models.component_ref.FunctionRef | nat.data_models.component_ref.FunctionGroupRef],
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get multiple tools by name wrapped in the specified framework type.
- Args:
tool_names: The names or references of the tools (functions or function groups) wrapper_type: The LLM framework type to wrap the tools in
- Returns:
List of tools wrapped in the specified framework type
- async get_tool(
- fn_name: str | nat.data_models.component_ref.FunctionRef,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get a tool by name wrapped in the specified framework type.
- Args:
fn_name: The name or reference of the tool (function) wrapper_type: The LLM framework type to wrap the tool in
- Returns:
The tool wrapped in the specified framework type
- async add_llm(name: str, config: nat.data_models.llm.LLMBaseConfig) None#
Add an LLM to the builder.
- Args:
name: The name or reference for the LLM config: The configuration for the LLM
- Returns:
The built LLM instance
- async add_auth_provider(
- name: str,
- config: nat.data_models.authentication.AuthProviderBaseConfig,
Add an authentication provider to the builder.
- Args:
name: The name or reference for the authentication provider config: The configuration for the authentication provider
- Returns:
The built authentication provider instance
- async get_auth_provider(auth_provider_name: str)#
Get an authentication provider by name.
- Args:
auth_provider_name: The name or reference of the authentication provider
- Returns:
The authentication provider instance
- async get_llm(
- llm_name: str,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get an LLM by name wrapped in the specified framework type.
- Args:
llm_name: The name or reference of the LLM wrapper_type: The LLM framework type to wrap the LLM in
- Returns:
The LLM wrapped in the specified framework type
- get_llm_config(llm_name: str) nat.data_models.llm.LLMBaseConfig#
Get the configuration for an LLM.
- Args:
llm_name: The name or reference of the LLM
- Returns:
The configuration for the LLM
- async add_embedder(
- name: str,
- config: nat.data_models.embedder.EmbedderBaseConfig,
Add an embedder to the builder.
- Args:
name: The name or reference for the embedder config: The configuration for the embedder
- async get_embedder(
- embedder_name: str,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get an embedder by name wrapped in the specified framework type.
- Args:
embedder_name: The name or reference of the embedder wrapper_type: The LLM framework type to wrap the embedder in
- Returns:
The embedder wrapped in the specified framework type
- get_embedder_config(
- embedder_name: str,
Get the configuration for an embedder.
- Args:
embedder_name: The name or reference of the embedder
- Returns:
The configuration for the embedder
- async add_memory_client(
- name: str,
- config: nat.data_models.memory.MemoryBaseConfig,
Add a memory client to the builder.
- Args:
name: The name or reference for the memory client config: The configuration for the memory client
- Returns:
The built memory client instance
- async get_memory_client(
- memory_name: str,
Return the instantiated memory client for the given name.
- get_memory_client_config(
- memory_name: str,
Get the configuration for a memory client.
- Args:
memory_name: The name or reference of the memory client
- Returns:
The configuration for the memory client
- async add_object_store(
- name: str,
- config: nat.data_models.object_store.ObjectStoreBaseConfig,
Add an object store to the builder.
- Args:
name: The name or reference for the object store config: The configuration for the object store
- Returns:
The built object store instance
- async get_object_store_client(
- object_store_name: str,
Return the instantiated object store client for the given name.
- get_object_store_config(
- object_store_name: str,
Get the configuration for an object store.
- Args:
object_store_name: The name or reference of the object store
- Returns:
The configuration for the object store
- async add_trainer(
- name: str | nat.data_models.component_ref.TrainerRef,
- config: nat.data_models.finetuning.TrainerConfig,
Add a trainer to the builder.
- Args:
name: The name or reference for the trainer config: The configuration for the trainer
- Returns:
The built trainer instance
- async add_trainer_adapter(
- name: str | nat.data_models.component_ref.TrainerAdapterRef,
- config: nat.data_models.finetuning.TrainerAdapterConfig,
Add a trainer adapter to the builder.
- Args:
name: The name or reference for the trainer adapter config: The configuration for the trainer adapter
- Returns:
The built trainer adapter instance
- async add_trajectory_builder(
- name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
- config: nat.data_models.finetuning.TrajectoryBuilderConfig,
Add a trajectory builder to the builder.
- Args:
name: The name or reference for the trajectory builder config: The configuration for the trajectory builder
- Returns:
The built trajectory builder instance
- async get_trainer(
- trainer_name: str | nat.data_models.component_ref.TrainerRef,
- trajectory_builder: nat.finetuning.interfaces.trajectory_builder.TrajectoryBuilder,
- trainer_adapter: nat.finetuning.interfaces.trainer_adapter.TrainerAdapter,
Get a trainer by name with the specified trajectory builder and trainer adapter.
- Args:
trainer_name: The name or reference of the trainer trajectory_builder: The trajectory builder instance trainer_adapter: The trainer adapter instance
- Returns:
The trainer instance
- async get_trainer_config(
- trainer_name: str | nat.data_models.component_ref.TrainerRef,
Get the configuration for a trainer.
- Args:
trainer_name: The name or reference of the trainer
- Returns:
The configuration for the trainer
- async get_trainer_adapter_config(
- trainer_adapter_name: str | nat.data_models.component_ref.TrainerAdapterRef,
Get the configuration for a trainer adapter.
- Args:
trainer_adapter_name: The name or reference of the trainer adapter
- Returns:
The configuration for the trainer adapter
- async get_trajectory_builder_config(
- trajectory_builder_name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
Get the configuration for a trajectory builder.
- Args:
trajectory_builder_name: The name or reference of the trajectory builder
- Returns:
The configuration for the trajectory builder
- async get_trainer_adapter(
- trainer_adapter_name: str | nat.data_models.component_ref.TrainerAdapterRef,
Get a trainer adapter by name.
- Args:
trainer_adapter_name: The name or reference of the trainer adapter
- Returns:
The trainer adapter instance
- async get_trajectory_builder(
- trajectory_builder_name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
Get a trajectory builder by name.
- Args:
trajectory_builder_name: The name or reference of the trajectory builder
- Returns:
The trajectory builder instance
- async add_ttc_strategy(
- name: str,
- config: nat.data_models.ttc_strategy.TTCStrategyBaseConfig,
Add a test-time compute strategy to the builder.
- Args:
name: The name or reference for the TTC strategy config: The configuration for the TTC strategy
- async get_ttc_strategy(
- strategy_name: str | nat.data_models.component_ref.TTCStrategyRef,
- pipeline_type: nat.experimental.test_time_compute.models.stage_enums.PipelineTypeEnum,
- stage_type: nat.experimental.test_time_compute.models.stage_enums.StageTypeEnum,
Get a test-time compute strategy by name.
- Args:
strategy_name: The name or reference of the TTC strategy pipeline_type: The pipeline type for the strategy stage_type: The stage type for the strategy
- Returns:
The TTC strategy instance
- async get_ttc_strategy_config(
- strategy_name: str | nat.data_models.component_ref.TTCStrategyRef,
- pipeline_type: nat.experimental.test_time_compute.models.stage_enums.PipelineTypeEnum,
- stage_type: nat.experimental.test_time_compute.models.stage_enums.StageTypeEnum,
Get the configuration for a test-time compute strategy.
- Args:
strategy_name: The name or reference of the TTC strategy pipeline_type: The pipeline type for the strategy stage_type: The stage type for the strategy
- Returns:
The configuration for the TTC strategy
- async add_retriever(
- name: str,
- config: nat.data_models.retriever.RetrieverBaseConfig,
Add a retriever to the builder.
- Args:
name: The name or reference for the retriever config: The configuration for the retriever
- async get_retriever(
- retriever_name: str,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str | None = None,
Get a retriever by name.
- Args:
retriever_name: The name or reference of the retriever wrapper_type: Optional LLM framework type to wrap the retriever in
- Returns:
The retriever instance, optionally wrapped in the specified framework type
- async get_retriever_config(
- retriever_name: str,
Get the configuration for a retriever.
- Args:
retriever_name: The name or reference of the retriever
- Returns:
The configuration for the retriever
- get_user_manager() nat.builder.builder.UserManagerHolder#
Get the user manager holder.
- Returns:
The user manager holder instance
- get_function_dependencies(
- fn_name: str,
Get the dependencies for a function.
- Args:
fn_name: The name of the function
- Returns:
The function dependencies
- get_function_group_dependencies(
- fn_name: str,
Get the dependencies for a function group.
- Args:
fn_name: The name of the function group
- Returns:
The function group dependencies
- async add_middleware(
- name: str | nat.data_models.component_ref.MiddlewareRef,
- config: nat.data_models.middleware.MiddlewareBaseConfig,
Add middleware to the builder.
- async get_middleware(
- middleware_name: str | nat.data_models.component_ref.MiddlewareRef,
Get built middleware by name.
- get_middleware_config(
- middleware_name: str | nat.data_models.component_ref.MiddlewareRef,
Get the configuration for middleware.
- static use(
- config: nat.data_models.common.TypedBaseModel,
- builder: nat.builder.builder.Builder,
Context manager for temporarily setting the Builder object.
Parameters#
- configTypedBaseModel
The configuration to use within the context. Note: Not used for now, but required by the interface and will be used in the future.
- builderBuilder
The Builder instance to use within the context.
Yields#
- ChildBuilder
The Builder instance that was set.
Examples#
>>> with ChildBuilder.use(config, my_builder) as builder: ... # builder is active in this context ... assert Builder.current() == builder >>> # Original builder is restored here