nat.builder.builder#
Attributes#
Classes#
Helper class that provides a standard way to create an ABC using |
|
Abstract base class for evaluation builder functionality. |
Module Contents#
- _current_builder_context: contextvars.ContextVar[Builder | None]#
- class UserManagerHolder(context: nat.builder.context.Context)#
- _context#
- get_id()#
- class Builder#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- static current() Builder#
Get the Builder object from the current context.
- Returns:
The Builder object stored in the ContextVar, or raises ValueError if not set.
- property sync_builder: nat.builder.sync_builder.SyncBuilder#
- Abstractmethod:
Get the synchronous version of the builder.
- Returns:
The SyncBuilder object (synchronous wrapper).
- abstractmethod add_function(
- name: str | nat.data_models.component_ref.FunctionRef,
- config: nat.data_models.function.FunctionBaseConfig,
- Async:
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
- abstractmethod add_function_group(
- name: str | nat.data_models.component_ref.FunctionGroupRef,
- config: nat.data_models.function.FunctionGroupBaseConfig,
- Async:
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
- abstractmethod get_function( ) nat.builder.function.Function#
- Async:
Get a function by name.
- Args:
name: The name or reference of the function
- Returns:
The built function instance
- abstractmethod get_function_group( ) nat.builder.function.FunctionGroup#
- Async:
Get a function group by name.
- Args:
name: The name or reference of the function group
- Returns:
The built function group instance
- async get_functions(
- function_names: collections.abc.Sequence[str | nat.data_models.component_ref.FunctionRef],
Get multiple functions by name.
- Args:
function_names: The names or references of the functions
- Returns:
List of built function instances
- async get_function_groups(
- function_group_names: collections.abc.Sequence[str | nat.data_models.component_ref.FunctionGroupRef],
Get multiple function groups by name.
- Args:
function_group_names: The names or references of the function groups
- Returns:
List of built function group instances
- abstractmethod get_function_config( ) nat.data_models.function.FunctionBaseConfig#
Get the configuration for a function.
- Args:
name: The name or reference of the function
- Returns:
The configuration for the function
- abstractmethod get_function_group_config( ) nat.data_models.function.FunctionGroupBaseConfig#
Get the configuration for a function group.
- Args:
name: The name or reference of the function group
- Returns:
The configuration for the function group
- abstractmethod set_workflow( ) nat.builder.function.Function#
- Async:
Set the workflow function.
- Args:
config: The configuration for the workflow function
- Returns:
The built workflow function instance
- abstractmethod get_workflow() nat.builder.function.Function#
Get the workflow function.
- Returns:
The workflow function instance
- abstractmethod get_workflow_config() nat.data_models.function.FunctionBaseConfig#
Get the configuration for the workflow.
- Returns:
The configuration for the workflow function
- abstractmethod 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,
- Async:
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
- abstractmethod get_tool(
- fn_name: str | nat.data_models.component_ref.FunctionRef,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
- Async:
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
- abstractmethod add_llm(
- name: str | nat.data_models.component_ref.LLMRef,
- config: nat.data_models.llm.LLMBaseConfig,
- Async:
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
- abstractmethod get_llm(
- llm_name: str | nat.data_models.component_ref.LLMRef,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
- Async:
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
- async get_llms(
- llm_names: collections.abc.Sequence[str | nat.data_models.component_ref.LLMRef],
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get multiple LLMs by name wrapped in the specified framework type.
- Args:
llm_names: The names or references of the LLMs wrapper_type: The LLM framework type to wrap the LLMs in
- Returns:
List of LLMs wrapped in the specified framework type
- abstractmethod get_llm_config(
- llm_name: str | nat.data_models.component_ref.LLMRef,
Get the configuration for an LLM.
- Args:
llm_name: The name or reference of the LLM
- Returns:
The configuration for the LLM
- abstractmethod add_auth_provider(
- name: str | nat.data_models.component_ref.AuthenticationRef,
- config: nat.data_models.authentication.AuthProviderBaseConfig,
- Async:
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
- abstractmethod get_auth_provider(
- auth_provider_name: str | nat.data_models.component_ref.AuthenticationRef,
- Async:
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_auth_providers(
- auth_provider_names: list[str | nat.data_models.component_ref.AuthenticationRef],
Get multiple authentication providers by name.
- Args:
auth_provider_names: The names or references of the authentication providers
- Returns:
List of authentication provider instances
- abstractmethod add_object_store(
- name: str | nat.data_models.component_ref.ObjectStoreRef,
- config: nat.data_models.object_store.ObjectStoreBaseConfig,
- Async:
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_clients(
- object_store_names: collections.abc.Sequence[str | nat.data_models.component_ref.ObjectStoreRef],
Return a list of all object store clients.
- abstractmethod get_object_store_client(
- object_store_name: str | nat.data_models.component_ref.ObjectStoreRef,
- Async:
Get an object store client by name.
- Args:
object_store_name: The name or reference of the object store
- Returns:
The object store client instance
- abstractmethod get_object_store_config(
- object_store_name: str | nat.data_models.component_ref.ObjectStoreRef,
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
- abstractmethod add_embedder(
- name: str | nat.data_models.component_ref.EmbedderRef,
- config: nat.data_models.embedder.EmbedderBaseConfig,
- Async:
Add an embedder to the builder.
- Args:
name: The name or reference for the embedder config: The configuration for the embedder
- async get_embedders(
- embedder_names: collections.abc.Sequence[str | nat.data_models.component_ref.EmbedderRef],
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
Get multiple embedders by name wrapped in the specified framework type.
- Args:
embedder_names: The names or references of the embedders wrapper_type: The LLM framework type to wrap the embedders in
- Returns:
List of embedders wrapped in the specified framework type
- abstractmethod get_embedder(
- embedder_name: str | nat.data_models.component_ref.EmbedderRef,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
- Async:
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
- abstractmethod get_embedder_config(
- embedder_name: str | nat.data_models.component_ref.EmbedderRef,
Get the configuration for an embedder.
- Args:
embedder_name: The name or reference of the embedder
- Returns:
The configuration for the embedder
- abstractmethod add_memory_client(
- name: str | nat.data_models.component_ref.MemoryRef,
- config: nat.data_models.memory.MemoryBaseConfig,
- Async:
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_clients(
- memory_names: collections.abc.Sequence[str | nat.data_models.component_ref.MemoryRef],
Return a list of memory clients for the specified names.
- abstractmethod get_memory_client(
- memory_name: str | nat.data_models.component_ref.MemoryRef,
- Async:
Return the instantiated memory client for the given name.
- abstractmethod get_memory_client_config(
- memory_name: str | nat.data_models.component_ref.MemoryRef,
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
- abstractmethod add_retriever(
- name: str | nat.data_models.component_ref.RetrieverRef,
- config: nat.data_models.retriever.RetrieverBaseConfig,
- Async:
Add a retriever to the builder.
- Args:
name: The name or reference for the retriever config: The configuration for the retriever
- async get_retrievers(
- retriever_names: collections.abc.Sequence[str | nat.data_models.component_ref.RetrieverRef],
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str | None = None,
Get multiple retrievers by name.
- Args:
retriever_names: The names or references of the retrievers wrapper_type: Optional LLM framework type to wrap the retrievers in
- Returns:
List of retriever instances
- async get_retriever(
- retriever_name: str | nat.data_models.component_ref.RetrieverRef,
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
- async get_retriever(
- retriever_name: str | nat.data_models.component_ref.RetrieverRef,
- wrapper_type: None,
- async get_retriever(
- retriever_name: str | nat.data_models.component_ref.RetrieverRef,
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
- abstractmethod get_retriever_config(
- retriever_name: str | nat.data_models.component_ref.RetrieverRef,
- Async:
Get the configuration for a retriever.
- Args:
retriever_name: The name or reference of the retriever
- Returns:
The configuration for the retriever
- abstractmethod add_trainer(
- name: str | nat.data_models.component_ref.TrainerRef,
- config: nat.data_models.finetuning.TrainerConfig,
- Async:
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
- abstractmethod add_trainer_adapter(
- name: str | nat.data_models.component_ref.TrainerAdapterRef,
- config: nat.data_models.finetuning.TrainerAdapterConfig,
- Async:
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
- abstractmethod add_trajectory_builder(
- name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
- config: nat.data_models.finetuning.TrajectoryBuilderConfig,
- Async:
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
- abstractmethod 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,
- Async:
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
- abstractmethod get_trainer_adapter(
- trainer_adapter_name: str | nat.data_models.component_ref.TrainerAdapterRef,
- Async:
Get a trainer adapter by name.
- Args:
trainer_adapter_name: The name or reference of the trainer adapter
- Returns:
The trainer adapter instance
- abstractmethod get_trajectory_builder(
- trajectory_builder_name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
- Async:
Get a trajectory builder by name.
- Args:
trajectory_builder_name: The name or reference of the trajectory builder
- Returns:
The trajectory builder instance
- abstractmethod get_trainer_config(
- trainer_name: str | nat.data_models.component_ref.TrainerRef,
- Async:
Get the configuration for a trainer.
- Args:
trainer_name: The name or reference of the trainer
- Returns:
The configuration for the trainer
- abstractmethod get_trainer_adapter_config(
- trainer_adapter_name: str | nat.data_models.component_ref.TrainerAdapterRef,
- Async:
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
- abstractmethod get_trajectory_builder_config(
- trajectory_builder_name: str | nat.data_models.component_ref.TrajectoryBuilderRef,
- Async:
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
- abstractmethod add_ttc_strategy(
- name: str | nat.data_models.component_ref.TTCStrategyRef,
- config: nat.data_models.ttc_strategy.TTCStrategyBaseConfig,
- Async:
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
- abstractmethod 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,
- Async:
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
- abstractmethod 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,
- Async:
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
- abstractmethod get_user_manager() UserManagerHolder#
Get the user manager holder.
- Returns:
The user manager holder instance
- abstractmethod get_function_dependencies(
- fn_name: str,
Get the dependencies for a function.
- Args:
fn_name: The name of the function
- Returns:
The function dependencies
- abstractmethod 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
- abstractmethod add_middleware(
- name: str | nat.data_models.component_ref.MiddlewareRef,
- config: nat.data_models.middleware.MiddlewareBaseConfig,
- Async:
Add middleware to the builder.
- Args:
name: The name or reference for the middleware config: The configuration for the middleware
- Returns:
The built middleware instance
- abstractmethod get_middleware(
- middleware_name: str | nat.data_models.component_ref.MiddlewareRef,
- Async:
Get built middleware by name.
- Args:
middleware_name: The name or reference of the middleware
- Returns:
The built middleware instance
- abstractmethod get_middleware_config(
- middleware_name: str | nat.data_models.component_ref.MiddlewareRef,
Get the configuration for middleware.
- Args:
middleware_name: The name or reference of the middleware
- Returns:
The configuration for the middleware
- async get_middleware_list(
- middleware_names: collections.abc.Sequence[str | nat.data_models.component_ref.MiddlewareRef],
Get multiple middleware by name.
- Args:
middleware_names: The names or references of the middleware
- Returns:
List of built middleware instances
- class EvalBuilder#
Bases:
abc.ABCAbstract base class for evaluation builder functionality.
- abstractmethod add_evaluator(
- name: str,
- config: nat.data_models.evaluator.EvaluatorBaseConfig,
- Async:
Add an evaluator to the builder.
- Args:
name: The name for the evaluator config: The configuration for the evaluator
- abstractmethod get_evaluator(evaluator_name: str) Any#
Get an evaluator by name.
- Args:
evaluator_name: The name of the evaluator
- Returns:
The evaluator instance
- abstractmethod get_evaluator_config(
- evaluator_name: str,
Get the configuration for an evaluator.
- Args:
evaluator_name: The name of the evaluator
- Returns:
The configuration for the evaluator
- abstractmethod get_max_concurrency() int#
Get the maximum concurrency for evaluation.
- Returns:
The maximum concurrency value
- abstractmethod get_output_dir() pathlib.Path#
Get the output directory for evaluation results.
- Returns:
The output directory path
- abstractmethod get_all_tools(
- wrapper_type: nat.builder.framework_enum.LLMFrameworkEnum | str,
- Async:
Get all tools wrapped in the specified framework type.
- Args:
wrapper_type: The LLM framework type to wrap the tools in
- Returns:
List of all tools wrapped in the specified framework type