Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Update deps & lock: litellm not required for now to allow openai 0.28 to work in cached notebooks

Omar Khattab473aeeaaab3b
diff --git a/dspy/clients/lm.py b/dspy/clients/lm.py
index 5e0969110..bdcdda7e6 100644
--- a/dspy/clients/lm.py
+++ b/dspy/clients/lm.py
@@ -1,10 +1,14 @@
import os
import ujson
-import litellm
import functools
-from litellm.caching import Cache
-litellm.cache = Cache(disk_cache_dir=".dspy_cache", type="disk")
+try:
+ import litellm
+ from litellm.caching import Cache
+
+ litellm.cache = Cache(disk_cache_dir=".dspy_cache", type="disk")
+except ImportError:
+ litellm = None
class LM:
def __init__(self, model, model_type='chat', temperature=0.0, cache=True, **kwargs):
diff --git a/poetry.lock b/poetry.lock
index b0a584e58..721d5ddf0 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -2156,7 +2156,7 @@ files = [
name = "jsonschema"
version = "4.23.0"
description = "An implementation of JSON Schema validation for Python"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "jsonschema-4.23.0-py3-none-any.whl", hash = "sha256:fbadb6f8b144a8f8cf9f0b89ba94501d143e50411a1278633f56a7acf7fd5566"},
@@ -2177,7 +2177,7 @@ format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-
name = "jsonschema-specifications"
version = "2023.12.1"
description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "jsonschema_specifications-2023.12.1-py3-none-any.whl", hash = "sha256:87e4fdf3a94858b8a2ba2778d9ba57d8a9cafca7c7489c46ba0d30a8bc6a9c3c"},
@@ -2257,34 +2257,6 @@ traitlets = ">=5.3"
docs = ["myst-parser", "pydata-sphinx-theme", "sphinx-autodoc-typehints", "sphinxcontrib-github-alt", "sphinxcontrib-spelling", "traitlets"]
test = ["ipykernel", "pre-commit", "pytest (<8)", "pytest-cov", "pytest-timeout"]
-[[package]]
-name = "litellm"
-version = "1.44.28"
-description = "Library to easily interface with LLM API providers"
-optional = false
-python-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"
-files = [
- {file = "litellm-1.44.28-py3-none-any.whl", hash = "sha256:a4476c1f076b7996a97bd5d51e53760be482f1ec888c0c626c7877d5c6ff0849"},
- {file = "litellm-1.44.28.tar.gz", hash = "sha256:9a9055ce3f655201e4527786c219eaa98579c0134c031418bc38744fed3cd265"},
-]
-
-[package.dependencies]
-aiohttp = "*"
-click = "*"
-importlib-metadata = ">=6.8.0"
-jinja2 = ">=3.1.2,<4.0.0"
-jsonschema = ">=4.22.0,<5.0.0"
-openai = ">=1.45.0"
-pydantic = ">=2.0.0,<3.0.0"
-python-dotenv = ">=0.2.0"
-requests = ">=2.31.0,<3.0.0"
-tiktoken = ">=0.7.0"
-tokenizers = "*"
-
-[package.extras]
-extra-proxy = ["azure-identity (>=1.15.0,<2.0.0)", "azure-keyvault-secrets (>=4.8.0,<5.0.0)", "google-cloud-kms (>=2.21.3,<3.0.0)", "prisma (==0.11.0)", "resend (>=0.8.0,<0.9.0)"]
-proxy = ["PyJWT (>=2.8.0,<3.0.0)", "apscheduler (>=3.10.4,<4.0.0)", "backoff", "cryptography (>=42.0.5,<43.0.0)", "fastapi (>=0.111.0,<0.112.0)", "fastapi-sso (>=0.10.0,<0.11.0)", "gunicorn (>=22.0.0,<23.0.0)", "orjson (>=3.9.7,<4.0.0)", "pynacl (>=1.5.0,<2.0.0)", "python-multipart (>=0.0.9,<0.0.10)", "pyyaml (>=6.0.1,<7.0.0)", "rq", "uvicorn (>=0.22.0,<0.23.0)"]
-
[[package]]
name = "llama-cloud"
version = "0.0.17"
@@ -4777,7 +4749,7 @@ six = ">=1.5"
name = "python-dotenv"
version = "1.0.1"
description = "Read key-value pairs from a .env file and set them as environment variables"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"},
@@ -5049,7 +5021,7 @@ fastembed-gpu = ["fastembed-gpu (==0.3.6)"]
name = "referencing"
version = "0.35.1"
description = "JSON Referencing + Python"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "referencing-0.35.1-py3-none-any.whl", hash = "sha256:eda6d3234d62814d1c64e305c1331c9a3a6132da475ab6382eaa997b21ee75de"},
@@ -5205,7 +5177,7 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"]
name = "rpds-py"
version = "0.20.0"
description = "Python bindings to Rust's persistent data structures (rpds)"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "rpds_py-0.20.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:3ad0fda1635f8439cde85c700f964b23ed5fc2d28016b32b9ee5fe30da5c84e2"},
@@ -6161,7 +6133,7 @@ test = ["pytest", "tornado (>=4.5)", "typeguard"]
name = "tiktoken"
version = "0.7.0"
description = "tiktoken is a fast BPE tokeniser for use with OpenAI's models"
-optional = false
+optional = true
python-versions = ">=3.8"
files = [
{file = "tiktoken-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:485f3cc6aba7c6b6ce388ba634fbba656d9ee27f766216f45146beb4ac18b25f"},
@@ -7476,4 +7448,4 @@ weaviate = ["weaviate-client"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.9,<3.13"
-content-hash = "bde4c18a93880a262b2ea0bff3965a5bf0b08359da77439f455871b4fde493a0"
+content-hash = "758427544b35e949bda6bb5a57820b14df90563ead51ee13f09bd1f2a6b3d5cd"
diff --git a/pyproject.toml b/pyproject.toml
index 5052b68cc..91f18f59c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,7 +41,7 @@ dependencies = [
"structlog",
"jinja2",
"magicattr~=0.1.6",
- "litellm",
+ # "litellm",
"diskcache"
]
@@ -131,7 +131,7 @@ llama-index = {version = "^0.10.30", optional = true}
snowflake-snowpark-python = { version = "*",optional=true, python = ">=3.9,<3.12" }
jinja2 = "^3.1.3"
magicattr = "^0.1.6"
-litellm = "^1.4.27"
+# litellm = "^1.4.27"
diskcache = "^5.6.0"
diff --git a/requirements.txt b/requirements.txt
index 698575337..46ba0b57a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,5 +12,4 @@ tqdm
ujson
httpx
magicattr~=0.1.6
-litellm
diskcache