From c34aa1fbdec6084387013a06dc768932698b594b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 8 Nov 2024 12:43:21 -0500 Subject: [PATCH] Update pyproject.toml to version 0.1.2 --- pyproject.toml | 2 +- simplechat/cli.py | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5cc0f4..303b5ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "simplemind-chat" -version = "0.1.1" +version = "0.1.2" description = "A chat interface for AI models using Simplemind." readme = "README.md" requires-python = ">=3.11" diff --git a/simplechat/cli.py b/simplechat/cli.py index 2699727..c37a0b4 100644 --- a/simplechat/cli.py +++ b/simplechat/cli.py @@ -4,24 +4,35 @@ import sys import subprocess import spacy +import nltk from spacy.cli import download -def ensure_spacy_model(): - """Ensure the required spaCy model is downloaded.""" +def ensure_models(): + """Ensure the required spaCy and NLTK models are downloaded.""" + # SpaCy model model_name = "en_core_web_sm" try: spacy.load(model_name) except OSError: - console.print(f"Downloading required language model: {model_name}") + print(f"Downloading required spaCy model: {model_name}") download(model_name) - console.print("Download complete!") + print("SpaCy download complete!") + # NLTK punkt + try: + nltk.data.find("tokenizers/punkt") + except LookupError: + print("Downloading required NLTK punkt tokenizer") + nltk.download("punkt_tab") + print("NLTK download complete!") + + +ensure_models() from rich.console import Console console = Console() -ensure_spacy_model() import xerox import simplemind as sm