feat: Multi-model command line

This commit is contained in:
FangYin Cheng
2023-08-30 11:07:35 +08:00
parent d467092766
commit dd86fb86b1
20 changed files with 317 additions and 35 deletions

View File

@@ -0,0 +1,45 @@
import sys
import click
import os
import copy
import logging
sys.path.append(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
)
@click.group()
@click.option(
"--log-level",
required=False,
type=str,
default="warn",
help="Log level",
)
@click.version_option()
def cli(log_level: str):
# TODO not working now
logging.basicConfig(level=log_level, encoding="utf-8")
def add_command_alias(command, name: str, hidden: bool = False):
new_command = copy.deepcopy(command)
new_command.hidden = hidden
cli.add_command(new_command, name=name)
try:
from pilot.model.cli import model_cli_group
add_command_alias(model_cli_group, name="model")
except ImportError as e:
logging.warning(f"Integrating dbgpt model command line tool failed: {e}")
def main():
return cli()
if __name__ == "__main__":
main()