Models
Models (llm_configs) exporter.
ModelsExporter ¶
ModelsExporter(
flow_name: str,
agents: list[WaldiezAgent],
agent_names: dict[str, str],
models: list[WaldiezModel],
model_names: dict[str, str],
for_notebook: bool = False,
cache_seed: Optional[int] = None,
output_dir: Optional[Union[str, Path]] = None,
context: Optional[ExporterContext] = None,
**kwargs: Any
)
Bases: Exporter[ModelExtras]
Mdels exporter with structured extras.Source code in
waldiez/exporting/models/exporter.py
generate_main_content ¶
Generate the main models content (LLM configs).
Returns:
Type | Description |
---|---|
Optional[str] | The main content string, or None if no content is available. |
Source code in waldiez/exporting/models/exporter.py
get_agent_llm_config_arg ¶
get_agent_llm_config_arg(agent: WaldiezAgent) -> str
Get LLM config argument for agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent | WaldiezAgent | The agent for which to get the LLM config argument. | required |
Returns:
Type | Description |
---|---|
str | The LLM config argument string for the agent, or "llm_config=False" if no models are configured. |
Source code in waldiez/exporting/models/exporter.py
get_api_key_loader_script ¶
get_api_key_loader_script() -> str
Get the api key loader script.
Returns:
Type | Description |
---|---|
str | The api key loader script. |
Source code in waldiez/exporting/models/exporter.py
create_models_exporter ¶
create_models_exporter(
flow_name: str,
agents: list[WaldiezAgent],
agent_names: dict[str, str],
models: list[WaldiezModel],
model_names: dict[str, str],
for_notebook: bool = False,
cache_seed: Optional[int] = None,
output_dir: Optional[Union[str, Path]] = None,
context: Optional[ExporterContext] = None,
) -> ModelsExporter
Create a models exporter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow_name | str | The name of the flow. | required |
agents | list[WaldiezAgent] | The agents that use models. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | list[WaldiezModel] | The models to export. | required |
model_names | dict[str, str] | Mapping of model IDs to names. | required |
for_notebook | bool | Whether the export is for a notebook, by default False | False |
cache_seed | Optional[int] | The cache seed if any, by default None | None |
output_dir | Optional[Union[str, Path]] | Output directory for generated files, by default None | None |
context | Optional[ExporterContext] | Exporter context with dependencies, by default None | None |
Returns:
Type | Description |
---|---|
ModelsExporter | The created models exporter. |
Source code in waldiez/exporting/models/factory.py
exporter ¶
Models exporter module.
ModelsExporter ¶
ModelsExporter(
flow_name: str,
agents: list[WaldiezAgent],
agent_names: dict[str, str],
models: list[WaldiezModel],
model_names: dict[str, str],
for_notebook: bool = False,
cache_seed: Optional[int] = None,
output_dir: Optional[Union[str, Path]] = None,
context: Optional[ExporterContext] = None,
**kwargs: Any
)
Bases: Exporter[ModelExtras]
Mdels exporter with structured extras.Source code in
waldiez/exporting/models/exporter.py
generate_main_content ¶
Generate the main models content (LLM configs).
Returns:
Type | Description |
---|---|
Optional[str] | The main content string, or None if no content is available. |
Source code in waldiez/exporting/models/exporter.py
get_agent_llm_config_arg ¶
get_agent_llm_config_arg(agent: WaldiezAgent) -> str
Get LLM config argument for agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent | WaldiezAgent | The agent for which to get the LLM config argument. | required |
Returns:
Type | Description |
---|---|
str | The LLM config argument string for the agent, or "llm_config=False" if no models are configured. |
Source code in waldiez/exporting/models/exporter.py
get_api_key_loader_script ¶
get_api_key_loader_script() -> str
Get the api key loader script.
Returns:
Type | Description |
---|---|
str | The api key loader script. |
Source code in waldiez/exporting/models/exporter.py
factory ¶
Factory function for creating a ModelsExporter instance.
create_models_exporter ¶
create_models_exporter(
flow_name: str,
agents: list[WaldiezAgent],
agent_names: dict[str, str],
models: list[WaldiezModel],
model_names: dict[str, str],
for_notebook: bool = False,
cache_seed: Optional[int] = None,
output_dir: Optional[Union[str, Path]] = None,
context: Optional[ExporterContext] = None,
) -> ModelsExporter
Create a models exporter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow_name | str | The name of the flow. | required |
agents | list[WaldiezAgent] | The agents that use models. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | list[WaldiezModel] | The models to export. | required |
model_names | dict[str, str] | Mapping of model IDs to names. | required |
for_notebook | bool | Whether the export is for a notebook, by default False | False |
cache_seed | Optional[int] | The cache seed if any, by default None | None |
output_dir | Optional[Union[str, Path]] | Output directory for generated files, by default None | None |
context | Optional[ExporterContext] | Exporter context with dependencies, by default None | None |
Returns:
Type | Description |
---|---|
ModelsExporter | The created models exporter. |
Source code in waldiez/exporting/models/factory.py
processor ¶
Model exporting utilities for Waldiez.
ModelProcessingResult dataclass
¶
ModelProcessingResult(
llm_configs_content: str = "",
api_keys_file: Optional[Path] = None,
needs_api_key_loader: bool = False,
)
Result from processing models.
ModelProcessor ¶
ModelProcessor(
flow_name: str,
models: list[WaldiezModel],
model_names: dict[str, str],
serializer: Optional[Serializer] = None,
output_dir: Optional[Path] = None,
)
Model processor for generating LLM configs and API key loading.Source code in
waldiez/exporting/models/processor.py
process ¶
process() -> str
Process the flow models.
Returns:
Type | Description |
---|---|
str | The string representation of all models' LLM configs. |