mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
offer to install aider[hf]
This commit is contained in:
parent
4e07710d4e
commit
f688c18b65
8 changed files with 60 additions and 14 deletions
|
@ -6,7 +6,7 @@ from pathlib import Path
|
|||
|
||||
import importlib_resources
|
||||
|
||||
from aider import __version__
|
||||
from aider import __version__, utils
|
||||
from aider.dump import dump # noqa: F401
|
||||
from aider.help_pats import exclude_website_pats
|
||||
|
||||
|
@ -87,10 +87,35 @@ def get_index():
|
|||
return index
|
||||
|
||||
|
||||
class PipInstallHF(Exception):
|
||||
pass
|
||||
|
||||
|
||||
pip_install_cmd = [
|
||||
"aider[hf]",
|
||||
"--extra-index-url",
|
||||
"https://download.pytorch.org/whl/cpu",
|
||||
]
|
||||
|
||||
pip_install_error = f"""
|
||||
To use interactive /help you need to install HuggingFace embeddings:
|
||||
|
||||
pip install {' '.join(pip_install_cmd)}
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class Help:
|
||||
def __init__(self):
|
||||
def __init__(self, pip_install=False):
|
||||
if pip_install:
|
||||
utils.pip_install(pip_install_cmd)
|
||||
|
||||
from llama_index.core import Settings
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
|
||||
try:
|
||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||
except ImportError:
|
||||
raise PipInstallHF(pip_install_error)
|
||||
|
||||
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
||||
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue