|
1 | 1 | #!/usr/bin/env python |
2 | | -"""Generate Python data model classes from lmstudio.js zod schema. |
| 2 | +"""Generate Python data model classes from lmstudio-js zod schema. |
3 | 3 |
|
4 | 4 | Recreates the Python data model classes from the exported JSON schema |
5 | 5 | (generating the JSON schema only if necessary). |
|
13 | 13 |
|
14 | 14 |
|
15 | 15 | # * invokes `npm run build` and `npm run make-schemas` in the |
16 | | -# `lmstudio.js` submodule's `packages/lms-json-schema` project |
| 16 | +# `lmstudio-js` submodule's `packages/lms-json-schema` project |
17 | 17 | # to create JSON schema files in |
18 | | -# `./lmstudio.js/packages/lms-json-schema/schemas/lms.json` |
| 18 | +# `./lmstudio-js/packages/lms-json-schema/schemas/lms.json` |
19 | 19 | # * uses `datamodel-code-generator` to produce Python data model |
20 | 20 | # classes from the exported JSON schema files |
21 | 21 |
|
|
41 | 41 | ) |
42 | 42 |
|
43 | 43 | _THIS_DIR = Path(__file__).parent |
44 | | -_LMSJS_DIR = _THIS_DIR / "lmstudio.js" |
| 44 | +_LMSJS_DIR = _THIS_DIR / "lmstudio-js" |
45 | 45 | _EXPORTER_DIR = _LMSJS_DIR / "packages/lms-json-schema" |
46 | 46 | _SCHEMA_DIR = _EXPORTER_DIR / "schemas" |
47 | 47 | _SCHEMA_PATH = _SCHEMA_DIR / "lms.json" |
|
64 | 64 |
|
65 | 65 | # TODO: |
66 | 66 | # * Figure out a way to avoid the full clean-and-build |
67 | | -# cycle when regenerating the lmstudio.js JSON schemas |
| 67 | +# cycle when regenerating the lmstudio-js JSON schemas |
68 | 68 | # |
69 | 69 | # * Potentially include models for the websocket channel, |
70 | 70 | # rpc, and signal message formats: |
71 | | -# https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-communication/src/Transport.ts |
| 71 | +# https://github.com/lmstudio-ai/lmstudio-js/blob/main/packages/lms-communication/src/Transport.ts |
72 | 72 |
|
73 | 73 |
|
74 | 74 | def _export_zod_schemas_to_json_schema() -> None: |
75 | | - """Run the lmstudio.js JSON schema export in the submodule.""" |
| 75 | + """Run the lmstudio-js JSON schema export in the submodule.""" |
76 | 76 | _SCHEMA_PATH.unlink(missing_ok=True) |
77 | 77 | _CACHED_SCHEMA_PATH.unlink(missing_ok=True) |
78 | 78 | with chdir(_LMSJS_DIR): |
@@ -123,7 +123,7 @@ def _check_discriminator(tag_field: str, union_array: _SchemaList) -> bool: |
123 | 123 | # Can only be a discriminated union on this tag if all variants have it |
124 | 124 | return False |
125 | 125 | if field_def["type"] != "string": |
126 | | - # Only string based unions are defined in lmstudio.js |
| 126 | + # Only string based unions are defined in lmstudio-js |
127 | 127 | return False |
128 | 128 | tag_value = field_def.get("const", None) |
129 | 129 | if tag_value is None: |
@@ -251,7 +251,7 @@ def _extract_union_variants( |
251 | 251 | def _is_void_union(union_members: _SchemaList) -> _SchemaObject | None: |
252 | 252 | if len(union_members) != 2: |
253 | 253 | return None |
254 | | - # Note: the "void spec" definition is actually an error in the lmstudio.js |
| 254 | + # Note: the "void spec" definition is actually an error in the lmstudio-js |
255 | 255 | # schema exporter, since it is defined as meaning "may be anything" in JSON |
256 | 256 | # schema, but the exporter is wanting to specify "may be omitted entirely". |
257 | 257 | # That "may be omitted" aspect would be specified by declaring the "result" |
|
0 commit comments