From 2135c8ccdc9aeaed6ed8caa03d1c0f3535143643 Mon Sep 17 00:00:00 2001 From: Alyssa Coghlan Date: Thu, 27 Feb 2025 00:15:44 +1000 Subject: [PATCH] Use 'sdk' in schema generator names --- .gitmodules | 4 +- README.md | 12 ++-- lmsjs-schema/README.md | 7 --- pdm.lock | 60 +++++++++---------- pyproject.toml | 4 +- {lmsjs-schema => sdk-schema}/.gitignore | 0 sdk-schema/README.md | 7 +++ .../_templates/msgspec.jinja2 | 0 .../lms-with-inferred-unions.json | 0 {lmsjs-schema => sdk-schema}/lms.json | 0 {lmsjs-schema => sdk-schema}/lmstudio.js | 0 .../sync-sdk-schema.py | 4 +- src/lmstudio/_kv_config.py | 2 +- .../{_lmsjs_models => _sdk_models}/README.md | 2 +- .../__init__.py | 2 +- src/lmstudio/async_api.py | 2 +- src/lmstudio/history.py | 2 +- src/lmstudio/json_api.py | 2 +- src/lmstudio/sync_api.py | 2 +- tests/support/__init__.py | 2 +- tests/test_basics.py | 2 +- tests/test_inference.py | 2 +- tests/test_kv_config.py | 2 +- tests/test_schemas.py | 2 +- tox.ini | 8 +-- 25 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 lmsjs-schema/README.md rename {lmsjs-schema => sdk-schema}/.gitignore (100%) create mode 100644 sdk-schema/README.md rename {lmsjs-schema => sdk-schema}/_templates/msgspec.jinja2 (100%) rename {lmsjs-schema => sdk-schema}/lms-with-inferred-unions.json (100%) rename {lmsjs-schema => sdk-schema}/lms.json (100%) rename {lmsjs-schema => sdk-schema}/lmstudio.js (100%) rename lmsjs-schema/sync-lmsjs-schema.py => sdk-schema/sync-sdk-schema.py (99%) rename src/lmstudio/{_lmsjs_models => _sdk_models}/README.md (85%) rename src/lmstudio/{_lmsjs_models => _sdk_models}/__init__.py (99%) diff --git a/.gitmodules b/.gitmodules index c17159a..f532fd7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "lmsjs-schema/lmstudio.js"] - path = lmsjs-schema/lmstudio.js +[submodule "sdk-schema/lmstudio.js"] + path = sdk-schema/lmstudio.js url = https://github.com/lmstudio-ai/lmstudio.js.git diff --git a/README.md b/README.md index d83f068..61c303e 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ $ git clone https://github.com/lmstudio-ai/lmstudio-python $ cd lmstudio-python ``` -To be able to run `tox -e sync-lmsjs-schema`, it is also +To be able to run `tox -e sync-sdk-schema`, it is also necessary to ensure the `lmstudio.js` submodule is updated: ```console @@ -190,12 +190,12 @@ Additional notes on running and updating the tests can be found in the ### Expanding the API -- the content of `src/lmstudio/_lmsjs_models` is automatically generated by the - `sync-lmsjs-schema.py` script in `lmsjs-schema` and should not be modified directly. - Run `tox -e sync-lmsjs-schema` to regenerate the Python submodule from the existing +- the content of `src/lmstudio/_sdk_models` is automatically generated by the + `sync-sdk-schema.py` script in `sdk-schema` and should not be modified directly. + Run `tox -e sync-sdk-schema` to regenerate the Python submodule from the existing export of the `lmstudio.js` schema (for example, after modifying the data model - template). Run `tox -e sync-lmsjs-schema -- --regen-schema` after updating the - `lmsjs-schema/lmstudio.js` submodule itself to a newer iteration of the + template). Run `tox -e sync-sdk-schema -- --regen-schema` after updating the + `sdk-schema/lmstudio.js` submodule itself to a newer iteration of the `lmstudio.js` JSON API. - as support for new API namespaces is added to the SDK, each should get a dedicated session type (similar to those for the already supported namespaces), even if it diff --git a/lmsjs-schema/README.md b/lmsjs-schema/README.md deleted file mode 100644 index 12534ca..0000000 --- a/lmsjs-schema/README.md +++ /dev/null @@ -1,7 +0,0 @@ -lmstudio.js JSON Schema export -============================== - -`tox -e sync-lmsjs-schema` runs `sync-lmsjs-schema.py` in -a suitably configured Python environment. - -The generated models are written to `../src/lmstudio.js/_lmsjs_models/*.py`. diff --git a/pdm.lock b/pdm.lock index f2cdab2..755c86c 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2,10 +2,10 @@ # It is not intended for manual editing. [metadata] -groups = ["default", "bootstrap", "dev", "docs", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "dev", "docs", "sync-sdk-schema"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:90e521184cf11ed09e729deba3faffdc6bb437a6451beb88d06de5e4caaf95c6" +content_hash = "sha256:704c7dbfc5f920ae8bbcddfacb6a64b6aa03bb62afd79fd0c529210abf7851b4" [[metadata.targets]] requires_python = ">=3.11" @@ -47,7 +47,7 @@ name = "annotated-types" version = "0.7.0" requires_python = ">=3.8" summary = "Reusable constraint types to use with typing.Annotated" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "typing-extensions>=4.0.0; python_version < \"3.9\"", ] @@ -61,7 +61,7 @@ name = "anyio" version = "4.8.0" requires_python = ">=3.9" summary = "High level compatibility layer for multiple asynchronous event loop implementations" -groups = ["default", "bootstrap", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "sync-sdk-schema"] dependencies = [ "exceptiongroup>=1.0.2; python_version < \"3.11\"", "idna>=2.8", @@ -78,7 +78,7 @@ name = "argcomplete" version = "3.5.3" requires_python = ">=3.8" summary = "Bash tab completion for argparse" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "argcomplete-3.5.3-py3-none-any.whl", hash = "sha256:2ab2c4a215c59fd6caaff41a869480a23e8f6a5f910b266c1808037f4e375b61"}, {file = "argcomplete-3.5.3.tar.gz", hash = "sha256:c12bf50eded8aebb298c7b7da7a5ff3ee24dffd9f5281867dfe1424b58c55392"}, @@ -129,7 +129,7 @@ name = "black" version = "25.1.0" requires_python = ">=3.9" summary = "The uncompromising code formatter." -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "click>=8.0.0", "mypy-extensions>=0.4.3", @@ -183,7 +183,7 @@ name = "certifi" version = "2025.1.31" requires_python = ">=3.6" summary = "Python package for providing Mozilla's CA Bundle." -groups = ["default", "bootstrap", "docs", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "docs", "sync-sdk-schema"] files = [ {file = "certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe"}, {file = "certifi-2025.1.31.tar.gz", hash = "sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651"}, @@ -225,7 +225,7 @@ name = "click" version = "8.1.8" requires_python = ">=3.7" summary = "Composable command line interface toolkit" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "colorama; platform_system == \"Windows\"", "importlib-metadata; python_version < \"3.8\"", @@ -240,7 +240,7 @@ name = "colorama" version = "0.4.6" requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" summary = "Cross-platform colored terminal text." -groups = ["dev", "docs", "sync-lmsjs-schema"] +groups = ["dev", "docs", "sync-sdk-schema"] files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -310,7 +310,7 @@ name = "datamodel-code-generator" version = "0.28.1" requires_python = ">=3.9" summary = "Datamodel Code Generator" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "argcomplete<4,>=2.10.1", "black>=19.10b0", @@ -334,7 +334,7 @@ version = "0.28.1" extras = ["http"] requires_python = ">=3.9" summary = "Datamodel Code Generator" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "datamodel-code-generator==0.28.1", "httpx>=0.24.1", @@ -425,7 +425,7 @@ files = [ name = "genson" version = "1.3.0" summary = "GenSON is a powerful, user-friendly JSON Schema generator." -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "genson-1.3.0-py3-none-any.whl", hash = "sha256:468feccd00274cc7e4c09e84b08704270ba8d95232aa280f65b986139cec67f7"}, {file = "genson-1.3.0.tar.gz", hash = "sha256:e02db9ac2e3fd29e65b5286f7135762e2cd8a986537c075b06fc5f1517308e37"}, @@ -436,7 +436,7 @@ name = "h11" version = "0.14.0" requires_python = ">=3.7" summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" -groups = ["default", "bootstrap", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "sync-sdk-schema"] dependencies = [ "typing-extensions; python_version < \"3.8\"", ] @@ -464,7 +464,7 @@ name = "httpcore" version = "1.0.7" requires_python = ">=3.8" summary = "A minimal low-level HTTP client." -groups = ["default", "bootstrap", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "sync-sdk-schema"] dependencies = [ "certifi", "h11<0.15,>=0.13", @@ -479,7 +479,7 @@ name = "httpx" version = "0.28.1" requires_python = ">=3.8" summary = "The next generation HTTP client." -groups = ["default", "bootstrap", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "sync-sdk-schema"] dependencies = [ "anyio", "certifi", @@ -529,7 +529,7 @@ name = "idna" version = "3.10" requires_python = ">=3.6" summary = "Internationalized Domain Names in Applications (IDNA)" -groups = ["default", "bootstrap", "docs", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "docs", "sync-sdk-schema"] files = [ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, @@ -551,7 +551,7 @@ name = "inflect" version = "5.6.2" requires_python = ">=3.7" summary = "Correctly generate plurals, singular nouns, ordinals, indefinite articles; convert numbers to words" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "inflect-5.6.2-py3-none-any.whl", hash = "sha256:b45d91a4a28a4e617ff1821117439b06eaa86e2a4573154af0149e9be6687238"}, {file = "inflect-5.6.2.tar.gz", hash = "sha256:aadc7ed73928f5e014129794bbac03058cca35d0a973a5fc4eb45c7fa26005f9"}, @@ -584,7 +584,7 @@ name = "isort" version = "6.0.0" requires_python = ">=3.9.0" summary = "A Python utility / library to sort Python imports." -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "isort-6.0.0-py3-none-any.whl", hash = "sha256:567954102bb47bb12e0fae62606570faacddd441e45683968c8d1734fb1af892"}, {file = "isort-6.0.0.tar.gz", hash = "sha256:75d9d8a1438a9432a7d7b54f2d3b45cad9a4a0fdba43617d9873379704a8bdf1"}, @@ -595,7 +595,7 @@ name = "jinja2" version = "3.1.5" requires_python = ">=3.7" summary = "A very fast and expressive template engine." -groups = ["docs", "sync-lmsjs-schema"] +groups = ["docs", "sync-sdk-schema"] dependencies = [ "MarkupSafe>=2.0", ] @@ -623,7 +623,7 @@ name = "markupsafe" version = "3.0.2" requires_python = ">=3.9" summary = "Safely add untrusted strings to HTML/XML markup." -groups = ["docs", "sync-lmsjs-schema"] +groups = ["docs", "sync-sdk-schema"] files = [ {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d"}, {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93"}, @@ -735,7 +735,7 @@ name = "mypy-extensions" version = "1.0.0" requires_python = ">=3.5" summary = "Type system extensions for programs checked with the mypy type checker." -groups = ["dev", "sync-lmsjs-schema"] +groups = ["dev", "sync-sdk-schema"] files = [ {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, @@ -746,7 +746,7 @@ name = "packaging" version = "24.2" requires_python = ">=3.8" summary = "Core utilities for Python packages" -groups = ["bootstrap", "dev", "docs", "sync-lmsjs-schema"] +groups = ["bootstrap", "dev", "docs", "sync-sdk-schema"] files = [ {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, @@ -757,7 +757,7 @@ name = "pathspec" version = "0.12.1" requires_python = ">=3.8" summary = "Utility library for gitignore style pattern matching of file paths." -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -816,7 +816,7 @@ name = "platformdirs" version = "4.3.6" requires_python = ">=3.8" summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -groups = ["bootstrap", "dev", "sync-lmsjs-schema"] +groups = ["bootstrap", "dev", "sync-sdk-schema"] files = [ {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, @@ -838,7 +838,7 @@ name = "pydantic" version = "2.10.6" requires_python = ">=3.8" summary = "Data validation using Python type hints" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "annotated-types>=0.6.0", "pydantic-core==2.27.2", @@ -854,7 +854,7 @@ name = "pydantic-core" version = "2.27.2" requires_python = ">=3.8" summary = "Core functionality for Pydantic validation and serialization" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] dependencies = [ "typing-extensions!=4.7.0,>=4.6.0", ] @@ -981,7 +981,7 @@ name = "pyyaml" version = "6.0.2" requires_python = ">=3.8" summary = "YAML parser and emitter for Python" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] files = [ {file = "PyYAML-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774"}, {file = "PyYAML-6.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee"}, @@ -1087,7 +1087,7 @@ name = "sniffio" version = "1.3.1" requires_python = ">=3.7" summary = "Sniff out which async library your code is running under" -groups = ["default", "bootstrap", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "sync-sdk-schema"] files = [ {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, @@ -1254,7 +1254,7 @@ name = "tomli" version = "2.2.1" requires_python = ">=3.8" summary = "A lil' TOML parser" -groups = ["sync-lmsjs-schema"] +groups = ["sync-sdk-schema"] marker = "python_version <= \"3.11\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, @@ -1353,7 +1353,7 @@ name = "typing-extensions" version = "4.12.2" requires_python = ">=3.8" summary = "Backported and Experimental Type Hints for Python 3.8+" -groups = ["default", "bootstrap", "dev", "docs", "sync-lmsjs-schema"] +groups = ["default", "bootstrap", "dev", "docs", "sync-sdk-schema"] files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, diff --git a/pyproject.toml b/pyproject.toml index d605d45..e6f02e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ dependencies = [ "typing-extensions>=4.12.2", ] -# Keep this in sync with the target Python version in sync-lmsjs-schema.py +# Keep this in sync with the target Python version in sync-sdk-schema.py requires-python = ">=3.11" readme = "README.md" @@ -71,7 +71,7 @@ dev = [ bootstrap = [ "pdm>=2.16.1", ] -sync-lmsjs-schema = [ +sync-sdk-schema = [ # Needs https://github.com/koxudaxi/datamodel-code-generator/issues/2211 fix "datamodel-code-generator[http]>=0.26.4", ] diff --git a/lmsjs-schema/.gitignore b/sdk-schema/.gitignore similarity index 100% rename from lmsjs-schema/.gitignore rename to sdk-schema/.gitignore diff --git a/sdk-schema/README.md b/sdk-schema/README.md new file mode 100644 index 0000000..66a2aa3 --- /dev/null +++ b/sdk-schema/README.md @@ -0,0 +1,7 @@ +lmstudio.js JSON Schema export +============================== + +`tox -e sync-sdk-schema` runs `sync-sdk-schema.py` in +a suitably configured Python environment. + +The generated models are written to `../src/lmstudio.js/_sdk_models/*.py`. diff --git a/lmsjs-schema/_templates/msgspec.jinja2 b/sdk-schema/_templates/msgspec.jinja2 similarity index 100% rename from lmsjs-schema/_templates/msgspec.jinja2 rename to sdk-schema/_templates/msgspec.jinja2 diff --git a/lmsjs-schema/lms-with-inferred-unions.json b/sdk-schema/lms-with-inferred-unions.json similarity index 100% rename from lmsjs-schema/lms-with-inferred-unions.json rename to sdk-schema/lms-with-inferred-unions.json diff --git a/lmsjs-schema/lms.json b/sdk-schema/lms.json similarity index 100% rename from lmsjs-schema/lms.json rename to sdk-schema/lms.json diff --git a/lmsjs-schema/lmstudio.js b/sdk-schema/lmstudio.js similarity index 100% rename from lmsjs-schema/lmstudio.js rename to sdk-schema/lmstudio.js diff --git a/lmsjs-schema/sync-lmsjs-schema.py b/sdk-schema/sync-sdk-schema.py similarity index 99% rename from lmsjs-schema/sync-lmsjs-schema.py rename to sdk-schema/sync-sdk-schema.py index 8ca9b27..ae7d214 100755 --- a/lmsjs-schema/sync-lmsjs-schema.py +++ b/sdk-schema/sync-sdk-schema.py @@ -9,7 +9,7 @@ # Uses `npm run zod-to-json-schema` to populate `./_json_schema` # Uses https://github.com/koxudaxi/datamodel-code-generator/ # to emit Python data model classes for the defined JSON schemas -# to `../src/lmstudio/_lmsjs_models` +# to `../src/lmstudio/_sdk_models` # * invokes `npm run build` and `npm run make-schemas` in the @@ -48,7 +48,7 @@ _CACHED_SCHEMA_PATH = _THIS_DIR / _SCHEMA_PATH.name _INFERRED_SCHEMA_PATH = _THIS_DIR / "lms-with-inferred-unions.json" _TEMPLATE_DIR = _THIS_DIR / "_templates" -_MODEL_DIR = _THIS_DIR.parent / "src/lmstudio/_lmsjs_models" +_MODEL_DIR = _THIS_DIR.parent / "src/lmstudio/_sdk_models" _MODEL_PATH = _MODEL_DIR / "__init__.py" # The following schemas are not actually used anywhere, diff --git a/src/lmstudio/_kv_config.py b/src/lmstudio/_kv_config.py index 492751a..cd5077b 100644 --- a/src/lmstudio/_kv_config.py +++ b/src/lmstudio/_kv_config.py @@ -6,7 +6,7 @@ from .sdk_api import LMStudioValueError from .schemas import DictSchema, DictObject, ModelSchema -from ._lmsjs_models import ( +from ._sdk_models import ( EmbeddingLoadModelConfig, EmbeddingLoadModelConfigDict, KvConfig, diff --git a/src/lmstudio/_lmsjs_models/README.md b/src/lmstudio/_sdk_models/README.md similarity index 85% rename from src/lmstudio/_lmsjs_models/README.md rename to src/lmstudio/_sdk_models/README.md index c7f51e2..82a2577 100644 --- a/src/lmstudio/_lmsjs_models/README.md +++ b/src/lmstudio/_sdk_models/README.md @@ -8,4 +8,4 @@ These files should NOT be modified: if the messaging protocol details change, updates should be made in lmstudio.js first, and then exported to the Python SDK via the automated code generation. -See the `lmsjs-schema` exporter folder for additional details. +See the `sdk-schema` exporter folder for additional details. diff --git a/src/lmstudio/_lmsjs_models/__init__.py b/src/lmstudio/_sdk_models/__init__.py similarity index 99% rename from src/lmstudio/_lmsjs_models/__init__.py rename to src/lmstudio/_sdk_models/__init__.py index 4edde6b..24b0778 100644 --- a/src/lmstudio/_lmsjs_models/__init__.py +++ b/src/lmstudio/_sdk_models/__init__.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: lms-with-inferred-unions.json -# timestamp: 2025-02-26T14:00:06+00:00 +# timestamp: 2025-02-26T14:13:24+00:00 from __future__ import annotations diff --git a/src/lmstudio/async_api.py b/src/lmstudio/async_api.py index 2450b52..6c9759b 100644 --- a/src/lmstudio/async_api.py +++ b/src/lmstudio/async_api.py @@ -83,7 +83,7 @@ _model_spec_to_api_dict, ) from ._kv_config import TLoadConfig, TLoadConfigDict, dict_from_fields_key -from ._lmsjs_models import ( +from ._sdk_models import ( DownloadProgressUpdate, EmbeddingRpcEmbedStringParameter, EmbeddingRpcTokenizeParameter, diff --git a/src/lmstudio/history.py b/src/lmstudio/history.py index 80224eb..7a1a6d7 100644 --- a/src/lmstudio/history.py +++ b/src/lmstudio/history.py @@ -34,7 +34,7 @@ sdk_public_api, ) from .schemas import DictObject, LMStudioStruct, _format_json -from ._lmsjs_models import ( +from ._sdk_models import ( ChatHistoryData, ChatHistoryDataDict, ChatMessageData as AnyChatMessage, diff --git a/src/lmstudio/json_api.py b/src/lmstudio/json_api.py index 5dfea51..9e2b87e 100644 --- a/src/lmstudio/json_api.py +++ b/src/lmstudio/json_api.py @@ -59,7 +59,7 @@ load_config_to_kv_config_stack, prediction_config_to_kv_config_stack, ) -from ._lmsjs_models import ( +from ._sdk_models import ( DownloadProgressUpdate, EmbeddingChannelLoadModelCreationParameter, EmbeddingChannelLoadModelCreationParameterDict, diff --git a/src/lmstudio/sync_api.py b/src/lmstudio/sync_api.py index 0ba5c53..cbd06c3 100644 --- a/src/lmstudio/sync_api.py +++ b/src/lmstudio/sync_api.py @@ -103,7 +103,7 @@ _model_spec_to_api_dict, ) from ._kv_config import TLoadConfig, TLoadConfigDict, dict_from_fields_key -from ._lmsjs_models import ( +from ._sdk_models import ( DownloadProgressUpdate, EmbeddingRpcEmbedStringParameter, EmbeddingRpcTokenizeParameter, diff --git a/tests/support/__init__.py b/tests/support/__init__.py index 6b4d9a0..a3f93a2 100644 --- a/tests/support/__init__.py +++ b/tests/support/__init__.py @@ -16,7 +16,7 @@ LMStudioChannelClosedError, ) from lmstudio.json_api import ChannelEndpoint -from lmstudio._lmsjs_models import LlmPredictionConfigDict +from lmstudio._sdk_models import LlmPredictionConfigDict # Imports from the nominal "SDK" used in some test cases from .lmstudio import ErrFunc diff --git a/tests/test_basics.py b/tests/test_basics.py index 4dfe1aa..f89ae39 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -43,7 +43,7 @@ def _find_unknown_numbered_schemas(schema_names: Set[str]) -> FrozenSet[str]: def test_no_automatic_schema_numbering() -> None: # Ensure the schema conversion only produces named types numbered_schemas: set[str] = set() - for name, obj in lmstudio._lmsjs_models.__dict__.items(): + for name, obj in lmstudio._sdk_models.__dict__.items(): if isinstance(obj, type) and issubclass(obj, Struct) and name[-1].isdigit(): numbered_schemas.add(name) unknown_numbered_schemas = _find_unknown_numbered_schemas(numbered_schemas) diff --git a/tests/test_inference.py b/tests/test_inference.py index 15932d0..35e6d2c 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -23,7 +23,7 @@ ToolFunctionDefDict, ) from lmstudio.json_api import ChatResponseEndpoint -from lmstudio._lmsjs_models import LlmToolParameters +from lmstudio._sdk_models import LlmToolParameters from .support import ( EXPECTED_LLM_ID, diff --git a/tests/test_kv_config.py b/tests/test_kv_config.py index e00ee69..9d4f60b 100644 --- a/tests/test_kv_config.py +++ b/tests/test_kv_config.py @@ -17,7 +17,7 @@ load_config_to_kv_config_stack, prediction_config_to_kv_config_stack, ) -from lmstudio._lmsjs_models import ( +from lmstudio._sdk_models import ( EmbeddingLoadModelConfig, EmbeddingLoadModelConfigDict, GpuSetting, diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 621709e..28b8e99 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -12,7 +12,7 @@ ModelTypesEmbedding, ModelTypesLlm, ) -from lmstudio._lmsjs_models import ( +from lmstudio._sdk_models import ( ModelSpecifierInstanceReference, ModelSpecifierInstanceReferenceDict, ModelSpecifierQuery, diff --git a/tox.ini b/tox.ini index 0f9f334..11f1903 100644 --- a/tox.ini +++ b/tox.ini @@ -42,7 +42,7 @@ commands = allowlist_externals = ruff skip_install = true commands = - ruff format {posargs} src/ tests/ lmsjs-schema/sync-lmsjs-schema.py + ruff format {posargs} src/ tests/ sdk-schema/sync-sdk-schema.py [testenv:lint] allowlist_externals = ruff @@ -55,12 +55,12 @@ allowlist_externals = mypy commands = mypy --strict {posargs} src/ tests/ -[testenv:sync-lmsjs-schema] +[testenv:sync-sdk-schema] allowlist_externals = python -groups = sync-lmsjs-schema +groups = sync-sdk-schema skip_install = true commands = - python lmsjs-schema/sync-lmsjs-schema.py {posargs} + python sdk-schema/sync-sdk-schema.py {posargs} [testenv:docs] groups =