mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
refactor help install and add to test setup
This commit is contained in:
parent
9c9fdb0a1b
commit
9ed0e33b9f
4 changed files with 25 additions and 18 deletions
|
@ -6,8 +6,8 @@ from pathlib import Path
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
|
||||||
from aider import models, prompts, utils, voice
|
from aider import models, prompts, voice
|
||||||
from aider.help import Help
|
from aider.help import Help, install_help_extra
|
||||||
from aider.llm import litellm
|
from aider.llm import litellm
|
||||||
from aider.scrape import Scraper
|
from aider.scrape import Scraper
|
||||||
from aider.utils import is_image_file
|
from aider.utils import is_image_file
|
||||||
|
@ -662,17 +662,7 @@ class Commands:
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
|
|
||||||
if not self.help:
|
if not self.help:
|
||||||
pip_install_cmd = [
|
res = install_help_extra(self.io)
|
||||||
"aider-chat[hf-embed]",
|
|
||||||
"--extra-index-url",
|
|
||||||
"https://download.pytorch.org/whl/cpu",
|
|
||||||
]
|
|
||||||
res = utils.check_pip_install_extra(
|
|
||||||
self.io,
|
|
||||||
"llama_index.embeddings.huggingface",
|
|
||||||
"To use interactive /help you need to install HuggingFace embeddings",
|
|
||||||
pip_install_cmd,
|
|
||||||
)
|
|
||||||
if not res:
|
if not res:
|
||||||
self.io.tool_error("Unable to initialize interactive help.")
|
self.io.tool_error("Unable to initialize interactive help.")
|
||||||
return
|
return
|
||||||
|
|
|
@ -6,13 +6,28 @@ from pathlib import Path
|
||||||
|
|
||||||
import importlib_resources
|
import importlib_resources
|
||||||
|
|
||||||
from aider import __version__
|
from aider import __version__, utils
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.help_pats import exclude_website_pats
|
from aider.help_pats import exclude_website_pats
|
||||||
|
|
||||||
warnings.simplefilter("ignore", category=FutureWarning)
|
warnings.simplefilter("ignore", category=FutureWarning)
|
||||||
|
|
||||||
|
|
||||||
|
def install_help_extra(io):
|
||||||
|
pip_install_cmd = [
|
||||||
|
"aider-chat[hf-embed]",
|
||||||
|
"--extra-index-url",
|
||||||
|
"https://download.pytorch.org/whl/cpu",
|
||||||
|
]
|
||||||
|
res = utils.check_pip_install_extra(
|
||||||
|
io,
|
||||||
|
"llama_index.embeddings.huggingface",
|
||||||
|
"To use interactive /help you need to install HuggingFace embeddings",
|
||||||
|
pip_install_cmd,
|
||||||
|
)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def get_package_files():
|
def get_package_files():
|
||||||
for path in importlib_resources.files("aider.website").iterdir():
|
for path in importlib_resources.files("aider.website").iterdir():
|
||||||
if path.is_file():
|
if path.is_file():
|
||||||
|
@ -88,7 +103,7 @@ def get_index():
|
||||||
|
|
||||||
|
|
||||||
class Help:
|
class Help:
|
||||||
def __init__(self, pip_install=False):
|
def __init__(self):
|
||||||
from llama_index.core import Settings
|
from llama_index.core import Settings
|
||||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from aider.help import Help
|
from aider.help import Help, install_help_extra
|
||||||
|
from aider.io import InputOutput
|
||||||
|
|
||||||
|
|
||||||
class TestHelp(unittest.TestCase):
|
class TestHelp(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
Help(pip_install=True)
|
io = InputOutput(yes=True)
|
||||||
|
install_help_extra(io)
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
help_inst = Help()
|
help_inst = Help()
|
||||||
|
|
|
@ -236,7 +236,7 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||||
|
|
||||||
cmd = get_pip_install(pip_install_cmd)
|
cmd = get_pip_install(pip_install_cmd)
|
||||||
|
|
||||||
text = f"{prompt}:\n\n{' '.join(cmd)}\n\n"
|
text = f"{prompt}:\n\n{' '.join(cmd)}\n"
|
||||||
io.tool_error(text)
|
io.tool_error(text)
|
||||||
|
|
||||||
if not io.confirm_ask("Run pip install?", default="y"):
|
if not io.confirm_ask("Run pip install?", default="y"):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue