From 25d6e451f4fbdabd0ef5fbd8eed732738ef8375d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Wed, 27 Nov 2024 13:39:55 +0100 Subject: [PATCH] build: improve support for uv (#288) --- gptme/chat.py | 2 +- gptme/cli.py | 2 +- gptme/init.py | 2 +- gptme/prompts.py | 2 +- gptme/{ => util}/readline.py | 8 +++---- poetry.lock | 5 ++-- pyproject.toml | 44 +++++++++++++++++++++++++++++------- tests/test_readline.py | 2 +- 8 files changed, 48 insertions(+), 19 deletions(-) rename gptme/{ => util}/readline.py (96%) diff --git a/gptme/chat.py b/gptme/chat.py index 562a6db9..08044987 100644 --- a/gptme/chat.py +++ b/gptme/chat.py @@ -17,7 +17,7 @@ from .logmanager import Log, LogManager, prepare_messages from .message import Message from .prompts import get_workspace_prompt -from .readline import add_history +from .util.readline import add_history from .tools import ToolUse, execute_msg, has_tool from .tools.base import ConfirmFunc from .tools.browser import read_url diff --git a/gptme/cli.py b/gptme/cli.py index a4cec86b..96d09b03 100644 --- a/gptme/cli.py +++ b/gptme/cli.py @@ -20,9 +20,9 @@ from .logmanager import ConversationMeta, get_user_conversations from .message import Message from .prompts import get_prompt -from .readline import add_history from .tools import all_tools, init_tools from .util import epoch_to_age, generate_name +from .util.readline import add_history logger = logging.getLogger(__name__) diff --git a/gptme/init.py b/gptme/init.py index 7895c6b0..e5caa582 100644 --- a/gptme/init.py +++ b/gptme/init.py @@ -13,9 +13,9 @@ get_recommended_model, set_default_model, ) -from .readline import load_readline_history, register_tabcomplete from .tools import init_tools from .util import console +from .util.readline import load_readline_history, register_tabcomplete logger = logging.getLogger(__name__) _init_done = False diff --git a/gptme/prompts.py b/gptme/prompts.py index 3695eeae..7e10bff0 100644 --- a/gptme/prompts.py +++ b/gptme/prompts.py @@ -241,7 +241,7 @@ def prompt_timeinfo() -> Generator[Message, None, None]: def get_workspace_prompt(workspace: Path) -> str: # NOTE: needs to run after the workspace is initialized (i.e. initial prompt is constructed) # TODO: update this prompt if the files change - # TODO: include `git status/diff/log` summary, and keep it up-to-date + # TODO: include `git status -vv`, and keep it up-to-date if project := get_project_config(workspace): files = [] for file in project.files: diff --git a/gptme/readline.py b/gptme/util/readline.py similarity index 96% rename from gptme/readline.py rename to gptme/util/readline.py index 162c50dd..18d6d645 100644 --- a/gptme/readline.py +++ b/gptme/util/readline.py @@ -3,16 +3,16 @@ from functools import lru_cache from pathlib import Path -from .commands import COMMANDS -from .dirs import get_readline_history_file +from ..commands import COMMANDS +from ..dirs import get_readline_history_file # noreorder try: import readline # fmt: skip -except ImportError: # pragma: no cover +except ImportError as e: # pragma: no cover raise Exception( "Unsupported platform: readline not available.\nIf you are on Windows, use WSL or Docker to run gptme." - ) from None + ) from e logger = logging.getLogger(__name__) diff --git a/poetry.lock b/poetry.lock index b6cf7511..fcf92634 100644 --- a/poetry.lock +++ b/poetry.lock @@ -5173,14 +5173,15 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", type = ["pytest-mypy"] [extras] -all = ["flask", "flask-cors", "gptme-rag", "matplotlib", "numpy", "pandas", "pillow", "playwright", "python-xlib"] +all = ["flask", "flask-cors", "gptme-rag", "matplotlib", "numpy", "pandas", "pillow", "playwright", "python-xlib", "youtube_transcript_api"] browser = ["playwright"] computer = ["pillow", "python-xlib"] datascience = ["matplotlib", "numpy", "pandas", "pillow"] rag = ["gptme-rag"] server = ["flask", "flask-cors"] +youtube = ["youtube_transcript_api"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "a6a12c5e4509d5da912b3777b593b7e9469bf18c2812adfe665a28d48b55164a" +content-hash = "c8c24e69c4e57c35efbe16a94baf9b092f3365b40ede02a54f5264ef30121db6" diff --git a/pyproject.toml b/pyproject.toml index c64db0b7..2c371a73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,31 @@ packages = [ include = ["gptme/server/static/**/*", "media/logo.png"] +[project] +name = "gptme" +dependencies = [ + "python = \"^3.10\"", + "click = \"^8.0\"", + "python-dotenv = \"^1.0.0\"", + "rich = \"^13.5.2\"", + "tabulate = \"*\"", + "pick = \"^2.2.0\"", + "tiktoken = \">=0.7\"", + "tomlkit = \"*\"", + "typing-extensions = \"*\"", + "platformdirs = \"^4.3\"", + "lxml = \"*\"", + "ipython = \"^8.17.2\"", + "bashlex = \"^0.18\"", +] + +[project.scripts] +gptme = "gptme.cli:main" +gptme-server = "gptme.server.cli:main" +gptme-eval = "gptme.eval.main:main" +gptme-util = "gptme.util.cli:main" +gptme-nc = "gptme.ncurses:main" + [tool.poetry.scripts] gptme = "gptme.cli:main" gptme-server = "gptme.server.cli:main" @@ -31,20 +56,20 @@ typing-extensions = "*" platformdirs = "^4.3" lxml = "*" +# providers +openai = "^1.0" +anthropic = ">=0.36,<0.40" + # tools ipython = "^8.17.2" bashlex = "^0.18" playwright = {version = "1.47.*", optional=true} # version constrained due to annoying to have to run `playwright install` on every update -youtube_transcript_api = {version = "^0.6.1", optional = true} -python-xlib = {version = "^0.33", optional = true} # for X11 interaction +youtube_transcript_api = {version = "^0.6.1", optional=true} +python-xlib = {version = "^0.33", optional=true} # for X11 interaction # RAG -gptme-rag = {version = "^0.3.1", optional = true} -#gptme-rag = {path = "../gptme-rag", optional = true, develop = true} - -# providers -openai = "^1.0" -anthropic = ">=0.36,<0.40" +gptme-rag = {version = "^0.3.1", optional=true} +#gptme-rag = {path = "../gptme-rag", optional=true, develop=true} # evals multiprocessing-logging = "^0.3.4" @@ -95,6 +120,7 @@ browser = ["playwright"] datascience = ["matplotlib", "pandas", "numpy", "pillow"] computer = ["python-xlib", "pillow"] # pillow already in datascience but listed for clarity rag = ["gptme-rag"] # RAG functionality +youtube = ["youtube_transcript_api"] all = [ # server "flask", "flask-cors", @@ -106,6 +132,8 @@ all = [ "python-xlib", # rag "gptme-rag", + # youtube transcript tool + "youtube_transcript_api", ] [tool.ruff] diff --git a/tests/test_readline.py b/tests/test_readline.py index 39b5ab22..9b7cd56f 100644 --- a/tests/test_readline.py +++ b/tests/test_readline.py @@ -2,7 +2,7 @@ import sys from pathlib import Path -from gptme.readline import _matches +from gptme.util.readline import _matches project_root = Path(__file__).parent.parent