Agents
Agent exporter.
AgentExporter ¶
AgentExporter(
agent: WaldiezAgent,
agent_names: dict[str, str],
models: tuple[list[WaldiezModel], dict[str, str]],
chats: tuple[list[WaldiezChat], dict[str, str]],
tool_names: dict[str, str],
is_async: bool = False,
for_notebook: bool = False,
cache_seed: int | None = None,
initial_chats: (
list[WaldiezAgentConnection] | None
) = None,
group_chat_members: list[WaldiezAgent] | None = None,
arguments_resolver: (
Callable[[WaldiezAgent], list[str]] | None
) = None,
output_dir: str | Path | None = None,
context: ExporterContext | None = None,
**kwargs: Any
)
Bases: Exporter[StandardExtras]
Agent exporter with standard extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent to export. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | tuple[list[WaldiezModel], dict[str, str]] | All models and model names mapping. | required |
chats | tuple[list[WaldiezChat], dict[str, str]] | All chats and chat names mapping. | required |
tool_names | dict[str, str] | Mapping of tool IDs to names. | required |
is_async | bool | Whether the flow is async, by default False | False |
for_notebook | bool | Whether exporting for notebook, by default False | False |
cache_seed | int | Cache seed if any, by default None | None |
initial_chats | list[WaldiezAgentConnection] | Initial chats for group managers, by default None | None |
group_chat_members | list[WaldiezAgent] | Group chat members if group manager, by default None | None |
arguments_resolver | Callable | Function to resolve additional arguments, by default None | None |
output_dir | str | Path | Output directory for generated files, by default None | None |
context | ExporterContext | Exporter context with dependencies, by default None | None |
**kwargs | Any | Additional keyword arguments. | {} |
Source code in waldiez/exporting/agent/exporter.py
create_reasoning_extras ¶
create_reasoning_extras() -> StandardExtras
Create reasoning-specific extras for the agent.
Returns:
| Type | Description |
|---|---|
StandardExtras | The reasoning-specific extras. |
Source code in waldiez/exporting/agent/exporter.py
generate_main_content ¶
generate_main_content() -> str | None
Generate the main agent definition.
Returns:
| Type | Description |
|---|---|
Optional[str] | The main agent definition content, or None if not applicable. |
Source code in waldiez/exporting/agent/exporter.py
code_execution ¶
Code execution processor for Waldiez agents.
CodeExecutionProcessor ¶
CodeExecutionProcessor(
agent: WaldiezAgent,
agent_name: str,
tool_names: dict[str, str],
)
Processor for code execution configuration.
process ¶
process() -> CodeExecutionConfig
Process code execution configuration.
Returns:
| Type | Description |
|---|---|
CodeExecutionConfig | The processed code execution configuration. |
Source code in waldiez/exporting/agent/code_execution.py
create_agent_exporter ¶
create_agent_exporter(
agent: WaldiezAgent,
agent_names: dict[str, str],
models: tuple[list[WaldiezModel], dict[str, str]],
chats: tuple[list[WaldiezChat], dict[str, str]],
tool_names: dict[str, str],
initial_chats: list[WaldiezAgentConnection],
is_async: bool = False,
for_notebook: bool = False,
cache_seed: int | None = None,
group_chat_members: list[WaldiezAgent] | None = None,
arguments_resolver: (
Callable[[WaldiezAgent], list[str]] | None
) = None,
output_dir: str | Path | None = None,
context: ExporterContext | None = None,
**kwargs: Any
) -> AgentExporter
Create an agent exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent to export. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | tuple[list[WaldiezModel], dict[str, str]] | All models and model names mapping. | required |
chats | tuple[list[WaldiezChat], dict[str, str]] | All chats and chat names mapping. | required |
tool_names | dict[str, str] | Mapping of tool IDs to names. | required |
is_async | bool | Whether the flow is async, by default False | False |
for_notebook | bool | Whether exporting for notebook, by default False | False |
cache_seed | Optional[int] | Cache seed if any, by default None | None |
initial_chats | list[WaldiezAgentConnection] | Initial chats for group managers, by default None | required |
group_chat_members | list[WaldiezAgent] | Group chat members if group manager, by default None | None |
arguments_resolver | Callable | Function to resolve additional arguments, by default None | None |
output_dir | str | Path | None | Output directory for generated files, by default None | None |
context | ExporterContext | None | Exporter context with dependencies, by default None | None |
**kwargs | Any | Additional keyword arguments. | {} |
Returns:
| Type | Description |
|---|---|
AgentExporter | The created agent exporter. |
Source code in waldiez/exporting/agent/factory.py
exporter ¶
Export agents.
AgentExporter ¶
AgentExporter(
agent: WaldiezAgent,
agent_names: dict[str, str],
models: tuple[list[WaldiezModel], dict[str, str]],
chats: tuple[list[WaldiezChat], dict[str, str]],
tool_names: dict[str, str],
is_async: bool = False,
for_notebook: bool = False,
cache_seed: int | None = None,
initial_chats: (
list[WaldiezAgentConnection] | None
) = None,
group_chat_members: list[WaldiezAgent] | None = None,
arguments_resolver: (
Callable[[WaldiezAgent], list[str]] | None
) = None,
output_dir: str | Path | None = None,
context: ExporterContext | None = None,
**kwargs: Any
)
Bases: Exporter[StandardExtras]
Agent exporter with standard extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent to export. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | tuple[list[WaldiezModel], dict[str, str]] | All models and model names mapping. | required |
chats | tuple[list[WaldiezChat], dict[str, str]] | All chats and chat names mapping. | required |
tool_names | dict[str, str] | Mapping of tool IDs to names. | required |
is_async | bool | Whether the flow is async, by default False | False |
for_notebook | bool | Whether exporting for notebook, by default False | False |
cache_seed | int | Cache seed if any, by default None | None |
initial_chats | list[WaldiezAgentConnection] | Initial chats for group managers, by default None | None |
group_chat_members | list[WaldiezAgent] | Group chat members if group manager, by default None | None |
arguments_resolver | Callable | Function to resolve additional arguments, by default None | None |
output_dir | str | Path | Output directory for generated files, by default None | None |
context | ExporterContext | Exporter context with dependencies, by default None | None |
**kwargs | Any | Additional keyword arguments. | {} |
Source code in waldiez/exporting/agent/exporter.py
create_reasoning_extras ¶
create_reasoning_extras() -> StandardExtras
Create reasoning-specific extras for the agent.
Returns:
| Type | Description |
|---|---|
StandardExtras | The reasoning-specific extras. |
Source code in waldiez/exporting/agent/exporter.py
generate_main_content ¶
generate_main_content() -> str | None
Generate the main agent definition.
Returns:
| Type | Description |
|---|---|
Optional[str] | The main agent definition content, or None if not applicable. |
Source code in waldiez/exporting/agent/exporter.py
fallback_args_resolver ¶
fallback_args_resolver(agent: WaldiezAgent) -> list[str]
Fallback resolver for agent arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent for which to resolve arguments. | required |
Returns:
| Type | Description |
|---|---|
list[str] | An empty list (no extra args). |
Source code in waldiez/exporting/agent/exporter.py
extras ¶
Agents exporter extras.
CaptainAgentProcessor ¶
CaptainAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
all_models: list[WaldiezModel],
serializer: Serializer | None = None,
output_dir: Path | None = None,
)
Processor for captain agent configuration.Source code in
waldiez/exporting/agent/extras/captain_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> CaptainExtras
Process group manager and return extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, by default None. | None |
termination_config | TerminationConfig | Configuration for termination, by default None. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, by default None. | None |
Returns:
| Type | Description |
|---|---|
CaptainExtras | The processed result containing extra arguments, before content, imports, and environment variables. |
Source code in waldiez/exporting/agent/extras/captain_agent_extras.py
DocAgentProcessor ¶
DocAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
model_names: dict[str, str],
all_models: list[WaldiezModel],
cache_seed: int | None = None,
serializer: Serializer | None = None,
path_resolver: PathResolver | None = None,
output_dir: Path | None = None,
)
Process document agent requests.Source code in
waldiez/exporting/agent/extras/doc_agent_extras.py
get_db_path ¶
get_db_path() -> str
Get the database path for the document agent.
Returns:
| Type | Description |
|---|---|
str | The database path for the document agent. |
Raises:
| Type | Description |
|---|---|
TypeError | If the agent is not a WaldiezDocAgent instance. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_in_memory_query_engine_extras ¶
Get the in-memory query engine extras.Source code in
waldiez/exporting/agent/extras/doc_agent_extras.py
get_llm_arg ¶
Get the LLM argument for the agent and any content before it.
Returns:
| Type | Description |
|---|---|
str | The LLM argument for the agent and any content before it. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_parsed_docs_path ¶
get_parsed_docs_path() -> str
Get the parsed documents path for the document agent.
Returns:
| Type | Description |
|---|---|
str | The parsed documents path for the document agent. |
Raises:
| Type | Description |
|---|---|
TypeError | If the agent is not a WaldiezDocAgent instance. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_vector_chroma_citation_query_engine_extras ¶
get_vector_chroma_citation_query_engine_extras(
query_engine: WaldiezDocAgentQueryEngine,
collection_name: str,
) -> None
Get the vector Chroma citation query engine extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_engine | WaldiezDocAgentQueryEngine | The vector Chroma citation query engine to process. | required |
collection_name | str | The name of the collection to use. | required |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_vector_chroma_query_engine_extras ¶
get_vector_chroma_query_engine_extras(
collection_name: str,
) -> None
Get the vector Chroma query engine extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_name | str | The name of the collection to use. | required |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> StandardExtras
Process the document agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, if applicable. | None |
termination_config | TerminationConfig | Configuration for termination, if applicable. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, if applicable. | None |
Returns:
| Type | Description |
|---|---|
DocExtras | The document agent extras. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
GroupManagerProcessor ¶
GroupManagerProcessor(
agent: WaldiezAgent,
initial_chats: list[WaldiezAgentConnection],
group_chat_members: list[WaldiezAgent],
agent_names: dict[str, str],
model_names: dict[str, str],
all_models: list[WaldiezModel],
serializer: Callable[..., str],
cache_seed: int | None = None,
strategy: GroupManagerStrategy | None = None,
)
Processes group manager configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The group manager agent to process. | required |
initial_chats | list[WaldiezAgentConnection] | The initial chats to process for the group manager. | required |
group_chat_members | list[WaldiezAgent] | The members of the group chat. | required |
agent_names | dict[str, str] | Mapping of agent IDs to their names. | required |
model_names | dict[str, str] | Mapping of model IDs to their names. | required |
all_models | list[WaldiezModel] | List of all models available for the agent. | required |
serializer | Callable[..., str] | Function to serialize data into a string format. | required |
cache_seed | Optional[int] | Seed for caching purposes, by default None. | None |
strategy | Optional[GroupManagerStrategy] | Optional strategy to force (pattern based or traditional) | None |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
is_pattern_strategy staticmethod ¶
Check if the group manager should use pattern strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_chats | list[WaldiezAgentConnection] | The initial chats to determine the strategy. | required |
Returns:
| Type | Description |
|---|---|
bool | True if pattern strategy should be used, False otherwise. |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> GroupManagerExtras
Process group manager and return extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, by default None. | None |
termination_config | TerminationConfig | Configuration for termination, by default None. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, by default None. | None |
Returns:
| Type | Description |
|---|---|
GroupManagerExtras | The processed group manager extras containing configuration. |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
GroupMemberAgentProcessor ¶
GroupMemberAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
tool_names: dict[str, str],
all_chats: list[WaldiezChat],
chat_names: dict[str, str],
serializer: Callable[..., str],
)
Processor for group member agent configuration.Source code in
waldiez/exporting/agent/extras/group_member_extras.py
process ¶
process() -> GroupMemberProcessorResult
Process group member agent configuration.
Returns:
| Type | Description |
|---|---|
GroupMemberProcessorResult | The processed result containing before_agent code, after_agent code, and extra imports. |
Source code in waldiez/exporting/agent/extras/group_member_extras.py
ReasoningAgentProcessor ¶
ReasoningAgentProcessor(
agent: WaldiezAgent, serializer: Serializer | None
)
Processor for reasoning agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The Waldiez agent to process. | required |
serializer | Serializer | None | Optional serializer for the reasoning configuration. Defaults to DefaultSerializer if not provided. | required |
Source code in waldiez/exporting/agent/extras/reasoning_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> ReasoningExtras
Process reasoning agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, if applicable. | None |
termination_config | TerminationConfig | Configuration for termination, if applicable. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, if applicable. | None |
Returns:
| Type | Description |
|---|---|
ReasoningExtras | The processed result containing extra arguments, before content, imports, and environment variables. |
Source code in waldiez/exporting/agent/extras/reasoning_agent_extras.py
captain_agent_extras ¶
Captain agent configuration processor.
CaptainAgentProcessor ¶
CaptainAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
all_models: list[WaldiezModel],
serializer: Serializer | None = None,
output_dir: Path | None = None,
)
Processor for captain agent configuration.Source code in
waldiez/exporting/agent/extras/captain_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> CaptainExtras
Process group manager and return extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, by default None. | None |
termination_config | TerminationConfig | Configuration for termination, by default None. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, by default None. | None |
Returns:
| Type | Description |
|---|---|
CaptainExtras | The processed result containing extra arguments, before content, imports, and environment variables. |
Source code in waldiez/exporting/agent/extras/captain_agent_extras.py
doc_agent_extras ¶
Document Agent Extras.
DocAgentProcessor ¶
DocAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
model_names: dict[str, str],
all_models: list[WaldiezModel],
cache_seed: int | None = None,
serializer: Serializer | None = None,
path_resolver: PathResolver | None = None,
output_dir: Path | None = None,
)
Process document agent requests.Source code in
waldiez/exporting/agent/extras/doc_agent_extras.py
get_db_path ¶
get_db_path() -> str
Get the database path for the document agent.
Returns:
| Type | Description |
|---|---|
str | The database path for the document agent. |
Raises:
| Type | Description |
|---|---|
TypeError | If the agent is not a WaldiezDocAgent instance. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_in_memory_query_engine_extras ¶
Get the in-memory query engine extras.Source code in
waldiez/exporting/agent/extras/doc_agent_extras.py
get_llm_arg ¶
Get the LLM argument for the agent and any content before it.
Returns:
| Type | Description |
|---|---|
str | The LLM argument for the agent and any content before it. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_parsed_docs_path ¶
get_parsed_docs_path() -> str
Get the parsed documents path for the document agent.
Returns:
| Type | Description |
|---|---|
str | The parsed documents path for the document agent. |
Raises:
| Type | Description |
|---|---|
TypeError | If the agent is not a WaldiezDocAgent instance. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_vector_chroma_citation_query_engine_extras ¶
get_vector_chroma_citation_query_engine_extras(
query_engine: WaldiezDocAgentQueryEngine,
collection_name: str,
) -> None
Get the vector Chroma citation query engine extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_engine | WaldiezDocAgentQueryEngine | The vector Chroma citation query engine to process. | required |
collection_name | str | The name of the collection to use. | required |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_vector_chroma_query_engine_extras ¶
get_vector_chroma_query_engine_extras(
collection_name: str,
) -> None
Get the vector Chroma query engine extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_name | str | The name of the collection to use. | required |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> StandardExtras
Process the document agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, if applicable. | None |
termination_config | TerminationConfig | Configuration for termination, if applicable. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, if applicable. | None |
Returns:
| Type | Description |
|---|---|
DocExtras | The document agent extras. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
get_agent_model ¶
get_agent_model(
agent: WaldiezAgent, all_models: list[WaldiezModel]
) -> WaldiezModel | None
Get the first model of the agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent. | required |
all_models | list[WaldiezModel] | All the models in the flow. | required |
Returns:
| Type | Description |
|---|---|
WaldiezModel | None | The first model of the agent, or None if not found. |
Source code in waldiez/exporting/agent/extras/doc_agent_extras.py
group_manager_agent_extas ¶
Group manager agent configuration processor.
GroupManagerProcessor ¶
GroupManagerProcessor(
agent: WaldiezAgent,
initial_chats: list[WaldiezAgentConnection],
group_chat_members: list[WaldiezAgent],
agent_names: dict[str, str],
model_names: dict[str, str],
all_models: list[WaldiezModel],
serializer: Callable[..., str],
cache_seed: int | None = None,
strategy: GroupManagerStrategy | None = None,
)
Processes group manager configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The group manager agent to process. | required |
initial_chats | list[WaldiezAgentConnection] | The initial chats to process for the group manager. | required |
group_chat_members | list[WaldiezAgent] | The members of the group chat. | required |
agent_names | dict[str, str] | Mapping of agent IDs to their names. | required |
model_names | dict[str, str] | Mapping of model IDs to their names. | required |
all_models | list[WaldiezModel] | List of all models available for the agent. | required |
serializer | Callable[..., str] | Function to serialize data into a string format. | required |
cache_seed | Optional[int] | Seed for caching purposes, by default None. | None |
strategy | Optional[GroupManagerStrategy] | Optional strategy to force (pattern based or traditional) | None |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
is_pattern_strategy staticmethod ¶
Check if the group manager should use pattern strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_chats | list[WaldiezAgentConnection] | The initial chats to determine the strategy. | required |
Returns:
| Type | Description |
|---|---|
bool | True if pattern strategy should be used, False otherwise. |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> GroupManagerExtras
Process group manager and return extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, by default None. | None |
termination_config | TerminationConfig | Configuration for termination, by default None. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, by default None. | None |
Returns:
| Type | Description |
|---|---|
GroupManagerExtras | The processed group manager extras containing configuration. |
Source code in waldiez/exporting/agent/extras/group_manager_agent_extas.py
group_member_extras ¶
Group member agent configuration processor.
GroupMemberAgentProcessor ¶
GroupMemberAgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
tool_names: dict[str, str],
all_chats: list[WaldiezChat],
chat_names: dict[str, str],
serializer: Callable[..., str],
)
Processor for group member agent configuration.Source code in
waldiez/exporting/agent/extras/group_member_extras.py
process ¶
process() -> GroupMemberProcessorResult
Process group member agent configuration.
Returns:
| Type | Description |
|---|---|
GroupMemberProcessorResult | The processed result containing before_agent code, after_agent code, and extra imports. |
Source code in waldiez/exporting/agent/extras/group_member_extras.py
GroupMemberProcessorResult dataclass ¶
GroupMemberProcessorResult(
before_agent: str = "",
after_agent: str = "",
extra_arguments: list[InstanceArgument] = list(),
extra_imports: set[ImportStatement] = set(),
)
Result from processing group member agent configuration.
handoffs ¶
Utility functions for generating agent related strings.
AfterWorkProcessor ¶
AfterWorkProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for after-work configurations.Source code in
waldiez/exporting/agent/extras/handoffs/after_work.py
process ¶
process(
after_work: WaldiezTransitionTarget,
) -> AfterWorkResult
Process after-work configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
after_work | WaldiezTransitionTarget | The after-work transition target to process. | required |
Returns:
| Type | Description |
|---|---|
AfterWorkResult | The processed result containing the registration string, before_content code, and extra imports. |
Source code in waldiez/exporting/agent/extras/handoffs/after_work.py
AfterWorkResult dataclass ¶
Result from processing after-work configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
content | str | The registration string for the after-work transition. |
before_content | str | Any additional code that should be placed before the main content, |
extra_imports | set[str] | Additional imports required for the after-work transition. |
HandoffProcessor ¶
HandoffProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for agent handoffs.Source code in
waldiez/exporting/agent/extras/handoffs/handoff.py
process ¶
process() -> HandoffResult
Process all handoff configurations.
Returns:
| Type | Description |
|---|---|
HandoffResult | The processed handoff result containing after_agent code, and extra imports. |
Source code in waldiez/exporting/agent/extras/handoffs/handoff.py
HandoffResult dataclass ¶
TargetResult dataclass ¶
TransitionTargetProcessor ¶
TransitionTargetProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for transition targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_names | dict[str, str] | Mapping of agent IDs to their names. | required |
Source code in waldiez/exporting/agent/extras/handoffs/target.py
process ¶
process(target: WaldiezTransitionTarget) -> TargetResult
Process transition target based on its type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | WaldiezTransitionTarget | The transition target to process. | required |
Returns:
| Type | Description |
|---|---|
TargetResult | The processed result containing the target string, before_content code, and extra imports. |
Raises:
| Type | Description |
|---|---|
ValueError | If the target type is unknown. |
Source code in waldiez/exporting/agent/extras/handoffs/target.py
after_work ¶
After-work processor for Waldiez agents.
AfterWorkProcessor ¶
AfterWorkProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for after-work configurations.Source code in
waldiez/exporting/agent/extras/handoffs/after_work.py
process ¶
process(
after_work: WaldiezTransitionTarget,
) -> AfterWorkResult
Process after-work configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
after_work | WaldiezTransitionTarget | The after-work transition target to process. | required |
Returns:
| Type | Description |
|---|---|
AfterWorkResult | The processed result containing the registration string, before_content code, and extra imports. |
Source code in waldiez/exporting/agent/extras/handoffs/after_work.py
AfterWorkResult dataclass ¶
Result from processing after-work configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
content | str | The registration string for the after-work transition. |
before_content | str | Any additional code that should be placed before the main content, |
extra_imports | set[str] | Additional imports required for the after-work transition. |
available ¶
Transition availability processor for Waldiez agents.
TransitionAvailableProcessor ¶
Processor for transition availability.
process ¶
process(
available: WaldiezTransitionAvailability,
) -> TransitionAvailableResult
Process the transition availability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available | WaldiezTransitionAvailability | The transition availability to process. | required |
Returns:
| Type | Description |
|---|---|
TransitionAvailableResult | The result of processing the transition availability. |
Raises:
| Type | Description |
|---|---|
ValueError | If the transition type is unsupported. |
Source code in waldiez/exporting/agent/extras/handoffs/available.py
condition ¶
Handoff condition processing for Waldiez agents.
ConditionProcessor ¶
ConditionProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for handoff conditions.Source code in
waldiez/exporting/agent/extras/handoffs/condition.py
process ¶
process(
condition: WaldiezHandoffCondition,
) -> ConditionResult
Process handoff conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
condition | WaldiezHandoffCondition | The handoff condition to process. | required |
Returns:
| Type | Description |
|---|---|
ConditionResult | The processed result containing the relevant code and extra imports. |
Raises:
| Type | Description |
|---|---|
ValueError | If the condition type is unsupported. |
Source code in waldiez/exporting/agent/extras/handoffs/condition.py
handoff ¶
Handoff processor for Waldiez agents.
HandoffProcessor ¶
HandoffProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for agent handoffs.Source code in
waldiez/exporting/agent/extras/handoffs/handoff.py
process ¶
process() -> HandoffResult
Process all handoff configurations.
Returns:
| Type | Description |
|---|---|
HandoffResult | The processed handoff result containing after_agent code, and extra imports. |
Source code in waldiez/exporting/agent/extras/handoffs/handoff.py
HandoffResult dataclass ¶
target ¶
Transition target processor for Waldiez agents.
TargetResult dataclass ¶
TransitionTargetProcessor ¶
TransitionTargetProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
chat_names: dict[str, str],
all_chats: list[WaldiezChat],
serializer: Callable[..., str],
)
Processor for transition targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_names | dict[str, str] | Mapping of agent IDs to their names. | required |
Source code in waldiez/exporting/agent/extras/handoffs/target.py
process ¶
process(target: WaldiezTransitionTarget) -> TargetResult
Process transition target based on its type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | WaldiezTransitionTarget | The transition target to process. | required |
Returns:
| Type | Description |
|---|---|
TargetResult | The processed result containing the target string, before_content code, and extra imports. |
Raises:
| Type | Description |
|---|---|
ValueError | If the target type is unknown. |
Source code in waldiez/exporting/agent/extras/handoffs/target.py
rag ¶
Agent exporter rag extras.
VectorDBExtras dataclass ¶
Vector DB exporting extras for RAG user agents.
chroma_extras ¶
Get chroma db related imports and content.
get_chroma_db_args ¶
Get the 'kwargs to use for ChromaVectorDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
tuple[str, Set[str], str] |
|
Source code in waldiez/exporting/agent/extras/rag/chroma_extras.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
get_vector_db_extras ¶
get_vector_db_extras(
agent: WaldiezRagUserProxy, agent_name: str
) -> VectorDBExtras
Get the RAG user vector db string.
The vector db can be one of the following: "vector_db": ChromaVectorDB(....) "vector_db": QdrantVectorDB(....) "vector_db": MongoDBAtlasVectorDB(....) "vector_db": PGVectorDB(....)
If a custom embedding function is to be used, it's name will be in the arg and its definition will be before the arg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
VectorDBExtras | The vector db extras containing the before content, vector db arg, and imports. |
Source code in waldiez/exporting/agent/extras/rag/vector_db_extras.py
mongo_extras ¶
Get mongodb related content and imports.
get_mongodb_db_args ¶
Get the kwargs to use for MongoDBAtlasVectorDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
tuple[str, Set[str], str] | The kwargs to use, what to import and the custom_embedding_function. |
Source code in waldiez/exporting/agent/extras/rag/mongo_extras.py
pgvector_extras ¶
Get pgvector related content and imports.
get_pgvector_db_args ¶
Get the kwargs to use for PGVectorDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
tuple[tuple[str, str], Set[str], str] | The kwargs to use, what to import and the custom_embedding_function. |
Source code in waldiez/exporting/agent/extras/rag/pgvector_extras.py
qdrant_extras ¶
Get qdrant db related imports and content.
get_qdrant_db_args ¶
Get the kwargs to use for QdrantVectorDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
tuple[str, Set[str], str] | The kwargs to use, the imports and the embedding function body if used. |
Source code in waldiez/exporting/agent/extras/rag/qdrant_extras.py
vector_db_extras ¶
Vector DB exporting utils for RAG user agents.
VectorDBExtras dataclass ¶
Vector DB exporting extras for RAG user agents.
get_vector_db_extras ¶
get_vector_db_extras(
agent: WaldiezRagUserProxy, agent_name: str
) -> VectorDBExtras
Get the RAG user vector db string.
The vector db can be one of the following: "vector_db": ChromaVectorDB(....) "vector_db": QdrantVectorDB(....) "vector_db": MongoDBAtlasVectorDB(....) "vector_db": PGVectorDB(....)
If a custom embedding function is to be used, it's name will be in the arg and its definition will be before the arg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezRagUserProxy | The agent. | required |
agent_name | str | The agent's name. | required |
Returns:
| Type | Description |
|---|---|
VectorDBExtras | The vector db extras containing the before content, vector db arg, and imports. |
Source code in waldiez/exporting/agent/extras/rag/vector_db_extras.py
rag_user_proxy_agent_extras ¶
RAG user proxy agent configuration processor.
RagUserProxyAgentProcessor ¶
RagUserProxyAgentProcessor(
agent: WaldiezAgent,
agent_name: str,
model_names: dict[str, str],
path_resolver: PathResolver | None = None,
serializer: Serializer | None = None,
)
Processor for RAG user proxy agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The Waldiez RAG user proxy agent to process. | required |
model_names | dict[str, str] | A mapping from model id to model name. | required |
path_resolver | PathResolver | None | Optional path resolver for resolving paths. Defaults to DefaultPathResolver if not provided. | None |
serializer | Serializer | None | Optional serializer for the RAG configuration. Defaults to DefaultSerializer if not provided. | None |
Source code in waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py
process ¶
process() -> RAGUserExtras
Process RAG user proxy agent configuration.
Returns:
| Type | Description |
|---|---|
RAGConfig | The processed result containing extra arguments, before content, imports, and environment variables. |
Source code in waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py
reasoning_agent_extras ¶
Reasoning agent configuration processor.
ReasoningAgentProcessor ¶
ReasoningAgentProcessor(
agent: WaldiezAgent, serializer: Serializer | None
)
Processor for reasoning agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The Waldiez agent to process. | required |
serializer | Serializer | None | Optional serializer for the reasoning configuration. Defaults to DefaultSerializer if not provided. | required |
Source code in waldiez/exporting/agent/extras/reasoning_agent_extras.py
process ¶
process(
code_execution_config: (
CodeExecutionConfig | None
) = None,
termination_config: TerminationConfig | None = None,
system_message_config: (
SystemMessageConfig | None
) = None,
) -> ReasoningExtras
Process reasoning agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_execution_config | CodeExecutionConfig | Configuration for code execution, if applicable. | None |
termination_config | TerminationConfig | Configuration for termination, if applicable. | None |
system_message_config | SystemMessageConfig | Configuration for system messages, if applicable. | None |
Returns:
| Type | Description |
|---|---|
ReasoningExtras | The processed result containing extra arguments, before content, imports, and environment variables. |
Source code in waldiez/exporting/agent/extras/reasoning_agent_extras.py
factory ¶
Factory for creating agent exporter.
create_agent_exporter ¶
create_agent_exporter(
agent: WaldiezAgent,
agent_names: dict[str, str],
models: tuple[list[WaldiezModel], dict[str, str]],
chats: tuple[list[WaldiezChat], dict[str, str]],
tool_names: dict[str, str],
initial_chats: list[WaldiezAgentConnection],
is_async: bool = False,
for_notebook: bool = False,
cache_seed: int | None = None,
group_chat_members: list[WaldiezAgent] | None = None,
arguments_resolver: (
Callable[[WaldiezAgent], list[str]] | None
) = None,
output_dir: str | Path | None = None,
context: ExporterContext | None = None,
**kwargs: Any
) -> AgentExporter
Create an agent exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent | WaldiezAgent | The agent to export. | required |
agent_names | dict[str, str] | Mapping of agent IDs to names. | required |
models | tuple[list[WaldiezModel], dict[str, str]] | All models and model names mapping. | required |
chats | tuple[list[WaldiezChat], dict[str, str]] | All chats and chat names mapping. | required |
tool_names | dict[str, str] | Mapping of tool IDs to names. | required |
is_async | bool | Whether the flow is async, by default False | False |
for_notebook | bool | Whether exporting for notebook, by default False | False |
cache_seed | Optional[int] | Cache seed if any, by default None | None |
initial_chats | list[WaldiezAgentConnection] | Initial chats for group managers, by default None | required |
group_chat_members | list[WaldiezAgent] | Group chat members if group manager, by default None | None |
arguments_resolver | Callable | Function to resolve additional arguments, by default None | None |
output_dir | str | Path | None | Output directory for generated files, by default None | None |
context | ExporterContext | None | Exporter context with dependencies, by default None | None |
**kwargs | Any | Additional keyword arguments. | {} |
Returns:
| Type | Description |
|---|---|
AgentExporter | The created agent exporter. |
Source code in waldiez/exporting/agent/factory.py
processor ¶
Processor for generating Waldiez agent definitions.
AgentProcessingResult dataclass ¶
AgentProcessingResult(content: str = '')
Result from processing an agent.
AgentProcessor ¶
AgentProcessor(
agent: WaldiezAgent,
agent_names: dict[str, str],
arguments_resolver: Callable[[WaldiezAgent], list[str]],
extras: StandardExtras,
)
Processor for main agent definition generation.Source code in
waldiez/exporting/agent/processor.py
add_extra_args ¶
Add extra agent args.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_str | str | The current agent string | required |
extra_args | str | The extra args to add | required |
Returns:
| Type | Description |
|---|---|
str | The new agent string |
Source code in waldiez/exporting/agent/processor.py
get_agent_string ¶
Get the agent definition string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name | str | The name of the agent. | required |
ag2_class | str | The class of the agent. | required |
extra_args | str | Additional arguments for the agent. | required |
Returns:
| Type | Description |
|---|---|
str | The agent definition string. |
Source code in waldiez/exporting/agent/processor.py
get_auto_reply_arg ¶
get_auto_reply_arg() -> str
Get the default auto reply argument.
Returns:
| Type | Description |
|---|---|
str | The default auto reply argument. |
Source code in waldiez/exporting/agent/processor.py
get_code_execution_arg ¶
get_code_execution_arg() -> str
Get the code execution argument.
Returns:
| Type | Description |
|---|---|
str | The code execution argument. |
Source code in waldiez/exporting/agent/processor.py
get_description_arg ¶
get_description_arg() -> str
Get the agent description.
Returns:
| Type | Description |
|---|---|
str | The agent description. |
Source code in waldiez/exporting/agent/processor.py
get_human_input_mode_arg ¶
get_human_input_mode_arg() -> str
get_max_consecutive_auto_reply_arg ¶
get_max_consecutive_auto_reply_arg() -> str
Get the maximum consecutive auto reply argument.
Returns:
| Type | Description |
|---|---|
str | The maximum consecutive auto reply argument. |
Source code in waldiez/exporting/agent/processor.py
get_name_arg ¶
get_name_arg() -> str
get_system_message_arg ¶
get_system_message_arg() -> str
Get the system message argument.
Returns:
| Type | Description |
|---|---|
str | The system message argument. |
Source code in waldiez/exporting/agent/processor.py
get_termination_arg ¶
get_termination_arg() -> str
Get the termination argument.
Returns:
| Type | Description |
|---|---|
str | The termination argument. |
Source code in waldiez/exporting/agent/processor.py
process ¶
process() -> AgentProcessingResult
Process the agent and generate its definition.
Returns:
| Type | Description |
|---|---|
AgentProcessingResult | The result containing the agent definition string. |
Source code in waldiez/exporting/agent/processor.py
system_message ¶
Termination message configuration for Waldiez agents.
SystemMessageProcessor ¶
SystemMessageProcessor(agent: WaldiezAgent)
Processor for system message configuration.
process ¶
process() -> SystemMessageConfig
Process system message configuration.
Returns:
| Type | Description |
|---|---|
SystemMessageConfig | The processed system message configuration. |
Source code in waldiez/exporting/agent/system_message.py
termination ¶
Termination message configuration for Waldiez agents.
TerminationProcessor ¶
TerminationProcessor(agent: WaldiezAgent, agent_name: str)
Processor for termination message configuration.
process ¶
process() -> TerminationConfig
Process termination configuration.
Returns:
| Type | Description |
|---|---|
TerminationConfig | The processed termination configuration. |