diff --git a/.gitmodules b/.gitmodules index f532fd7..ec15e9c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "sdk-schema/lmstudio.js"] - path = sdk-schema/lmstudio.js - url = https://github.com/lmstudio-ai/lmstudio.js.git +[submodule "sdk-schema/lmstudio-js"] + path = sdk-schema/lmstudio-js + url = https://github.com/lmstudio-ai/lmstudio-js.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9851591..8c30591 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ First off, thank you for considering contributing to our open source projects! There are many ways to help, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or contributing code which can be incorporated into the SDK itself. -Note: the SDK documentation is maintained in combination with the [`lmstudio.js`](https://github.com/lmstudio-ai/lmstudio.js) +Note: the SDK documentation is maintained in combination with [`lmstudio-js`](https://github.com/lmstudio-ai/lmstudio-js) in a dedicated [documentation repo](https://github.com/lmstudio-ai/docs). ## Communication @@ -75,11 +75,11 @@ on working with the `lmstudio-python` code and test suite. `lmstudio-python` communicates with LM Studio through its native dedicated websocket API, rather than via its Open AI compatibility layer. -- **How does `lmstudio-python` relate to `lmstudio.js`?** +- **How does `lmstudio-python` relate to `lmstudio-js`?** - `lmstudio-python` communicates with LM Studio based on JSON interface types defined in `lmstudio.js`. - The `lmstudio-python` repository includes `lmstudio.js` as a submodule in order to support generating - the Python API interface classes from the JSON schema definitions exported by `lmstudio.js`. + `lmstudio-python` communicates with LM Studio based on JSON interface types defined in `lmstudio-js`. + The `lmstudio-python` repository includes `lmstudio-js` as a submodule in order to support generating + the Python API interface classes from the JSON schema definitions exported by `lmstudio-js`. ## Questions diff --git a/README.md b/README.md index 61c303e..30119d4 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ $ cd lmstudio-python ``` To be able to run `tox -e sync-sdk-schema`, it is also -necessary to ensure the `lmstudio.js` submodule is updated: +necessary to ensure the `lmstudio-js` submodule is updated: ```console $ git submodule update --init --recursive @@ -193,10 +193,10 @@ Additional notes on running and updating the tests can be found in the - 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 + export of the `lmstudio-js` schema (for example, after modifying the data model 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. + `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 is only used privately by the client implementation. diff --git a/sdk-schema/README.md b/sdk-schema/README.md index 66a2aa3..6ac3919 100644 --- a/sdk-schema/README.md +++ b/sdk-schema/README.md @@ -1,7 +1,7 @@ -lmstudio.js JSON Schema export +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`. +The generated models are written to `../src/lmstudio/_sdk_models/*.py`. diff --git a/sdk-schema/lmstudio-js b/sdk-schema/lmstudio-js new file mode 160000 index 0000000..12af436 --- /dev/null +++ b/sdk-schema/lmstudio-js @@ -0,0 +1 @@ +Subproject commit 12af436862cd393004c8f8668d29f3ed10a092c0 diff --git a/sdk-schema/lmstudio.js b/sdk-schema/lmstudio.js deleted file mode 160000 index 0a90e92..0000000 --- a/sdk-schema/lmstudio.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a90e9270e27ee76f8b014ce2f0f153aac4aa4d7 diff --git a/sdk-schema/sync-sdk-schema.py b/sdk-schema/sync-sdk-schema.py index ae7d214..9cc9a2e 100755 --- a/sdk-schema/sync-sdk-schema.py +++ b/sdk-schema/sync-sdk-schema.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""Generate Python data model classes from lmstudio.js zod schema. +"""Generate Python data model classes from lmstudio-js zod schema. Recreates the Python data model classes from the exported JSON schema (generating the JSON schema only if necessary). @@ -13,9 +13,9 @@ # * invokes `npm run build` and `npm run make-schemas` in the -# `lmstudio.js` submodule's `packages/lms-json-schema` project +# `lmstudio-js` submodule's `packages/lms-json-schema` project # to create JSON schema files in -# `./lmstudio.js/packages/lms-json-schema/schemas/lms.json` +# `./lmstudio-js/packages/lms-json-schema/schemas/lms.json` # * uses `datamodel-code-generator` to produce Python data model # classes from the exported JSON schema files @@ -41,7 +41,7 @@ ) _THIS_DIR = Path(__file__).parent -_LMSJS_DIR = _THIS_DIR / "lmstudio.js" +_LMSJS_DIR = _THIS_DIR / "lmstudio-js" _EXPORTER_DIR = _LMSJS_DIR / "packages/lms-json-schema" _SCHEMA_DIR = _EXPORTER_DIR / "schemas" _SCHEMA_PATH = _SCHEMA_DIR / "lms.json" @@ -64,15 +64,15 @@ # TODO: # * Figure out a way to avoid the full clean-and-build -# cycle when regenerating the lmstudio.js JSON schemas +# cycle when regenerating the lmstudio-js JSON schemas # # * Potentially include models for the websocket channel, # rpc, and signal message formats: -# https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-communication/src/Transport.ts +# https://github.com/lmstudio-ai/lmstudio-js/blob/main/packages/lms-communication/src/Transport.ts def _export_zod_schemas_to_json_schema() -> None: - """Run the lmstudio.js JSON schema export in the submodule.""" + """Run the lmstudio-js JSON schema export in the submodule.""" _SCHEMA_PATH.unlink(missing_ok=True) _CACHED_SCHEMA_PATH.unlink(missing_ok=True) with chdir(_LMSJS_DIR): @@ -123,7 +123,7 @@ def _check_discriminator(tag_field: str, union_array: _SchemaList) -> bool: # Can only be a discriminated union on this tag if all variants have it return False if field_def["type"] != "string": - # Only string based unions are defined in lmstudio.js + # Only string based unions are defined in lmstudio-js return False tag_value = field_def.get("const", None) if tag_value is None: @@ -251,7 +251,7 @@ def _extract_union_variants( def _is_void_union(union_members: _SchemaList) -> _SchemaObject | None: if len(union_members) != 2: return None - # Note: the "void spec" definition is actually an error in the lmstudio.js + # Note: the "void spec" definition is actually an error in the lmstudio-js # schema exporter, since it is defined as meaning "may be anything" in JSON # schema, but the exporter is wanting to specify "may be omitted entirely". # That "may be omitted" aspect would be specified by declaring the "result" diff --git a/src/lmstudio/_kv_config.py b/src/lmstudio/_kv_config.py index cd5077b..a3e7541 100644 --- a/src/lmstudio/_kv_config.py +++ b/src/lmstudio/_kv_config.py @@ -1,7 +1,7 @@ """Conversion between dicts/public config structs and server KVConfig(Stack)s.""" # Known KV config settings are defined in -# https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-kv-config/src/schema.ts +# https://github.com/lmstudio-ai/lmstudio-js/blob/main/packages/lms-kv-config/src/schema.ts from typing import Any, Sequence, Type, TypeVar from .sdk_api import LMStudioValueError @@ -19,7 +19,7 @@ LlmPredictionConfigDict, ) -# TODO we can reasonably add unit tests for this module: compare against lmstudio.js? +# TODO we can reasonably add unit tests for this module: compare against lmstudio-js? TLoadConfig = TypeVar("TLoadConfig", LlmLoadModelConfig, EmbeddingLoadModelConfig) @@ -113,7 +113,7 @@ def _to_kv_config_stack_base( fields: list[KvConfigFieldDict] = [] # TODO: Define a JSON or TOML data file for mapping prediction config # fields to config stack entries (preferably JSON exported by - # lmstudio.js rather than something maintained in the Python SDK) + # lmstudio-js rather than something maintained in the Python SDK) for client_key in checkbox_keys: if client_key in config: diff --git a/src/lmstudio/_sdk_models/README.md b/src/lmstudio/_sdk_models/README.md index 82a2577..e32cfcf 100644 --- a/src/lmstudio/_sdk_models/README.md +++ b/src/lmstudio/_sdk_models/README.md @@ -1,11 +1,11 @@ -lmstudio.js Pydantic Models -=========================== +lmstudio-js SDK Data Model +========================== -The Pydantic model files in this folder are generated from the -lmstudio.js zod schema files rather than being maintained directly. +The Python data model class definitions in this folder are generated from +the lmstudio-js zod schema files rather than being maintained directly. These files should NOT be modified: if the messaging protocol details -change, updates should be made in lmstudio.js first, and then exported +change, updates should be made in lmstudio-js first, and then exported to the Python SDK via the automated code generation. See the `sdk-schema` exporter folder for additional details. diff --git a/src/lmstudio/_sdk_models/__init__.py b/src/lmstudio/_sdk_models/__init__.py index 24b0778..b4b3ee6 100644 --- a/src/lmstudio/_sdk_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:13:24+00:00 +# timestamp: 2025-02-27T03:57:00+00:00 from __future__ import annotations