chat (CLI command)
What it is
A click-based CLI command that loads a module via naas_abi_core’s Engine and runs a named terminal agent from that module.
Public API
chat(module_name: str = "", agent_name: str = "")- Click command named
chat. - Arguments:
module-name(string, default"")agent-name(string, default"")
- Behavior:
- If both arguments are empty, uses
engine.configuration.default_agentand splits it into"module agent". - Loads the module via
engine.load(module_names=[module_name]). - Validates the module exists in
engine.modules; otherwise raisesValueError. - Searches
engine.modules[module_name].agentsfor a class whose__name__matchesagent_name. - Runs the agent via
naas_abi_core.apps.terminal_agent.main.run_agent(agent_class.New()).
- If both arguments are empty, uses
- Click command named
Configuration/Dependencies
- Dependencies
clicknaas_abi_core:naas_abi_core.engine.Engine.Enginenaas_abi_core.apps.terminal_agent.main.run_agentnaas_abi_core.logger
- Configuration
engine.configuration.default_agentmust be a string formatted like"module_name agent_name"if relying on defaults.
Usage
# Running through Click normally happens via your package's CLI entrypoint.
# If you have a Click group, it typically registers `chat` as a subcommand.
Example CLI invocation (assuming your project exposes this command):
# Use explicit module and agent
naas-abi chat my_module MyAgent
# Use defaults from engine.configuration.default_agent
naas-abi chat
Caveats
- If
module_nameis loaded but no agent class name matchesagent_name, nothing is run and no error is raised. default_agentis split on a single space (split(" ")); unexpected formatting may break default resolution.- The agent class is expected to provide a
New()constructor-like method (called dynamically).