From 1f1da4b1a2e97bce6d8d3a4b4b517a002c0cd449 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 8 Jun 2024 12:53:54 -0700 Subject: [PATCH] refac all urls into urls.py --- aider/coders/base_coder.py | 10 +++------- aider/gui.py | 13 +++++++------ aider/models.py | 3 ++- aider/scrape.py | 8 ++++---- aider/urls.py | 7 +++++++ requirements.in | 1 + requirements.txt | 2 ++ 7 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 aider/urls.py diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 1d7046ad8..8b3a54c72 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -17,7 +17,7 @@ from jsonschema import Draft7Validator from rich.console import Console, Text from rich.markdown import Markdown -from aider import __version__, models, prompts, utils +from aider import __version__, models, prompts, urls, utils from aider.commands import Commands from aider.history import ChatSummary from aider.io import InputOutput @@ -1213,9 +1213,7 @@ class Coder: return self.io.tool_error("Warning: it's best to only add files that need changes to the chat.") - self.io.tool_error( - "https://aider.chat/docs/faq.html#how-can-i-add-all-the-files-to-the-chat" - ) + self.io.tool_error(urls.edit_errors) self.warning_given = True def prepare_to_edit(self, edits): @@ -1255,9 +1253,7 @@ class Coder: err = err.args[0] self.io.tool_error("The LLM did not conform to the edit format.") - self.io.tool_error( - "For more info see: https://aider.chat/docs/faq.html#aider-isnt-editing-my-files" - ) + self.io.tool_error(urls.edit_errors) self.io.tool_error() self.io.tool_error(str(err), strip=False) diff --git a/aider/gui.py b/aider/gui.py index e064aaf70..6d5cd0a9a 100755 --- a/aider/gui.py +++ b/aider/gui.py @@ -6,6 +6,7 @@ import sys import streamlit as st +from aider import urls from aider.coders import Coder from aider.dump import dump # noqa: F401 from aider.io import InputOutput @@ -159,12 +160,12 @@ class GUI: pass def do_recommended_actions(self): + text = "Aider works best when your code is stored in a git repo. \n" + text += f"[See the FAQ for more info]({urls.git})" + with st.expander("Recommended actions", expanded=True): with st.popover("Create a git repo to track changes"): - st.write( - "Aider works best when your code is stored in a git repo. \n[See the FAQ" - " for more info](https://aider.chat/docs/git.html)" - ) + st.write(text) self.button("Create git repo", key=random.random(), help="?") with st.popover("Update your `.gitignore` file"): @@ -513,9 +514,9 @@ def gui_main(): st.set_page_config( layout="wide", page_title="Aider", - page_icon="https://aider.chat/assets/favicon-32x32.png", + page_icon=urls.favicon, menu_items={ - "Get Help": "https://aider.chat/", + "Get Help": urls.website, "Report a bug": "https://github.com/paul-gauthier/aider/issues", "About": "# Aider\nAI pair programming in your browser.", }, diff --git a/aider/models.py b/aider/models.py index 60a18a23d..1d51c10c7 100644 --- a/aider/models.py +++ b/aider/models.py @@ -8,6 +8,7 @@ from typing import Optional from PIL import Image +from aider import urls from aider.dump import dump # noqa: F401 from aider.litellm import litellm @@ -471,7 +472,7 @@ def sanity_check_model(io, model): io.tool_error(f"- {m} ({fq})") if show: - io.tool_error("For more info see https://aider.chat/docs/llms/warnings.html") + io.tool_error(urls.model_warnings) def fuzzy_match_models(name): diff --git a/aider/scrape.py b/aider/scrape.py index ea0734f62..48a220b70 100755 --- a/aider/scrape.py +++ b/aider/scrape.py @@ -8,18 +8,18 @@ import pypandoc from bs4 import BeautifulSoup from playwright.sync_api import sync_playwright -from aider import __version__ +from aider import __version__, urls -aider_user_agent = f"Aider/{__version__} +https://aider.chat" +aider_user_agent = f"Aider/{__version__} +{urls.website}" # Playwright is nice because it has a simple way to install dependencies on most # platforms. -PLAYWRIGHT_INFO = """ +PLAYWRIGHT_INFO = f""" For better web scraping, install Playwright chromium with this command in your terminal: playwright install --with-deps chromium -See https://aider.chat/docs/install/optional.html#enable-playwright for more info. +See {urls.enable_playwrite} for more info. """ diff --git a/aider/urls.py b/aider/urls.py new file mode 100644 index 000000000..29e7d1370 --- /dev/null +++ b/aider/urls.py @@ -0,0 +1,7 @@ +website = "https://aider.chat/" +add_all_files = "https://aider.chat/docs/faq.html#how-can-i-add-all-the-files-to-the-chat" +edit_errors = "https://aider.chat/docs/troubleshooting/edit-errors.html" +git = "https://aider.chat/docs/git.html" +enable_playwrite = "https://aider.chat/docs/install/optional.html#enable-playwright" +favicon = "https://aider.chat/assets/favicon-32x32.png" +model_warnings = "https://aider.chat/docs/llms/warnings.html" diff --git a/requirements.in b/requirements.in index 1da3cbafa..f7e49c219 100644 --- a/requirements.in +++ b/requirements.in @@ -26,6 +26,7 @@ pypandoc litellm google-generativeai streamlit +watchdog flake8 # v3.3 no longer works on python 3.9 diff --git a/requirements.txt b/requirements.txt index b5d0731f4..844b4e6b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -321,6 +321,8 @@ uritemplate==4.1.1 # via google-api-python-client urllib3==2.2.1 # via requests +watchdog==4.0.1 + # via -r requirements.in wcwidth==0.2.13 # via prompt-toolkit yarl==1.9.4