chat
What it is
- A
clickCLI command that loads a module vianaas_abi_core.Engineand launches a terminal agent from that module.
Public API
chat(module_name: str = "", agent_name: str = "")- Click command named
chat. - Arguments:
module-name(str, default""): Module to load.agent-name(str, default""): Agent class name to run.
- Behavior:
- Instantiates
Engine(). - If both args are empty, uses
engine.configuration.default_agentsplit into"module agent". - Loads the module (
engine.load(module_names=[module_name])). - Validates module exists in
engine.modules; otherwise raisesValueError. - Iterates available agent classes in
engine.modules[module_name].agents, matches by__name__, and runs it viarun_agent(agent_class.New()).
- Instantiates
- Click command named
Configuration/Dependencies
- Dependencies
clickfor CLI registration and argument parsing.naas_abi_core:naas_abi_core.engine.Engine.Enginefor configuration and module loading.naas_abi_core.apps.terminal_agent.main.run_agentto execute the agent in a terminal loop.naas_abi_core.loggerfor debug logging.
- Configuration
engine.configuration.default_agentis used when no arguments are provided. It must be a string formatted as"module_name agent_name"(split on a single space).
Usage
CLI
# Run using explicit module and agent names
naas-abi-cli chat my_module MyAgent
# Use the configured default agent (engine.configuration.default_agent)
naas-abi-cli chat
Caveats
- If the module cannot be found after
engine.load(...), the command raisesValueError: Module <name> not found. - If the agent name does not match any agent class
__name__in the module, nothing is run (no explicit error is raised). - Default agent parsing relies on
default_agent.split(" "); unexpected formatting (e.g., extra spaces or missing parts) may cause errors.