fix: readline error on Windows (#139)

With this change, `pyreadline3` is automatically installed on OS `win32`
only. Linux/Mac doesn't need it.
This commit is contained in:
Nate Barbettini 2024-11-01 13:15:52 -07:00 committed by GitHub
parent efee9589fa
commit aff7350eec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -1,6 +1,5 @@
import asyncio
import os
import readline
import threading
import uuid
import webbrowser
@ -234,6 +233,14 @@ def chat(
"""
Chat with a language model.
"""
try:
import readline
except ImportError:
console.print(
"Readline is not available on this platform. Command history will be limited.",
style="dim",
)
config = validate_and_get_config()
base_url = compute_base_url(force_tls, force_no_tls, host, port)

View file

@ -37,6 +37,7 @@ scikit-learn = {version = "^1.5.0", optional = true}
pytz = {version = "^2024.1", optional = true}
python-dateutil = {version = "^2.8.2", optional = true}
pyreadline3 = {version = "^3.5.4", platform = "win32"}
[tool.poetry.extras]
fastapi = ["fastapi", "uvicorn", "opentelemetry-instrumentation-fastapi", "opentelemetry-exporter-otlp-proto-http", "opentelemetry-exporter-otlp-proto-common"]
evals = ["scipy", "numpy", "scikit-learn", "pytz", "python-dateutil"]