diff --git a/gptcli/cli.py b/gptcli/cli.py index 65e1040..838aa0c 100644 --- a/gptcli/cli.py +++ b/gptcli/cli.py @@ -78,13 +78,15 @@ def __exit__(self, *args): class CLIChatListener(ChatListener): - def __init__(self, markdown: bool): + def __init__(self, markdown: bool, print_welcome: bool): self.markdown = markdown + self.print_welcome = print_welcome self.console = Console() def on_chat_start(self): console = Console(width=80) - console.print(Markdown(TERMINAL_WELCOME)) + if self.print_welcome: + console.print(Markdown(TERMINAL_WELCOME)) def on_chat_clear(self): self.console.print("[bold]Cleared the conversation.[/bold]") diff --git a/gptcli/config.py b/gptcli/config.py index a23753b..4344f2e 100644 --- a/gptcli/config.py +++ b/gptcli/config.py @@ -18,6 +18,7 @@ class GptCliConfig: default_assistant: str = "general" markdown: bool = True show_price: bool = True + print_welcome: bool = True api_key: Optional[str] = os.environ.get("OPENAI_API_KEY") openai_api_key: Optional[str] = os.environ.get("OPENAI_API_KEY") openai_base_url: Optional[str] = os.environ.get("OPENAI_BASE_URL") diff --git a/gptcli/gpt.py b/gptcli/gpt.py index 897694e..94b4bfb 100755 --- a/gptcli/gpt.py +++ b/gptcli/gpt.py @@ -139,6 +139,13 @@ def parse_args(config: GptCliConfig): help="Disable price logging.", default=config.show_price, ) + parser.add_argument( + "--no_welcome", + action="store_false", + dest="print_welcome", + help="Deactivate the welcome message being printed to the top of the terminal.", + default=config.print_welcome, + ) parser.add_argument( "--version", "-v", @@ -230,9 +237,9 @@ def run_non_interactive(args, assistant): class CLIChatSession(ChatSession): - def __init__(self, assistant: Assistant, markdown: bool, show_price: bool): + def __init__(self, assistant: Assistant, markdown: bool, show_price: bool, print_welcome: bool): listeners = [ - CLIChatListener(markdown), + CLIChatListener(markdown, print_welcome), LoggingChatListener(), ] @@ -246,7 +253,7 @@ def __init__(self, assistant: Assistant, markdown: bool, show_price: bool): def run_interactive(args, assistant): logger.info("Starting a new chat session. Assistant config: %s", assistant.config) session = CLIChatSession( - assistant=assistant, markdown=args.markdown, show_price=args.show_price + assistant=assistant, markdown=args.markdown, show_price=args.show_price, print_welcome=args.print_welcome ) history_filename = os.path.expanduser("~/.config/gpt-cli/history") os.makedirs(os.path.dirname(history_filename), exist_ok=True)