diff --git a/gptme/cli.py b/gptme/cli.py index f1f2bef1..99dd93c5 100644 --- a/gptme/cli.py +++ b/gptme/cli.py @@ -21,6 +21,7 @@ """ # The above may be used as a prompt for the agent. import atexit +import importlib.metadata import io import logging import os @@ -54,12 +55,11 @@ from .util import epoch_to_age, generate_unique_name logger = logging.getLogger(__name__) - +print_builtin = __builtins__["print"] # type: ignore LLMChoice = Literal["openai", "llama"] ModelChoice = Literal["gpt-3.5-turbo", "gpt4"] - Actions = Literal[ "continue", "summarize", @@ -236,6 +236,11 @@ def handle_cmd( is_flag=True, help="Show hidden system messages.", ) +@click.option( + "--version", + is_flag=True, + help="Show version.", +) def main( prompts: list[str], prompt_system: str, @@ -247,7 +252,13 @@ def main( no_confirm: bool, show_hidden: bool, interactive: bool, + version: bool, ): + if version: + # print version and exit + print_builtin(f"gptme {importlib.metadata.version('gptme-python')}") + exit(0) + # log init logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)