diff --git a/sdk-schema/lms-with-inferred-unions.json b/sdk-schema/lms-with-inferred-unions.json index 5d774b6..5d05b4a 100644 --- a/sdk-schema/lms-with-inferred-unions.json +++ b/sdk-schema/lms-with-inferred-unions.json @@ -81,6 +81,78 @@ "propertyName": "type" } }, + "artifactType": { + "type": "string", + "enum": [ + "plugin", + "preset", + "model" + ] + }, + "artifactArtifactDependency": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "artifact", + "default": "artifact", + "title": "Type" + }, + "purpose": { + "$ref": "#/definitions/artifactDependencyPurpose" + }, + "owner": { + "$ref": "#/definitions/kebabCase" + }, + "name": { + "$ref": "#/definitions/kebabCaseWithDots" + } + }, + "required": [ + "type", + "purpose", + "owner", + "name" + ], + "additionalProperties": false + }, + "artifactDependencyBase": { + "type": "object", + "properties": { + "purpose": { + "$ref": "#/definitions/artifactDependencyPurpose" + } + }, + "required": [ + "purpose" + ], + "additionalProperties": false + }, + "artifactDependencyPurpose": { + "type": "string", + "enum": [ + "baseModel", + "draftModel", + "custom" + ] + }, + "artifactDependency": { + "anyOf": [ + { + "$ref": "#/definitions/artifactModelDependency" + }, + { + "$ref": "#/definitions/artifactArtifactDependency" + } + ], + "discriminator": { + "mapping": { + "model": "#/definitions/artifactModelDependency", + "artifact": "#/definitions/artifactArtifactDependency" + }, + "propertyName": "type" + } + }, "artifactManifestBase": { "type": "object", "properties": { @@ -89,28 +161,65 @@ }, "name": { "type": "string", - "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", + "pattern": "^[a-z0-9]+(?:[-.][a-z0-9]+)*$", "minLength": 1, "maxLength": 100 }, - "description": { - "type": "string", - "maxLength": 1000 - }, "revision": { "type": "integer" + }, + "dependencies": { + "type": "array", + "items": { + "$ref": "#/definitions/artifactDependency" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } } }, "required": [ "owner", - "name", - "description" + "name" ], "additionalProperties": false }, - "kebabCase": { - "type": "string", - "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + "artifactModelDependency": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "model", + "default": "model", + "title": "Type" + }, + "purpose": { + "$ref": "#/definitions/artifactDependencyPurpose" + }, + "modelKeys": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "sources": { + "type": "array", + "items": { + "$ref": "#/definitions/modelDownloadSource" + } + } + }, + "required": [ + "type", + "purpose", + "modelKeys", + "sources" + ], + "additionalProperties": false }, "backendNotification": { "type": "object", @@ -309,7 +418,9 @@ }, "arguments": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "$ref": "#/definitions/jsonSerializable" + } }, "name": { "type": "string" @@ -633,6 +744,31 @@ }, "additionalProperties": false }, + "documentParsingLibraryIdentifier": { + "type": "object", + "properties": { + "library": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "library", + "version" + ], + "additionalProperties": false + }, + "documentParsingOpts": { + "type": "object", + "properties": { + "parserId": { + "$ref": "#/definitions/documentParsingLibraryIdentifier" + } + }, + "additionalProperties": false + }, "fileNamespace": { "type": "string", "enum": [ @@ -712,6 +848,15 @@ "custom" ] }, + "jsonSerializable": {}, + "kebabCase": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + }, + "kebabCaseWithDots": { + "type": "string", + "pattern": "^[a-z0-9]+(?:[-.][a-z0-9]+)*$" + }, "kvConfigFieldDependency": { "type": "object", "properties": { @@ -835,6 +980,12 @@ }, "omitEosToken": { "type": "boolean" + }, + "toolDefinitions": { + "type": "array", + "items": { + "$ref": "#/definitions/llmTool" + } } }, "additionalProperties": false @@ -916,6 +1067,9 @@ "gpuStrictVramCap": { "type": "boolean" }, + "offloadKVCacheToGpu": { + "type": "boolean" + }, "contextLength": { "type": "integer", "minimum": 1 @@ -1386,6 +1540,9 @@ }, "reasoningParsing": { "$ref": "#/definitions/llmReasoningParsing" + }, + "raw": { + "$ref": "#/definitions/kvConfig" } }, "additionalProperties": false @@ -1446,6 +1603,9 @@ }, "reasoningParsing": { "$ref": "#/definitions/llmPredictionConfigInput/properties/reasoningParsing" + }, + "raw": { + "$ref": "#/definitions/llmPredictionConfigInput/properties/raw" } }, "additionalProperties": false @@ -1470,6 +1630,21 @@ ], "additionalProperties": false }, + "llmPredictionFragmentInputOpts": { + "type": "object", + "properties": { + "tokenCount": { + "type": "integer" + }, + "containsDrafted": { + "type": "boolean" + }, + "reasoningType": { + "$ref": "#/definitions/llmPredictionFragmentReasoningType" + } + }, + "additionalProperties": false + }, "llmPredictionFragmentReasoningType": { "type": "string", "enum": [ @@ -1589,100 +1764,15 @@ "contextLengthReached" ] }, - "llmJinjaInputConfig": { - "type": "object", - "properties": { - "messagesConfig": { - "$ref": "#/definitions/llmJinjaInputMessagesConfig" - }, - "useTools": { - "type": "boolean" - } - }, - "required": [ - "messagesConfig", - "useTools" - ], - "additionalProperties": false - }, - "llmJinjaInputMessagesConfig": { - "type": "object", - "properties": { - "contentConfig": { - "$ref": "#/definitions/llmJinjaInputMessagesContentConfig" - } - }, - "required": [ - "contentConfig" - ], - "additionalProperties": false - }, - "llmJinjaInputMessagesContentConfig": { - "anyOf": [ - { - "$ref": "#/definitions/llmJinjaInputMessagesContentConfigString" - }, - { - "$ref": "#/definitions/llmJinjaInputMessagesContentConfigArray" - } - ], - "discriminator": { - "mapping": { - "string": "#/definitions/llmJinjaInputMessagesContentConfigString", - "array": "#/definitions/llmJinjaInputMessagesContentConfigArray" - }, - "propertyName": "type" - } - }, - "llmJinjaInputMessagesContentConfigTextFieldName": { - "type": "string", - "enum": [ - "content", - "text" - ] - }, - "llmJinjaInputMessagesContentImagesConfig": { - "anyOf": [ - { - "$ref": "#/definitions/llmJinjaInputMessagesContentImagesConfigSimple" - }, - { - "$ref": "#/definitions/llmJinjaInputMessagesContentImagesConfigNumbered" - }, - { - "$ref": "#/definitions/llmJinjaInputMessagesContentImagesConfigObject" - } - ], - "discriminator": { - "mapping": { - "simple": "#/definitions/llmJinjaInputMessagesContentImagesConfigSimple", - "numbered": "#/definitions/llmJinjaInputMessagesContentImagesConfigNumbered", - "object": "#/definitions/llmJinjaInputMessagesContentImagesConfigObject" - }, - "propertyName": "type" - } - }, "llmJinjaPromptTemplate": { "type": "object", "properties": { "template": { "type": "string" - }, - "bosToken": { - "type": "string" - }, - "eosToken": { - "type": "string" - }, - "inputConfig": { - "$ref": "#/definitions/llmJinjaInputConfig" } }, "required": [ - "template", - "bosToken", - "eosToken", - "inputConfig" + "template" ], "additionalProperties": false }, @@ -1757,7 +1847,7 @@ "$ref": "#/definitions/llmStructuredPredictionType" }, "jsonSchema": { - "$ref": "#/definitions/functionToolCallRequest/properties/arguments/additionalProperties" + "$ref": "#/definitions/jsonSerializable" }, "gbnfGrammar": { "type": "string" @@ -1825,7 +1915,7 @@ "propertyName": "type" } }, - "generatorUpdate": { + "predictionLoopHandlerUpdate": { "anyOf": [ { "$ref": "#/definitions/processingUpdateStatusCreate" @@ -1851,12 +1941,30 @@ { "$ref": "#/definitions/processingUpdateContentBlockReplaceText" }, + { + "$ref": "#/definitions/processingUpdateContentBlockAppendToolRequest" + }, + { + "$ref": "#/definitions/processingUpdateContentBlockReplaceToolRequest" + }, + { + "$ref": "#/definitions/processingUpdateContentBlockAppendToolResult" + }, { "$ref": "#/definitions/processingUpdateContentBlockAttachGenInfo" }, { "$ref": "#/definitions/processingUpdateContentBlockSetStyle" }, + { + "$ref": "#/definitions/processingUpdateToolStatusCreate" + }, + { + "$ref": "#/definitions/processingUpdateToolStatusUpdate" + }, + { + "$ref": "#/definitions/processingUpdateToolStatusArgumentFragment" + }, { "$ref": "#/definitions/processingUpdateSetSenderName" } @@ -1871,8 +1979,14 @@ "contentBlock.create": "#/definitions/processingUpdateContentBlockCreate", "contentBlock.appendText": "#/definitions/processingUpdateContentBlockAppendText", "contentBlock.replaceText": "#/definitions/processingUpdateContentBlockReplaceText", + "contentBlock.appendToolRequest": "#/definitions/processingUpdateContentBlockAppendToolRequest", + "contentBlock.replaceToolRequest": "#/definitions/processingUpdateContentBlockReplaceToolRequest", + "contentBlock.appendToolResult": "#/definitions/processingUpdateContentBlockAppendToolResult", "contentBlock.attachGenInfo": "#/definitions/processingUpdateContentBlockAttachGenInfo", "contentBlock.setStyle": "#/definitions/processingUpdateContentBlockSetStyle", + "toolStatus.create": "#/definitions/processingUpdateToolStatusCreate", + "toolStatus.update": "#/definitions/processingUpdateToolStatusUpdate", + "toolStatus.argumentFragment": "#/definitions/processingUpdateToolStatusArgumentFragment", "setSenderName": "#/definitions/processingUpdateSetSenderName" }, "propertyName": "type" @@ -1907,33 +2021,155 @@ "propertyName": "type" } }, - "blockLocation": { + "processingRequestConfirmToolCall": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "confirmToolCall", + "default": "confirmToolCall", + "title": "Type" + }, + "callId": { + "type": "integer" + }, + "pluginIdentifier": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "object", + "additionalProperties": {} + } + }, + "required": [ + "type", + "callId", + "name", + "parameters" + ], + "additionalProperties": false + }, + "processingRequestResponseConfirmToolCall": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "confirmToolCall", + "default": "confirmToolCall", + "title": "Type" + }, + "result": { + "$ref": "#/definitions/processingRequestResponseConfirmToolCallResult" + } + }, + "required": [ + "type", + "result" + ], + "additionalProperties": false + }, + "processingRequestResponse": { "anyOf": [ { - "$ref": "#/definitions/blockLocationBeforeId" + "$ref": "#/definitions/processingRequestResponseConfirmToolCall" }, { - "$ref": "#/definitions/blockLocationAfterId" + "$ref": "#/definitions/processingRequestResponseTextInput" } ], "discriminator": { "mapping": { - "beforeId": "#/definitions/blockLocationBeforeId", - "afterId": "#/definitions/blockLocationAfterId" + "confirmToolCall": "#/definitions/processingRequestResponseConfirmToolCall", + "textInput": "#/definitions/processingRequestResponseTextInput" }, "propertyName": "type" } }, - "processingUpdateCitationBlockCreate": { + "processingRequestResponseTextInput": { "type": "object", "properties": { "type": { "type": "string", - "const": "citationBlock.create", - "default": "citationBlock.create", + "const": "textInput", + "default": "textInput", "title": "Type" }, - "id": { + "result": { + "type": "string" + } + }, + "required": [ + "type", + "result" + ], + "additionalProperties": false + }, + "processingRequest": { + "anyOf": [ + { + "$ref": "#/definitions/processingRequestConfirmToolCall" + }, + { + "$ref": "#/definitions/processingRequestTextInput" + } + ], + "discriminator": { + "mapping": { + "confirmToolCall": "#/definitions/processingRequestConfirmToolCall", + "textInput": "#/definitions/processingRequestTextInput" + }, + "propertyName": "type" + } + }, + "processingRequestTextInput": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "textInput", + "default": "textInput", + "title": "Type" + }, + "prompt": { + "type": "string" + } + }, + "required": [ + "type", + "prompt" + ], + "additionalProperties": false + }, + "blockLocation": { + "anyOf": [ + { + "$ref": "#/definitions/blockLocationBeforeId" + }, + { + "$ref": "#/definitions/blockLocationAfterId" + } + ], + "discriminator": { + "mapping": { + "beforeId": "#/definitions/blockLocationBeforeId", + "afterId": "#/definitions/blockLocationAfterId" + }, + "propertyName": "type" + } + }, + "processingUpdateCitationBlockCreate": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "citationBlock.create", + "default": "citationBlock.create", + "title": "Type" + }, + "id": { "type": "string" }, "citedText": { @@ -2024,6 +2260,74 @@ ], "additionalProperties": false }, + "processingUpdateContentBlockAppendToolRequest": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "contentBlock.appendToolRequest", + "default": "contentBlock.appendToolRequest", + "title": "Type" + }, + "id": { + "type": "string" + }, + "callId": { + "type": "integer" + }, + "toolCallRequestId": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "object", + "additionalProperties": {} + }, + "pluginIdentifier": { + "type": "string" + } + }, + "required": [ + "type", + "id", + "callId", + "name", + "parameters" + ], + "additionalProperties": false + }, + "processingUpdateContentBlockAppendToolResult": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "contentBlock.appendToolResult", + "default": "contentBlock.appendToolResult", + "title": "Type" + }, + "id": { + "type": "string" + }, + "callId": { + "type": "integer" + }, + "toolCallRequestId": { + "type": "string" + }, + "content": { + "type": "string" + } + }, + "required": [ + "type", + "id", + "callId", + "content" + ], + "additionalProperties": false + }, "processingUpdateContentBlockAttachGenInfo": { "type": "object", "properties": { @@ -2062,6 +2366,15 @@ "includeInContext": { "type": "boolean" }, + "roleOverride": { + "type": "string", + "enum": [ + "user", + "assistant", + "system", + "tool" + ] + }, "style": { "$ref": "#/definitions/contentBlockStyle" }, @@ -2102,6 +2415,44 @@ ], "additionalProperties": false }, + "processingUpdateContentBlockReplaceToolRequest": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "contentBlock.replaceToolRequest", + "default": "contentBlock.replaceToolRequest", + "title": "Type" + }, + "id": { + "type": "string" + }, + "callId": { + "type": "integer" + }, + "toolCallRequestId": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "object", + "additionalProperties": {} + }, + "pluginIdentifier": { + "type": "string" + } + }, + "required": [ + "type", + "id", + "callId", + "name", + "parameters" + ], + "additionalProperties": false + }, "processingUpdateContentBlockSetPrefix": { "type": "object", "properties": { @@ -2217,6 +2568,15 @@ { "$ref": "#/definitions/processingUpdateContentBlockAppendText" }, + { + "$ref": "#/definitions/processingUpdateContentBlockAppendToolRequest" + }, + { + "$ref": "#/definitions/processingUpdateContentBlockReplaceToolRequest" + }, + { + "$ref": "#/definitions/processingUpdateContentBlockAppendToolResult" + }, { "$ref": "#/definitions/processingUpdateContentBlockReplaceText" }, @@ -2232,6 +2592,15 @@ { "$ref": "#/definitions/processingUpdateContentBlockSetStyle" }, + { + "$ref": "#/definitions/processingUpdateToolStatusCreate" + }, + { + "$ref": "#/definitions/processingUpdateToolStatusUpdate" + }, + { + "$ref": "#/definitions/processingUpdateToolStatusArgumentFragment" + }, { "$ref": "#/definitions/processingUpdateSetSenderName" } @@ -2245,11 +2614,17 @@ "debugInfoBlock.create": "#/definitions/processingUpdateDebugInfoBlockCreate", "contentBlock.create": "#/definitions/processingUpdateContentBlockCreate", "contentBlock.appendText": "#/definitions/processingUpdateContentBlockAppendText", + "contentBlock.appendToolRequest": "#/definitions/processingUpdateContentBlockAppendToolRequest", + "contentBlock.replaceToolRequest": "#/definitions/processingUpdateContentBlockReplaceToolRequest", + "contentBlock.appendToolResult": "#/definitions/processingUpdateContentBlockAppendToolResult", "contentBlock.replaceText": "#/definitions/processingUpdateContentBlockReplaceText", "contentBlock.setPrefix": "#/definitions/processingUpdateContentBlockSetPrefix", "contentBlock.setSuffix": "#/definitions/processingUpdateContentBlockSetSuffix", "contentBlock.attachGenInfo": "#/definitions/processingUpdateContentBlockAttachGenInfo", "contentBlock.setStyle": "#/definitions/processingUpdateContentBlockSetStyle", + "toolStatus.create": "#/definitions/processingUpdateToolStatusCreate", + "toolStatus.update": "#/definitions/processingUpdateToolStatusUpdate", + "toolStatus.argumentFragment": "#/definitions/processingUpdateToolStatusArgumentFragment", "setSenderName": "#/definitions/processingUpdateSetSenderName" }, "propertyName": "type" @@ -2345,6 +2720,79 @@ ], "additionalProperties": false }, + "processingUpdateToolStatusArgumentFragment": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "toolStatus.argumentFragment", + "default": "toolStatus.argumentFragment", + "title": "Type" + }, + "id": { + "type": "string" + }, + "content": { + "type": "string" + } + }, + "required": [ + "type", + "id", + "content" + ], + "additionalProperties": false + }, + "processingUpdateToolStatusCreate": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "toolStatus.create", + "default": "toolStatus.create", + "title": "Type" + }, + "id": { + "type": "string" + }, + "callId": { + "type": "integer" + }, + "state": { + "$ref": "#/definitions/toolStatusStepState" + } + }, + "required": [ + "type", + "id", + "callId", + "state" + ], + "additionalProperties": false + }, + "processingUpdateToolStatusUpdate": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "toolStatus.update", + "default": "toolStatus.update", + "title": "Type" + }, + "id": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/toolStatusStepState" + } + }, + "required": [ + "type", + "id", + "state" + ], + "additionalProperties": false + }, "statusStepState": { "type": "object", "properties": { @@ -2371,40 +2819,140 @@ "canceled" ] }, - "getModelOpts": { + "toolStatusStepState": { "type": "object", "properties": { - "modelTag": { + "status": { + "$ref": "#/definitions/toolStatusStepStateStatus" + }, + "customStatus": { "type": "string" }, - "ignoreUserConfig": { - "type": "boolean" + "customWarnings": { + "type": "array", + "items": { + "type": "string" + } } }, + "required": [ + "status", + "customStatus", + "customWarnings" + ], "additionalProperties": false }, - "modelCompatibilityType": { - "type": "string", - "enum": [ - "gguf", - "safetensors", - "onnx", - "ggml", - "mlx_placeholder", - "torch_safetensors" - ] - }, - "modelDomainType": { - "type": "string", - "enum": [ - "llm", - "embedding", - "imageGen", - "transcription", - "tts" - ] - }, - "modelInfo": { + "toolStatusStepStateStatus": { + "anyOf": [ + { + "$ref": "#/definitions/toolStatusStepStateStatusGeneratingToolCall" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusToolCallGenerationFailed" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusToolCallQueued" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusConfirmingToolCall" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusToolCallDenied" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusCallingTool" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusToolCallFailed" + }, + { + "$ref": "#/definitions/toolStatusStepStateStatusToolCallSucceeded" + } + ], + "discriminator": { + "mapping": { + "generatingToolCall": "#/definitions/toolStatusStepStateStatusGeneratingToolCall", + "toolCallGenerationFailed": "#/definitions/toolStatusStepStateStatusToolCallGenerationFailed", + "toolCallQueued": "#/definitions/toolStatusStepStateStatusToolCallQueued", + "confirmingToolCall": "#/definitions/toolStatusStepStateStatusConfirmingToolCall", + "toolCallDenied": "#/definitions/toolStatusStepStateStatusToolCallDenied", + "callingTool": "#/definitions/toolStatusStepStateStatusCallingTool", + "toolCallFailed": "#/definitions/toolStatusStepStateStatusToolCallFailed", + "toolCallSucceeded": "#/definitions/toolStatusStepStateStatusToolCallSucceeded" + }, + "propertyName": "type" + } + }, + "getModelOpts": { + "type": "object", + "properties": { + "modelTag": { + "type": "string" + }, + "ignoreUserConfig": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "modelCompatibilityType": { + "type": "string", + "enum": [ + "gguf", + "safetensors", + "onnx", + "ggml", + "mlx_placeholder", + "torch_safetensors" + ] + }, + "modelDomainType": { + "type": "string", + "enum": [ + "llm", + "embedding", + "imageGen", + "transcription", + "tts" + ] + }, + "huggingFaceModelDownloadSource": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "huggingface", + "default": "huggingface", + "title": "Type" + }, + "user": { + "$ref": "#/definitions/fileName" + }, + "repo": { + "$ref": "#/definitions/fileName" + } + }, + "required": [ + "type", + "user", + "repo" + ], + "additionalProperties": false + }, + "modelDownloadSource": { + "anyOf": [ + { + "$ref": "#/definitions/huggingFaceModelDownloadSource" + } + ], + "discriminator": { + "mapping": { + "huggingface": "#/definitions/huggingFaceModelDownloadSource" + }, + "propertyName": "type" + } + }, + "modelInfo": { "anyOf": [ { "$ref": "#/definitions/llmInfo" @@ -2523,29 +3071,26 @@ "default": "model", "title": "Type" }, - "virtual": { - "type": "boolean", - "const": true - }, "owner": { "$ref": "#/definitions/kebabCase" }, "name": { "$ref": "#/definitions/artifactManifestBase/properties/name" }, - "description": { - "$ref": "#/definitions/artifactManifestBase/properties/description" - }, "revision": { "$ref": "#/definitions/artifactManifestBase/properties/revision" + }, + "dependencies": { + "$ref": "#/definitions/artifactManifestBase/properties/dependencies" + }, + "tags": { + "$ref": "#/definitions/artifactManifestBase/properties/tags" } }, "required": [ "type", - "virtual", "owner", - "name", - "description" + "name" ], "additionalProperties": false }, @@ -2584,6 +3129,14 @@ "propertyName": "type" } }, + "fileName": { + "type": "string", + "pattern": "^[\\p{L}\\p{N}!@#$%^&()\\-_+=,.;'[\\]{}~`][\\p{L}\\p{N}!@#$%^&()\\-_+=,.;'[\\]{}~` ]*(? None: raise RuntimeError(f"Failed to create {_MODEL_PATH!r}") # Generated source code post-processing: # + # * Fix up miscellaneous issues the code generator currently mishandles # * Fix up typed dicts to be defined in terms of nested dicts # * Add an `__all__` definition for wildcard imports (which also # serves as a top level summary of the defined schemas) print("Post-processing generated source code...") - model_source = _MODEL_PATH.read_text() + # Replace unsupported regex character classes with `.` + # https://github.com/python/cpython/issues/95555 + # https://github.com/jcrist/msgspec/issues/860 + model_source = re.sub(r"\\\\p\{[^}]*\}", ".", _MODEL_PATH.read_text()) model_ast = ast.parse(model_source) dict_token_replacements: dict[str, str] = {} exported_names: list[str] = [] diff --git a/src/lmstudio/_kv_config.py b/src/lmstudio/_kv_config.py index 75aa8ba..167c31d 100644 --- a/src/lmstudio/_kv_config.py +++ b/src/lmstudio/_kv_config.py @@ -120,7 +120,9 @@ def to_kv_field( def update_client_config( self, client_config: MutableDictObject, server_value: DictObject ) -> None: - client_container: MutableDictObject = client_config.setdefault(self.client_key, {}) + client_container: MutableDictObject = client_config.setdefault( + self.client_key, {} + ) self.server_to_client(server_value, client_container) @@ -216,6 +218,7 @@ def _gpu_split_config_to_gpu_settings( **_COMMON_MODEL_LOAD_KEYS, "numExperts": ConfigField("numExperts"), "seed": CheckboxField("seed"), + "offloadKVCacheToGpu": ConfigField("offloadKVCacheToGpu"), "llama": { **_COMMON_LLAMA_LOAD_KEYS, "evalBatchSize": ConfigField("evalBatchSize"), diff --git a/src/lmstudio/_sdk_models/__init__.py b/src/lmstudio/_sdk_models/__init__.py index 0d98782..96b9824 100644 --- a/src/lmstudio/_sdk_models/__init__.py +++ b/src/lmstudio/_sdk_models/__init__.py @@ -7,13 +7,29 @@ LogLevel = Literal["debug", "info", "warn", "error"] AllowableEnvVarKeys = Literal["HSA_OVERRIDE_GFX_VERSION"] AllowableEnvVars = Mapping[str, str] | None -KebabCase = Annotated[str, Meta(pattern="^[a-z0-9]+(?:-[a-z0-9]+)*$")] +ArtifactType = Literal["plugin", "preset", "model"] +ArtifactDependencyPurpose = Literal["baseModel", "draftModel", "custom"] +ModelKey = Annotated[str, Meta(min_length=1)] __all__ = [ "Accelerator", "AcceleratorDict", + "ArtifactArtifactDependency", + "ArtifactArtifactDependencyDict", + "ArtifactDependencyBase", + "ArtifactDependencyBaseDict", + "ArtifactDownloadPlan", + "ArtifactDownloadPlanDict", + "ArtifactDownloadPlanModelInfo", + "ArtifactDownloadPlanModelInfoDict", + "ArtifactDownloadPlanNodeArtifact", + "ArtifactDownloadPlanNodeArtifactDict", + "ArtifactDownloadPlanNodeModel", + "ArtifactDownloadPlanNodeModelDict", "ArtifactManifestBase", "ArtifactManifestBaseDict", + "ArtifactModelDependency", + "ArtifactModelDependencyDict", "AssistantResponse", "AssistantResponseDict", "AvailablePresetsSampleItem", @@ -44,6 +60,10 @@ "DiagnosticsLogEventDataLlmPredictionInput", "DiagnosticsLogEventDataLlmPredictionInputDict", "DiagnosticsLogEventDict", + "DocumentParsingLibraryIdentifier", + "DocumentParsingLibraryIdentifierDict", + "DocumentParsingOpts", + "DocumentParsingOptsDict", "DownloadModelChannelRequest", "DownloadModelChannelRequestDict", "DownloadProgressUpdate", @@ -118,6 +138,16 @@ "ErrorDisplayDataGenericSpecificModelUnloadedDict", "FileHandle", "FileHandleDict", + "FilesChannelParseDocumentCreationParameter", + "FilesChannelParseDocumentCreationParameterDict", + "FilesChannelParseDocumentToClientPacketParserLoaded", + "FilesChannelParseDocumentToClientPacketParserLoadedDict", + "FilesChannelParseDocumentToClientPacketProgress", + "FilesChannelParseDocumentToClientPacketProgressDict", + "FilesChannelParseDocumentToClientPacketResult", + "FilesChannelParseDocumentToClientPacketResultDict", + "FilesChannelParseDocumentToServerPacketCancel", + "FilesChannelParseDocumentToServerPacketCancelDict", "FilesChannelRetrieveCreationParameter", "FilesChannelRetrieveCreationParameterDict", "FilesChannelRetrieveToClientPacketOnFileProcessList", @@ -140,6 +170,10 @@ "FilesChannelRetrieveToClientPacketResultDict", "FilesChannelRetrieveToServerPacketStop", "FilesChannelRetrieveToServerPacketStopDict", + "FilesRpcGetDocumentParsingLibraryParameter", + "FilesRpcGetDocumentParsingLibraryParameterDict", + "FilesRpcGetDocumentParsingLibraryReturns", + "FilesRpcGetDocumentParsingLibraryReturnsDict", "FilesRpcGetLocalFileAbsolutePathParameter", "FilesRpcGetLocalFileAbsolutePathParameterDict", "FilesRpcGetLocalFileAbsolutePathReturns", @@ -156,6 +190,8 @@ "GpuSettingDict", "GpuSplitConfig", "GpuSplitConfigDict", + "HuggingFaceModelDownloadSource", + "HuggingFaceModelDownloadSourceDict", "InternalRetrievalResult", "InternalRetrievalResultDict", "InternalRetrievalResultEntry", @@ -180,6 +216,26 @@ "LlmAdditionalInfoDict", "LlmApplyPromptTemplateOpts", "LlmApplyPromptTemplateOptsDict", + "LlmChannelGenerateWithGeneratorCreationParameter", + "LlmChannelGenerateWithGeneratorCreationParameterDict", + "LlmChannelGenerateWithGeneratorToClientPacketFragment", + "LlmChannelGenerateWithGeneratorToClientPacketFragmentDict", + "LlmChannelGenerateWithGeneratorToClientPacketPromptProcessingProgress", + "LlmChannelGenerateWithGeneratorToClientPacketPromptProcessingProgressDict", + "LlmChannelGenerateWithGeneratorToClientPacketSuccess", + "LlmChannelGenerateWithGeneratorToClientPacketSuccessDict", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationArgumentFragmentGenerated", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationArgumentFragmentGeneratedDict", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationEnd", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationEndDict", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationFailed", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationFailedDict", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationNameReceived", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationNameReceivedDict", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationStart", + "LlmChannelGenerateWithGeneratorToClientPacketToolCallGenerationStartDict", + "LlmChannelGenerateWithGeneratorToServerPacketCancel", + "LlmChannelGenerateWithGeneratorToServerPacketCancelDict", "LlmChannelGetOrLoadCreationParameter", "LlmChannelGetOrLoadCreationParameterDict", "LlmChannelGetOrLoadToClientPacketAlreadyLoaded", @@ -210,10 +266,14 @@ "LlmChannelPredictToClientPacketPromptProcessingProgressDict", "LlmChannelPredictToClientPacketSuccess", "LlmChannelPredictToClientPacketSuccessDict", + "LlmChannelPredictToClientPacketToolCallGenerationArgumentFragmentGenerated", + "LlmChannelPredictToClientPacketToolCallGenerationArgumentFragmentGeneratedDict", "LlmChannelPredictToClientPacketToolCallGenerationEnd", "LlmChannelPredictToClientPacketToolCallGenerationEndDict", "LlmChannelPredictToClientPacketToolCallGenerationFailed", "LlmChannelPredictToClientPacketToolCallGenerationFailedDict", + "LlmChannelPredictToClientPacketToolCallGenerationNameReceived", + "LlmChannelPredictToClientPacketToolCallGenerationNameReceivedDict", "LlmChannelPredictToClientPacketToolCallGenerationStart", "LlmChannelPredictToClientPacketToolCallGenerationStartDict", "LlmChannelPredictToServerPacketCancel", @@ -230,20 +290,6 @@ "LlmInstanceAdditionalInfoDict", "LlmInstanceInfo", "LlmInstanceInfoDict", - "LlmJinjaInputConfig", - "LlmJinjaInputConfigDict", - "LlmJinjaInputMessagesConfig", - "LlmJinjaInputMessagesConfigDict", - "LlmJinjaInputMessagesContentConfigArray", - "LlmJinjaInputMessagesContentConfigArrayDict", - "LlmJinjaInputMessagesContentConfigString", - "LlmJinjaInputMessagesContentConfigStringDict", - "LlmJinjaInputMessagesContentImagesConfigNumbered", - "LlmJinjaInputMessagesContentImagesConfigNumberedDict", - "LlmJinjaInputMessagesContentImagesConfigObject", - "LlmJinjaInputMessagesContentImagesConfigObjectDict", - "LlmJinjaInputMessagesContentImagesConfigSimple", - "LlmJinjaInputMessagesContentImagesConfigSimpleDict", "LlmJinjaPromptTemplate", "LlmJinjaPromptTemplateDict", "LlmLlamaMirostatSamplingConfig", @@ -260,6 +306,8 @@ "LlmPredictionConfigInputDict", "LlmPredictionFragment", "LlmPredictionFragmentDict", + "LlmPredictionFragmentInputOpts", + "LlmPredictionFragmentInputOptsDict", "LlmPredictionStats", "LlmPredictionStatsDict", "LlmPromptTemplate", @@ -298,6 +346,10 @@ "LlmToolUseSettingNoneDict", "LlmToolUseSettingToolArray", "LlmToolUseSettingToolArrayDict", + "LocalArtifactFileEntry", + "LocalArtifactFileEntryDict", + "LocalArtifactFileList", + "LocalArtifactFileListDict", "Logprob", "LogprobDict", "Model", @@ -346,6 +398,28 @@ "PluginsChannelSetGeneratorToServerPacketCompleteDict", "PluginsChannelSetGeneratorToServerPacketError", "PluginsChannelSetGeneratorToServerPacketErrorDict", + "PluginsChannelSetGeneratorToServerPacketFragmentGenerated", + "PluginsChannelSetGeneratorToServerPacketFragmentGeneratedDict", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationArgumentFragmentGenerated", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationArgumentFragmentGeneratedDict", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationEnded", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationEndedDict", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationFailed", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationFailedDict", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationNameReceived", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationNameReceivedDict", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationStarted", + "PluginsChannelSetGeneratorToServerPacketToolCallGenerationStartedDict", + "PluginsChannelSetPredictionLoopHandlerToClientPacketAbort", + "PluginsChannelSetPredictionLoopHandlerToClientPacketAbortDict", + "PluginsChannelSetPredictionLoopHandlerToClientPacketHandlePredictionLoop", + "PluginsChannelSetPredictionLoopHandlerToClientPacketHandlePredictionLoopDict", + "PluginsChannelSetPredictionLoopHandlerToServerPacketAborted", + "PluginsChannelSetPredictionLoopHandlerToServerPacketAbortedDict", + "PluginsChannelSetPredictionLoopHandlerToServerPacketComplete", + "PluginsChannelSetPredictionLoopHandlerToServerPacketCompleteDict", + "PluginsChannelSetPredictionLoopHandlerToServerPacketError", + "PluginsChannelSetPredictionLoopHandlerToServerPacketErrorDict", "PluginsChannelSetPreprocessorToClientPacketAbort", "PluginsChannelSetPreprocessorToClientPacketAbortDict", "PluginsChannelSetPreprocessorToClientPacketPreprocess", @@ -356,10 +430,34 @@ "PluginsChannelSetPreprocessorToServerPacketCompleteDict", "PluginsChannelSetPreprocessorToServerPacketError", "PluginsChannelSetPreprocessorToServerPacketErrorDict", + "PluginsChannelSetToolsProviderToClientPacketAbortToolCall", + "PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict", + "PluginsChannelSetToolsProviderToClientPacketCallTool", + "PluginsChannelSetToolsProviderToClientPacketCallToolDict", + "PluginsChannelSetToolsProviderToClientPacketDiscardSession", + "PluginsChannelSetToolsProviderToClientPacketDiscardSessionDict", + "PluginsChannelSetToolsProviderToClientPacketInitSession", + "PluginsChannelSetToolsProviderToClientPacketInitSessionDict", + "PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed", + "PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict", + "PluginsChannelSetToolsProviderToServerPacketSessionInitialized", + "PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict", + "PluginsChannelSetToolsProviderToServerPacketToolCallComplete", + "PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict", + "PluginsChannelSetToolsProviderToServerPacketToolCallError", + "PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict", + "PluginsChannelSetToolsProviderToServerPacketToolCallStatus", + "PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict", + "PluginsChannelSetToolsProviderToServerPacketToolCallWarn", + "PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict", "PluginsRpcProcessingGetOrLoadModelParameter", "PluginsRpcProcessingGetOrLoadModelParameterDict", "PluginsRpcProcessingGetOrLoadModelReturns", "PluginsRpcProcessingGetOrLoadModelReturnsDict", + "PluginsRpcProcessingHandleRequestParameter", + "PluginsRpcProcessingHandleRequestParameterDict", + "PluginsRpcProcessingHandleRequestReturns", + "PluginsRpcProcessingHandleRequestReturnsDict", "PluginsRpcProcessingHandleUpdateParameter", "PluginsRpcProcessingHandleUpdateParameterDict", "PluginsRpcProcessingHasStatusParameter", @@ -376,20 +474,40 @@ "PluginsRpcProcessingSuggestNameParameterDict", "PluginsRpcSetConfigSchematicsParameter", "PluginsRpcSetConfigSchematicsParameterDict", + "PluginsRpcSetGlobalConfigSchematicsParameter", + "PluginsRpcSetGlobalConfigSchematicsParameterDict", "PredictionChannelRequest", "PredictionChannelRequestDict", "PresetManifest", "PresetManifestDict", + "ProcessingRequestConfirmToolCall", + "ProcessingRequestConfirmToolCallDict", + "ProcessingRequestResponseConfirmToolCall", + "ProcessingRequestResponseConfirmToolCallDict", + "ProcessingRequestResponseConfirmToolCallResultAllow", + "ProcessingRequestResponseConfirmToolCallResultAllowDict", + "ProcessingRequestResponseConfirmToolCallResultDeny", + "ProcessingRequestResponseConfirmToolCallResultDenyDict", + "ProcessingRequestResponseTextInput", + "ProcessingRequestResponseTextInputDict", + "ProcessingRequestTextInput", + "ProcessingRequestTextInputDict", "ProcessingUpdateCitationBlockCreate", "ProcessingUpdateCitationBlockCreateDict", "ProcessingUpdateContentBlockAppendText", "ProcessingUpdateContentBlockAppendTextDict", + "ProcessingUpdateContentBlockAppendToolRequest", + "ProcessingUpdateContentBlockAppendToolRequestDict", + "ProcessingUpdateContentBlockAppendToolResult", + "ProcessingUpdateContentBlockAppendToolResultDict", "ProcessingUpdateContentBlockAttachGenInfo", "ProcessingUpdateContentBlockAttachGenInfoDict", "ProcessingUpdateContentBlockCreate", "ProcessingUpdateContentBlockCreateDict", "ProcessingUpdateContentBlockReplaceText", "ProcessingUpdateContentBlockReplaceTextDict", + "ProcessingUpdateContentBlockReplaceToolRequest", + "ProcessingUpdateContentBlockReplaceToolRequestDict", "ProcessingUpdateContentBlockSetPrefix", "ProcessingUpdateContentBlockSetPrefixDict", "ProcessingUpdateContentBlockSetStyle", @@ -406,6 +524,12 @@ "ProcessingUpdateStatusRemoveDict", "ProcessingUpdateStatusUpdate", "ProcessingUpdateStatusUpdateDict", + "ProcessingUpdateToolStatusArgumentFragment", + "ProcessingUpdateToolStatusArgumentFragmentDict", + "ProcessingUpdateToolStatusCreate", + "ProcessingUpdateToolStatusCreateDict", + "ProcessingUpdateToolStatusUpdate", + "ProcessingUpdateToolStatusUpdateDict", "PseudoDiagnostics", "PseudoDiagnosticsChannelStreamLogs", "PseudoDiagnosticsChannelStreamLogsDict", @@ -431,14 +555,20 @@ "PseudoEmbeddingRpcUnloadModel", "PseudoEmbeddingRpcUnloadModelDict", "PseudoFiles", + "PseudoFilesChannelParseDocument", + "PseudoFilesChannelParseDocumentDict", "PseudoFilesChannelRetrieve", "PseudoFilesChannelRetrieveDict", "PseudoFilesDict", + "PseudoFilesRpcGetDocumentParsingLibrary", + "PseudoFilesRpcGetDocumentParsingLibraryDict", "PseudoFilesRpcGetLocalFileAbsolutePath", "PseudoFilesRpcGetLocalFileAbsolutePathDict", "PseudoFilesRpcUploadFileBase64", "PseudoFilesRpcUploadFileBase64Dict", "PseudoLlm", + "PseudoLlmChannelGenerateWithGenerator", + "PseudoLlmChannelGenerateWithGeneratorDict", "PseudoLlmChannelGetOrLoad", "PseudoLlmChannelGetOrLoadDict", "PseudoLlmChannelLoadModel", @@ -467,12 +597,18 @@ "PseudoPluginsChannelRegisterDevelopmentPluginDict", "PseudoPluginsChannelSetGenerator", "PseudoPluginsChannelSetGeneratorDict", + "PseudoPluginsChannelSetPredictionLoopHandler", + "PseudoPluginsChannelSetPredictionLoopHandlerDict", "PseudoPluginsChannelSetPreprocessor", "PseudoPluginsChannelSetPreprocessorDict", + "PseudoPluginsChannelSetToolsProvider", + "PseudoPluginsChannelSetToolsProviderDict", "PseudoPluginsDict", "PseudoPluginsRpcPluginInitCompleted", "PseudoPluginsRpcProcessingGetOrLoadModel", "PseudoPluginsRpcProcessingGetOrLoadModelDict", + "PseudoPluginsRpcProcessingHandleRequest", + "PseudoPluginsRpcProcessingHandleRequestDict", "PseudoPluginsRpcProcessingHandleUpdate", "PseudoPluginsRpcProcessingHandleUpdateDict", "PseudoPluginsRpcProcessingHasStatus", @@ -488,7 +624,11 @@ "PseudoPluginsRpcReindexPlugins", "PseudoPluginsRpcSetConfigSchematics", "PseudoPluginsRpcSetConfigSchematicsDict", + "PseudoPluginsRpcSetGlobalConfigSchematics", + "PseudoPluginsRpcSetGlobalConfigSchematicsDict", "PseudoRepository", + "PseudoRepositoryChannelCreateArtifactDownloadPlan", + "PseudoRepositoryChannelCreateArtifactDownloadPlanDict", "PseudoRepositoryChannelDownloadArtifact", "PseudoRepositoryChannelDownloadArtifactDict", "PseudoRepositoryChannelDownloadModel", @@ -498,21 +638,45 @@ "PseudoRepositoryChannelPushArtifact", "PseudoRepositoryChannelPushArtifactDict", "PseudoRepositoryDict", + "PseudoRepositoryRpcGetLocalArtifactFiles", + "PseudoRepositoryRpcGetLocalArtifactFilesDict", "PseudoRepositoryRpcGetModelDownloadOptions", "PseudoRepositoryRpcGetModelDownloadOptionsDict", "PseudoRepositoryRpcInstallPluginDependencies", "PseudoRepositoryRpcInstallPluginDependenciesDict", + "PseudoRepositoryRpcLoginWithPreAuthenticatedKeys", + "PseudoRepositoryRpcLoginWithPreAuthenticatedKeysDict", "PseudoRepositoryRpcSearchModels", "PseudoRepositoryRpcSearchModelsDict", "PseudoSystem", "PseudoSystemChannelAlive", "PseudoSystemDict", + "PseudoSystemRpcGetExperimentFlags", + "PseudoSystemRpcGetExperimentFlagsDict", "PseudoSystemRpcListDownloadedModels", "PseudoSystemRpcListDownloadedModelsDict", "PseudoSystemRpcNotify", "PseudoSystemRpcNotifyDict", + "PseudoSystemRpcSetExperimentFlag", + "PseudoSystemRpcSetExperimentFlagDict", "PseudoSystemRpcVersion", "PseudoSystemRpcVersionDict", + "RepositoryChannelCreateArtifactDownloadPlanCreationParameter", + "RepositoryChannelCreateArtifactDownloadPlanCreationParameterDict", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketDownloadProgress", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketDownloadProgressDict", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketPlanReady", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketPlanReadyDict", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketPlanUpdated", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketPlanUpdatedDict", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketStartFinalizing", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketStartFinalizingDict", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketSuccess", + "RepositoryChannelCreateArtifactDownloadPlanToClientPacketSuccessDict", + "RepositoryChannelCreateArtifactDownloadPlanToServerPacketCancel", + "RepositoryChannelCreateArtifactDownloadPlanToServerPacketCancelDict", + "RepositoryChannelCreateArtifactDownloadPlanToServerPacketCommit", + "RepositoryChannelCreateArtifactDownloadPlanToServerPacketCommitDict", "RepositoryChannelDownloadArtifactCreationParameter", "RepositoryChannelDownloadArtifactCreationParameterDict", "RepositoryChannelDownloadArtifactToClientPacketDownloadProgress", @@ -539,12 +703,20 @@ "RepositoryChannelPushArtifactCreationParameterDict", "RepositoryChannelPushArtifactToClientPacketMessage", "RepositoryChannelPushArtifactToClientPacketMessageDict", + "RepositoryRpcGetLocalArtifactFilesParameter", + "RepositoryRpcGetLocalArtifactFilesParameterDict", + "RepositoryRpcGetLocalArtifactFilesReturns", + "RepositoryRpcGetLocalArtifactFilesReturnsDict", "RepositoryRpcGetModelDownloadOptionsParameter", "RepositoryRpcGetModelDownloadOptionsParameterDict", "RepositoryRpcGetModelDownloadOptionsReturns", "RepositoryRpcGetModelDownloadOptionsReturnsDict", "RepositoryRpcInstallPluginDependenciesParameter", "RepositoryRpcInstallPluginDependenciesParameterDict", + "RepositoryRpcLoginWithPreAuthenticatedKeysParameter", + "RepositoryRpcLoginWithPreAuthenticatedKeysParameterDict", + "RepositoryRpcLoginWithPreAuthenticatedKeysReturns", + "RepositoryRpcLoginWithPreAuthenticatedKeysReturnsDict", "RepositoryRpcSearchModelsParameter", "RepositoryRpcSearchModelsParameterDict", "RepositoryRpcSearchModelsReturns", @@ -567,6 +739,8 @@ "SystemPromptDict", "SystemRpcNotifyParameter", "SystemRpcNotifyParameterDict", + "SystemRpcSetExperimentFlagParameter", + "SystemRpcSetExperimentFlagParameterDict", "SystemRpcVersionReturns", "SystemRpcVersionReturnsDict", "TextData", @@ -579,10 +753,48 @@ "ToolCallResultDataDict", "ToolResultMessage", "ToolResultMessageDict", + "ToolStatusStepState", + "ToolStatusStepStateDict", + "ToolStatusStepStateStatusCallingTool", + "ToolStatusStepStateStatusCallingToolDict", + "ToolStatusStepStateStatusConfirmingToolCall", + "ToolStatusStepStateStatusConfirmingToolCallDict", + "ToolStatusStepStateStatusGeneratingToolCall", + "ToolStatusStepStateStatusGeneratingToolCallDict", + "ToolStatusStepStateStatusToolCallDenied", + "ToolStatusStepStateStatusToolCallDeniedDict", + "ToolStatusStepStateStatusToolCallFailed", + "ToolStatusStepStateStatusToolCallFailedDict", + "ToolStatusStepStateStatusToolCallGenerationFailed", + "ToolStatusStepStateStatusToolCallGenerationFailedDict", + "ToolStatusStepStateStatusToolCallQueued", + "ToolStatusStepStateStatusToolCallQueuedDict", + "ToolStatusStepStateStatusToolCallSucceeded", + "ToolStatusStepStateStatusToolCallSucceededDict", "UserMessage", "UserMessageDict", - "VirtualModelManifest", - "VirtualModelManifestDict", + "VirtualModelBooleanCustomFieldDefinition", + "VirtualModelBooleanCustomFieldDefinitionDict", + "VirtualModelConditionEquals", + "VirtualModelConditionEqualsDict", + "VirtualModelCustomFieldAppendSystemPromptEffect", + "VirtualModelCustomFieldAppendSystemPromptEffectDict", + "VirtualModelCustomFieldDefinitionBase", + "VirtualModelCustomFieldDefinitionBaseDict", + "VirtualModelCustomFieldPrependSystemPromptEffect", + "VirtualModelCustomFieldPrependSystemPromptEffectDict", + "VirtualModelCustomFieldSetJinjaVariableEffect", + "VirtualModelCustomFieldSetJinjaVariableEffectDict", + "VirtualModelDefinition", + "VirtualModelDefinitionConcreteModelBase", + "VirtualModelDefinitionConcreteModelBaseDict", + "VirtualModelDefinitionDict", + "VirtualModelDefinitionMetadataOverrides", + "VirtualModelDefinitionMetadataOverridesDict", + "VirtualModelStringCustomFieldDefinition", + "VirtualModelStringCustomFieldDefinitionDict", + "VirtualModelSuggestion", + "VirtualModelSuggestionDict", ] @@ -648,29 +860,6 @@ class ToolCallResultDataDict(TypedDict): ChatMessageRoleData = Literal["assistant", "user", "system", "tool"] - - -class ToolCallRequest(LMStudioStruct["ToolCallRequestDict"], kw_only=True): - type: Annotated[Literal["function"], Meta(title="Type")] - name: str - id: str | None = None - arguments: Mapping[str, Any] | None = None - - -class ToolCallRequestDict(TypedDict): - """Corresponding typed dictionary definition for FunctionToolCallRequest. - - NOTE: Multi-word keys are defined using their camelCase form, - as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. - """ - - type: Annotated[Literal["function"], Meta(title="Type")] - name: str - id: NotRequired[str | None] - arguments: NotRequired[Mapping[str, Any] | None] - - -ToolCallRequest = ToolCallRequest PageNumber = Sequence[int] LineNumber = Sequence[int] @@ -758,6 +947,40 @@ class SerializedLMSExtendedErrorDict(TypedDict): rootTitle: NotRequired[Any | None] +class DocumentParsingLibraryIdentifier( + LMStudioStruct["DocumentParsingLibraryIdentifierDict"], kw_only=True +): + library: str + version: str + + +class DocumentParsingLibraryIdentifierDict(TypedDict): + """Corresponding typed dictionary definition for DocumentParsingLibraryIdentifier. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + library: str + version: str + + +class DocumentParsingOpts(LMStudioStruct["DocumentParsingOptsDict"], kw_only=True): + parser_id: DocumentParsingLibraryIdentifier | None = field( + name="parserId", default=None + ) + + +class DocumentParsingOptsDict(TypedDict): + """Corresponding typed dictionary definition for DocumentParsingOpts. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + parserId: NotRequired[DocumentParsingLibraryIdentifierDict | None] + + FileNamespace = Literal["local", "base64"] FileType = Literal[ "image", @@ -771,6 +994,9 @@ class SerializedLMSExtendedErrorDict(TypedDict): PriorityItem = Annotated[int, Meta(ge=0)] CustomRatioItem = Annotated[float, Meta(ge=0.0)] GpuSplitStrategy = Literal["evenly", "priorityOrder", "custom"] +JsonSerializable = Any +KebabCase = Annotated[str, Meta(pattern="^[a-z0-9]+(?:-[a-z0-9]+)*$")] +KebabCaseWithDots = Annotated[str, Meta(pattern="^[a-z0-9]+(?:[-.][a-z0-9]+)*$")] class KvConfigField(LMStudioStruct["KvConfigFieldDict"], kw_only=True): @@ -851,24 +1077,6 @@ class KvConfigStackDict(TypedDict): layers: Sequence[KvConfigStackLayerDict] -class LlmApplyPromptTemplateOpts( - LMStudioStruct["LlmApplyPromptTemplateOptsDict"], kw_only=True -): - omit_bos_token: bool | None = field(name="omitBosToken", default=None) - omit_eos_token: bool | None = field(name="omitEosToken", default=None) - - -class LlmApplyPromptTemplateOptsDict(TypedDict): - """Corresponding typed dictionary definition for LlmApplyPromptTemplateOpts. - - NOTE: Multi-word keys are defined using their camelCase form, - as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. - """ - - omitBosToken: NotRequired[bool | None] - omitEosToken: NotRequired[bool | None] - - LlmLlamaAccelerationOffloadRatio1 = Annotated[float, Meta(ge=0.0, le=1.0)] LlmLlamaAccelerationOffloadRatio = LlmLlamaAccelerationOffloadRatio1 | str LlmLlamaAccelerationOffloadRatioDict = float | str @@ -1018,7 +1226,22 @@ class LlmPredictionFragmentDict(TypedDict): "maxPredictedTokensReached", "contextLengthReached", ] -LlmJinjaInputMessagesContentConfigTextFieldName = Literal["content", "text"] + + +class LlmJinjaPromptTemplate( + LMStudioStruct["LlmJinjaPromptTemplateDict"], kw_only=True +): + template: str + + +class LlmJinjaPromptTemplateDict(TypedDict): + """Corresponding typed dictionary definition for LlmJinjaPromptTemplate. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + template: str class LlmManualPromptTemplate( @@ -1051,6 +1274,77 @@ class LlmManualPromptTemplateDict(TypedDict): LlmStructuredPredictionType = Literal["none", "json", "gbnf"] +class ProcessingRequestConfirmToolCall( + LMStudioStruct["ProcessingRequestConfirmToolCallDict"], + kw_only=True, + tag_field="type", + tag="confirmToolCall", +): + type: ClassVar[Annotated[Literal["confirmToolCall"], Meta(title="Type")]] = ( + "confirmToolCall" + ) + call_id: int = field(name="callId") + name: str + parameters: Mapping[str, Any] + plugin_identifier: str | None = field(name="pluginIdentifier", default=None) + + +class ProcessingRequestConfirmToolCallDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingRequestConfirmToolCall. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["confirmToolCall"] + callId: int + name: str + parameters: Mapping[str, Any] + pluginIdentifier: NotRequired[str | None] + + +class ProcessingRequestResponseTextInput( + LMStudioStruct["ProcessingRequestResponseTextInputDict"], + kw_only=True, + tag_field="type", + tag="textInput", +): + type: ClassVar[Annotated[Literal["textInput"], Meta(title="Type")]] = "textInput" + result: str + + +class ProcessingRequestResponseTextInputDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingRequestResponseTextInput. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["textInput"] + result: str + + +class ProcessingRequestTextInput( + LMStudioStruct["ProcessingRequestTextInputDict"], + kw_only=True, + tag_field="type", + tag="textInput", +): + type: ClassVar[Annotated[Literal["textInput"], Meta(title="Type")]] = "textInput" + prompt: str + + +class ProcessingRequestTextInputDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingRequestTextInput. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["textInput"] + prompt: str + + class ProcessingUpdateCitationBlockCreate( LMStudioStruct["ProcessingUpdateCitationBlockCreateDict"], kw_only=True, @@ -1113,6 +1407,68 @@ class ProcessingUpdateContentBlockAppendTextDict(TypedDict): fromDraftModel: NotRequired[bool | None] +class ProcessingUpdateContentBlockAppendToolRequest( + LMStudioStruct["ProcessingUpdateContentBlockAppendToolRequestDict"], + kw_only=True, + tag_field="type", + tag="contentBlock.appendToolRequest", +): + type: ClassVar[ + Annotated[Literal["contentBlock.appendToolRequest"], Meta(title="Type")] + ] = "contentBlock.appendToolRequest" + id: str + call_id: int = field(name="callId") + name: str + parameters: Mapping[str, Any] + tool_call_request_id: str | None = field(name="toolCallRequestId", default=None) + plugin_identifier: str | None = field(name="pluginIdentifier", default=None) + + +class ProcessingUpdateContentBlockAppendToolRequestDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingUpdateContentBlockAppendToolRequest. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["contentBlock.appendToolRequest"] + id: str + callId: int + name: str + parameters: Mapping[str, Any] + toolCallRequestId: NotRequired[str | None] + pluginIdentifier: NotRequired[str | None] + + +class ProcessingUpdateContentBlockAppendToolResult( + LMStudioStruct["ProcessingUpdateContentBlockAppendToolResultDict"], + kw_only=True, + tag_field="type", + tag="contentBlock.appendToolResult", +): + type: ClassVar[ + Annotated[Literal["contentBlock.appendToolResult"], Meta(title="Type")] + ] = "contentBlock.appendToolResult" + id: str + call_id: int = field(name="callId") + content: str + tool_call_request_id: str | None = field(name="toolCallRequestId", default=None) + + +class ProcessingUpdateContentBlockAppendToolResultDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingUpdateContentBlockAppendToolResult. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["contentBlock.appendToolResult"] + id: str + callId: int + content: str + toolCallRequestId: NotRequired[str | None] + + class ProcessingUpdateContentBlockReplaceText( LMStudioStruct["ProcessingUpdateContentBlockReplaceTextDict"], kw_only=True, @@ -1138,6 +1494,39 @@ class ProcessingUpdateContentBlockReplaceTextDict(TypedDict): text: str +class ProcessingUpdateContentBlockReplaceToolRequest( + LMStudioStruct["ProcessingUpdateContentBlockReplaceToolRequestDict"], + kw_only=True, + tag_field="type", + tag="contentBlock.replaceToolRequest", +): + type: ClassVar[ + Annotated[Literal["contentBlock.replaceToolRequest"], Meta(title="Type")] + ] = "contentBlock.replaceToolRequest" + id: str + call_id: int = field(name="callId") + name: str + parameters: Mapping[str, Any] + tool_call_request_id: str | None = field(name="toolCallRequestId", default=None) + plugin_identifier: str | None = field(name="pluginIdentifier", default=None) + + +class ProcessingUpdateContentBlockReplaceToolRequestDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingUpdateContentBlockReplaceToolRequest. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["contentBlock.replaceToolRequest"] + id: str + callId: int + name: str + parameters: Mapping[str, Any] + toolCallRequestId: NotRequired[str | None] + pluginIdentifier: NotRequired[str | None] + + class ProcessingUpdateContentBlockSetPrefix( LMStudioStruct["ProcessingUpdateContentBlockSetPrefixDict"], kw_only=True, @@ -1259,6 +1648,31 @@ class ProcessingUpdateStatusRemoveDict(TypedDict): id: str +class ProcessingUpdateToolStatusArgumentFragment( + LMStudioStruct["ProcessingUpdateToolStatusArgumentFragmentDict"], + kw_only=True, + tag_field="type", + tag="toolStatus.argumentFragment", +): + type: ClassVar[ + Annotated[Literal["toolStatus.argumentFragment"], Meta(title="Type")] + ] = "toolStatus.argumentFragment" + id: str + content: str + + +class ProcessingUpdateToolStatusArgumentFragmentDict(TypedDict): + """Corresponding typed dictionary definition for ProcessingUpdateToolStatusArgumentFragment. + + NOTE: Multi-word keys are defined using their camelCase form, + as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. + """ + + type: Literal["toolStatus.argumentFragment"] + id: str + content: str + + StatusStepStatus = Literal["waiting", "loading", "done", "error", "canceled"] @@ -1282,10 +1696,81 @@ class GetModelOptsDict(TypedDict): "gguf", "safetensors", "onnx", "ggml", "mlx_placeholder", "torch_safetensors" ] ModelDomainType = Literal["llm", "embedding", "imageGen", "transcription", "tts"] -PluginRunnerType = Literal["ecmascript"] +FileName = Annotated[ + str, + Meta( + pattern="^[..!@#$%^&()\\-_+=,.;'[\\]{}~`][..!@#$%^&()\\-_+=,.;'[\\]{}~` ]*(? T: return self._result def raise_unknown_message_error(self, unknown_message: Any) -> NoReturn: + # TODO: improve forward compatibility by switching this to use warnings.warn + # instead of failing immediately for all unknown messages raise LMStudioUnknownMessageError( f"{self._NOTICE_PREFIX} unexpected message contents: {unknown_message!r}" ) @@ -1234,10 +1236,12 @@ def iter_message_events( # Ignore status updates after cancellation (avoids race condition) return yield from self._update_prompt_processing_progress(progress) - case { - "type": "toolCallGenerationStart", - }: + case {"type": "toolCallGenerationStart"}: self._logger.debug("Notified of pending tool call request generation.") + case {"type": "toolCallGenerationNameReceived"}: + pass # UI event, currently ignored by Python SDK + case {"type": "toolCallGenerationArgumentFragmentGenerated"}: + pass # UI event, currently ignored by Python SDK case { "type": "toolCallGenerationEnd", "toolCallRequest": tool_call_request, @@ -1245,9 +1249,7 @@ def iter_message_events( yield PredictionToolCallEvent( ToolCallRequest._from_api_dict(tool_call_request) ) - case { - "type": "toolCallGenerationFailed", - }: + case {"type": "toolCallGenerationFailed"}: self._logger.warn("Tool call processing generation failed.") yield PredictionToolCallAbortedEvent(None) case {"type": "error", "error": {} as error}: diff --git a/src/lmstudio/schemas.py b/src/lmstudio/schemas.py index 2e4c3dd..4dcefab 100644 --- a/src/lmstudio/schemas.py +++ b/src/lmstudio/schemas.py @@ -94,8 +94,9 @@ def model_json_schema(cls) -> DictSchema: _CAMEL_CASE_OVERRIDES = { - # This is the one key in the API that capitalizes the `V` in `KV` + # `_kv_` in snake_case becomes KV in camelCase "useFp16ForKvCache": "useFp16ForKVCache", + "offloadKvCacheToGpu": "offloadKVCacheToGpu", } _SKIP_FIELD_RECURSION = set( diff --git a/tests/test_inference.py b/tests/test_inference.py index f6c6012..aecfba8 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -287,5 +287,5 @@ def _handle_invalid_request( assert isinstance(tool_failure_exc.__cause__, ZeroDivisionError) # If the content checks prove too flaky in practice, they can be dropped completed_response = predictions[-1].content.lower() - assert "divid" in completed_response # Accepts both "divide" and "dividing" + assert "divid" in completed_response # Accepts both "divide" and "dividing" assert "zero" in completed_response diff --git a/tests/test_kv_config.py b/tests/test_kv_config.py index 213e736..67e0185 100644 --- a/tests/test_kv_config.py +++ b/tests/test_kv_config.py @@ -76,6 +76,7 @@ "llamaKCacheQuantizationType": "q8_0", "llamaVCacheQuantizationType": "f32", "numExperts": 0, + "offloadKVCacheToGpu": False, "ropeFrequencyBase": 10.0, "ropeFrequencyScale": 1.5, "seed": 313, @@ -93,6 +94,7 @@ "llama_k_cache_quantization_type": "q8_0", "llama_v_cache_quantization_type": "f32", "num_experts": 0, + "offload_kv_cache_to_gpu": False, "rope_frequency_base": 10.0, "rope_frequency_scale": 1.5, "seed": 313, @@ -221,6 +223,9 @@ class LlmPredictionConfigStrict(LlmPredictionConfig, forbid_unknown_fields=True) LlmPredictionConfigStrict, ) +# The "raw" debugging field is a special case, with TBD handling +_NOT_YET_MAPPED = {"raw"} + @pytest.mark.parametrize("config_dict,config_type", zip(CONFIG_DICTS, CONFIG_TYPES)) def test_struct_field_coverage( @@ -232,7 +237,7 @@ def test_struct_field_coverage( missing_keys = expected_keys - mapped_keys assert not missing_keys # Ensure no extra keys are mistakenly defined - unknown_keys = mapped_keys - expected_keys + unknown_keys = mapped_keys - expected_keys - _NOT_YET_MAPPED assert not unknown_keys # Ensure the config can be loaded config_struct = config_type._from_api_dict(config_dict) @@ -260,7 +265,7 @@ def test_kv_stack_field_coverage( # Ensure all expected keys are covered (even those with default values) mapped_keys = keymap.keys() expected_keys = set(config_type.__struct_encode_fields__) - missing_keys = expected_keys - mapped_keys + missing_keys = expected_keys - mapped_keys - _NOT_YET_MAPPED assert not missing_keys # Ensure no extra keys are mistakenly defined unknown_keys = mapped_keys - expected_keys @@ -342,6 +347,7 @@ def test_kv_stack_field_coverage( {"key": "llm.load.llama.tryMmap", "value": False}, {"key": "llm.load.llama.useFp16ForKVCache", "value": True}, {"key": "llm.load.numExperts", "value": 0}, + {"key": "llm.load.offloadKVCacheToGpu", "value": False}, {"key": "llm.load.seed", "value": {"checked": True, "value": 313}}, {"key": "load.gpuStrictVramCap", "value": False}, ]