diff --git a/sdk-schema/sync-sdk-schema.py b/sdk-schema/sync-sdk-schema.py index dc2c38e..7f3dda1 100755 --- a/sdk-schema/sync-sdk-schema.py +++ b/sdk-schema/sync-sdk-schema.py @@ -355,6 +355,7 @@ def _infer_schema_unions() -> None: "ChatMessagePartToolCallRequestDataDict": "ToolCallRequestDataDict", "ChatMessagePartToolCallResultData": "ToolCallResultData", "ChatMessagePartToolCallResultDataDict": "ToolCallResultDataDict", + "FunctionToolCallRequest": "ToolCallRequest", "FunctionToolCallRequestDict": "ToolCallRequestDict", # Prettier channel creation type names "LlmChannelPredictCreationParameter": "PredictionChannelRequest", @@ -431,7 +432,9 @@ def _generate_data_model_from_json_schema() -> None: if override_name is not None: name_constant.value = override_name # Scan top level nodes only (allows for adding & removing top level nodes) - for node in model_ast.body: + declared_structs: set[str] = set() + additional_nodes: list[tuple[int, ast.stmt]] = [] + for body_idx, node in enumerate(model_ast.body): match node: case ast.ClassDef(name=name): # Override names when defining classes @@ -440,8 +443,11 @@ def _generate_data_model_from_json_schema() -> None: generated_name = name name = node.name = override_name exported_names.append(name) - if name.endswith("Dict"): + if not name.endswith("Dict"): + declared_structs.add(name) + else: struct_name = name.removesuffix("Dict") + assert struct_name in declared_structs, struct_name dict_token_replacements[struct_name] = name if override_name is not None: # Fix up docstring reference back to corresponding struct type @@ -454,7 +460,9 @@ def _generate_data_model_from_json_schema() -> None: docstring_node.value = docstring.replace(generated_name, name) case ast.Assign(targets=[ast.Name(id=alias)], value=expr): match expr: - # For dict fields, replace builtin type aliases with the builtin type names + # For dict fields, replace all type aliases with the original type name + # This covers both builtin type aliases (as these will be accepted), + # and struct type aliases (for mapping to their TypedDict counterparts) case ( # alias = name ast.Name(id=name) @@ -465,59 +473,85 @@ def _generate_data_model_from_json_schema() -> None: ) ): if hasattr(builtins, name): + # Simple alias for builtins dict_token_replacements[alias] = name + else: + dict_name = dict_token_replacements.get(name, None) + if dict_name is not None: + dict_token_replacements[alias] = dict_name + # Unions require additional handling to add dict variants of the union + case ast.BinOp(op=ast.BitOr()) as union_node: + named_union_members: list[str] = [] + other_union_members: list[ast.expr] = [] + optional_union = False + needs_dict_alias = False + for union_child in ast.walk(union_node): + match union_child: + case ast.Name(id=name): + named_union_members.append(name) + if not needs_dict_alias: + needs_dict_alias = ( + name in dict_token_replacements + ) + case ast.Subscript(value=ast.Name(id="Mapping")): + other_union_members.append(union_child) + case ast.Constant(value=None): + optional_union = True + # Ignore expected structural elements + case ( + ast.BinOp(op=ast.BitOr()) + | ast.BitOr() + | ast.Load() + | ast.Store() + | ast.Tuple( + elts=[ast.Name(id="str"), ast.Name(id="str")] + ) + ): + continue + case _: + raise RuntimeError( + f"Failed to parse union node: {ast.dump(union_child)} in {ast.dump(node)}" + ) + if needs_dict_alias: + dict_alias = f"{alias}Dict" + dict_token_replacements[alias] = dict_alias + struct_union_member = named_union_members[0] + dict_union_member = dict_token_replacements.get( + struct_union_member, struct_union_member + ) + dict_union: ast.expr = ast.Name( + dict_union_member, ast.Load() + ) + for struct_union_member in named_union_members[1:]: + dict_union_member = dict_token_replacements.get( + struct_union_member, struct_union_member + ) + union_rhs = ast.Name(dict_union_member, ast.Load()) + dict_union = ast.BinOp( + dict_union, ast.BitOr(), union_rhs + ) + for other_union_member in other_union_members: + dict_union = ast.BinOp( + dict_union, ast.BitOr(), other_union_member + ) + if optional_union: + dict_union = ast.BinOp( + dict_union, ast.BitOr(), ast.Constant(None) + ) + # Insert the dict alias assignment after the struct alias assignment + dict_alias_target = ast.Name(dict_alias, ast.Store()) + dict_alias_node = ast.Assign( + [dict_alias_target], dict_union + ) + additional_nodes.append((body_idx + 1, dict_alias_node)) + # Write any AST level changes back to the source file - # TODO: Move more changes to the AST rather than relying on raw text replacement + for insertion_idx, node in reversed(additional_nodes): + model_ast.body[insertion_idx:insertion_idx] = (node,) + ast.fix_missing_locations(model_ast) _MODEL_PATH.write_text(ast.unparse(model_ast)) - # Additional type union names to be translated - # Inject the dict versions of required type unions - # (This is a brute force hack, but it's good enough while there's only a few that matter) - _single_line_union = (" = ", " | ", "") - # _multi_line_union = (" = (\n ", "\n | ", "\n)") - _dict_unions = ( - ( - "AnyChatMessage", - ( - "AssistantResponse", - "UserMessage", - "SystemPrompt", - "ToolResultMessage", - ), - _single_line_union, - ), - ( - "LlmToolUseSetting", - ("LlmToolUseSettingNone", "LlmToolUseSettingToolArray"), - _single_line_union, - ), - ( - "ModelSpecifier", - ("ModelSpecifierQuery", "ModelSpecifierInstanceReference"), - _single_line_union, - ), - ) - combined_union_defs: dict[str, str] = {} - for union_name, union_members, (assign_sep, union_sep, union_end) in _dict_unions: - dict_union_name = f"{union_name}Dict" - dict_token_replacements[union_name] = dict_union_name - if dict_union_name != f"{union_name}Dict": - raise RuntimeError( - f"Union {union_name!r} mapped to unexpected name {dict_union_name!r}" - ) - union_def = ( - f"{union_name}{assign_sep}{union_sep.join(union_members)}{union_end}" - ) - dict_union_def = f"{dict_union_name}{assign_sep}{('Dict' + union_sep).join(union_members)}Dict{union_end}" - combined_union_defs[union_def] = f"{union_def}\n{dict_union_def}" - # Additional type aliases for translation - # TODO: Rather than setting these on an ad hoc basis, record all the pure aliases - # during the AST scan, and add the extra dict token replacements automatically - dict_token_replacements["PromptTemplate"] = "LlmPromptTemplateDict" - dict_token_replacements["ReasoningParsing"] = "LlmReasoningParsingDict" - dict_token_replacements["RawTools"] = "LlmToolUseSettingDict" - dict_token_replacements["LlmTool"] = "LlmToolFunctionDict" - dict_token_replacements["LlmToolParameters"] = "LlmToolParametersObjectDict" # Replace struct names in TypedDict definitions with their dict counterparts + # Also replace other type alias names with the original type (as dict inputs will be translated as needed) model_tokens = tokenize.tokenize(_MODEL_PATH.open("rb").readline) updated_tokens: list[tokenize.TokenInfo] = [] checking_class_header = False @@ -529,7 +563,7 @@ def _generate_data_model_from_json_schema() -> None: assert token_type == tokenize.NAME if token.endswith("Dict"): processing_typed_dict = True - # Either way, not checking the class header anymore + # Either way, not checking the class header any more checking_class_header = False elif processing_typed_dict: # Stop processing at the next dedent (no methods in the typed dicts) @@ -545,9 +579,6 @@ def _generate_data_model_from_json_schema() -> None: checking_class_header = True updated_tokens.append(token_info) updated_source: str = tokenize.untokenize(updated_tokens).decode("utf-8") - # Inject the dict versions of required type unions - for union_def, combined_def in combined_union_defs.items(): - updated_source = updated_source.replace(union_def, combined_def) # Insert __all__ between the imports and the schema definitions name_lines = (f' "{name}",' for name in (sorted(exported_names))) lines_to_insert = ["__all__ = [", *name_lines, "]", "", ""] diff --git a/src/lmstudio/_sdk_models/__init__.py b/src/lmstudio/_sdk_models/__init__.py index d7f6785..0d98782 100644 --- a/src/lmstudio/_sdk_models/__init__.py +++ b/src/lmstudio/_sdk_models/__init__.py @@ -150,7 +150,6 @@ "FilesRpcUploadFileBase64ReturnsDict", "Function", "FunctionDict", - "FunctionToolCallRequest", "GetModelOpts", "GetModelOptsDict", "GpuSetting", @@ -572,6 +571,7 @@ "SystemRpcVersionReturnsDict", "TextData", "TextDataDict", + "ToolCallRequest", "ToolCallRequestData", "ToolCallRequestDataDict", "ToolCallRequestDict", @@ -650,7 +650,7 @@ class ToolCallResultDataDict(TypedDict): ChatMessageRoleData = Literal["assistant", "user", "system", "tool"] -class FunctionToolCallRequest(LMStudioStruct["ToolCallRequestDict"], kw_only=True): +class ToolCallRequest(LMStudioStruct["ToolCallRequestDict"], kw_only=True): type: Annotated[Literal["function"], Meta(title="Type")] name: str id: str | None = None @@ -670,7 +670,7 @@ class ToolCallRequestDict(TypedDict): arguments: NotRequired[Mapping[str, Any] | None] -ToolCallRequest = FunctionToolCallRequest +ToolCallRequest = ToolCallRequest PageNumber = Sequence[int] LineNumber = Sequence[int] @@ -871,6 +871,7 @@ class LlmApplyPromptTemplateOptsDict(TypedDict): LlmLlamaAccelerationOffloadRatio1 = Annotated[float, Meta(ge=0.0, le=1.0)] LlmLlamaAccelerationOffloadRatio = LlmLlamaAccelerationOffloadRatio1 | str +LlmLlamaAccelerationOffloadRatioDict = float | str LlmLlamaCacheQuantizationType = Literal[ "f32", "f16", "q8_0", "q4_0", "q4_1", "iq4_nl", "q5_0", "q5_1" ] @@ -3844,6 +3845,7 @@ class RepositoryChannelEnsureAuthenticatedToClientPacketAuthenticatedDict(TypedD CpuThreads = int DraftModel = str MaxTokensModel = Any | MaxTokens | bool +MaxTokensModelDict = bool | Any | int MinPSampling = Any | float | bool ReasoningParsing = LlmReasoningParsing RepeatPenalty = Any | float | bool @@ -3944,7 +3946,7 @@ class DiagnosticsLogEventDict(TypedDict): """ timestamp: float - data: DiagnosticsLogEventData + data: DiagnosticsLogEventDataLlmPredictionInputDict class EmbeddingModelInfo( @@ -4024,6 +4026,9 @@ class EmbeddingModelInstanceInfoDict(TypedDict): ParsedFileIdentifier = ParsedFileIdentifierLocal | ParsedFileIdentifierBase64 +ParsedFileIdentifierDict = ( + ParsedFileIdentifierLocalDict | ParsedFileIdentifierBase64Dict +) class GpuSplitConfig(LMStudioStruct["GpuSplitConfigDict"], kw_only=True): @@ -4049,7 +4054,15 @@ class GpuSplitConfigDict(TypedDict): ContentBlockStyle = ( ContentBlockStyleDefault | ContentBlockStyleCustomLabel | ContentBlockStyleThinking ) +ContentBlockStyleDict = ( + ContentBlockStyleThinkingDict + | ContentBlockStyleDefaultDict + | ContentBlockStyleCustomLabelDict +) LlmContextReference = LlmContextReferenceJsonFile | LlmContextReferenceYamlFile +LlmContextReferenceDict = ( + LlmContextReferenceJsonFileDict | LlmContextReferenceYamlFileDict +) class GpuSetting(LMStudioStruct["GpuSettingDict"], kw_only=True): @@ -4066,7 +4079,7 @@ class GpuSettingDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - ratio: NotRequired[LlmLlamaAccelerationOffloadRatio | None] + ratio: NotRequired[LlmLlamaAccelerationOffloadRatioDict | None] mainGpu: NotRequired[int | None] splitStrategy: NotRequired[LlmSplitStrategy | None] disabledGpus: NotRequired[Sequence[int] | None] @@ -4265,6 +4278,11 @@ class LlmPredictionStatsDict(TypedDict): | LlmJinjaInputMessagesContentImagesConfigNumbered | LlmJinjaInputMessagesContentImagesConfigObject ) +LlmJinjaInputMessagesContentImagesConfigDict = ( + LlmJinjaInputMessagesContentImagesConfigObjectDict + | LlmJinjaInputMessagesContentImagesConfigSimpleDict + | LlmJinjaInputMessagesContentImagesConfigNumberedDict +) class LlmStructuredPredictionSetting( @@ -4288,6 +4306,7 @@ class LlmStructuredPredictionSettingDict(TypedDict): BlockLocation = BlockLocationBeforeId | BlockLocationAfterId +BlockLocationDict = BlockLocationBeforeIdDict | BlockLocationAfterIdDict class ProcessingUpdateContentBlockCreate( @@ -4316,7 +4335,7 @@ class ProcessingUpdateContentBlockCreateDict(TypedDict): type: Literal["contentBlock.create"] id: str includeInContext: bool - style: NotRequired[ContentBlockStyle | None] + style: NotRequired[ContentBlockStyleDict | None] prefix: NotRequired[str | None] suffix: NotRequired[str | None] @@ -4343,7 +4362,7 @@ class ProcessingUpdateContentBlockSetStyleDict(TypedDict): type: Literal["contentBlock.setStyle"] id: str - style: ContentBlockStyle + style: ContentBlockStyleDict class StatusStepState(LMStudioStruct["StatusStepStateDict"], kw_only=True): @@ -4363,7 +4382,9 @@ class StatusStepStateDict(TypedDict): ModelInfo = LlmInfo | EmbeddingModelInfo +ModelInfoDict = LlmInfoDict | EmbeddingModelInfoDict ModelInstanceInfo = LlmInstanceInfo | EmbeddingModelInstanceInfo +ModelInstanceInfoDict = LlmInstanceInfoDict | EmbeddingModelInstanceInfoDict class ModelInfoBase(LMStudioStruct["ModelInfoBaseDict"], kw_only=True): @@ -4521,6 +4542,9 @@ class PresetManifestDict(TypedDict): ModelSearchResultIdentifier = ( ModelSearchResultIdentifierCatalog | ModelSearchResultIdentifierHf ) +ModelSearchResultIdentifierDict = ( + ModelSearchResultIdentifierCatalogDict | ModelSearchResultIdentifierHfDict +) RetrievalChunkingMethod = RetrievalChunkingMethodRecursiveV1 @@ -4695,6 +4719,17 @@ class FilesChannelRetrieveCreationParameterDict(TypedDict): | FilesChannelRetrieveToClientPacketOnSearchingEnd | FilesChannelRetrieveToClientPacketResult ) +FilesChannelRetrieveToClientPacketDict = ( + FilesChannelRetrieveToClientPacketResultDict + | FilesChannelRetrieveToClientPacketOnSearchingEndDict + | FilesChannelRetrieveToClientPacketOnSearchingStartDict + | FilesChannelRetrieveToClientPacketOnFileProcessingStepEndDict + | FilesChannelRetrieveToClientPacketOnFileProcessingStepProgressDict + | FilesChannelRetrieveToClientPacketOnFileProcessingStepStartDict + | FilesChannelRetrieveToClientPacketOnFileProcessingEndDict + | FilesChannelRetrieveToClientPacketOnFileProcessListDict + | FilesChannelRetrieveToClientPacketOnFileProcessingStartDict +) FilesChannelRetrieveToServerPacket = FilesChannelRetrieveToServerPacketStop @@ -4716,8 +4751,8 @@ class PseudoFilesChannelRetrieveDict(TypedDict): """ creationParameter: FilesChannelRetrieveCreationParameterDict - toClientPacket: FilesChannelRetrieveToClientPacket - toServerPacket: FilesChannelRetrieveToServerPacket + toClientPacket: FilesChannelRetrieveToClientPacketDict + toServerPacket: FilesChannelRetrieveToServerPacketStopDict class PseudoFiles(LMStudioStruct["PseudoFilesDict"], kw_only=True): @@ -4863,8 +4898,8 @@ class PseudoPluginsChannelRegisterDevelopmentPluginDict(TypedDict): """ creationParameter: PluginsChannelRegisterDevelopmentPluginCreationParameterDict - toClientPacket: PluginsChannelRegisterDevelopmentPluginToClientPacket - toServerPacket: PluginsChannelRegisterDevelopmentPluginToServerPacket + toClientPacket: PluginsChannelRegisterDevelopmentPluginToClientPacketReadyDict + toServerPacket: PluginsChannelRegisterDevelopmentPluginToServerPacketEndDict PluginsChannelSetGeneratorToServerPacket = ( @@ -4872,6 +4907,11 @@ class PseudoPluginsChannelRegisterDevelopmentPluginDict(TypedDict): | PluginsChannelSetGeneratorToServerPacketAborted | PluginsChannelSetGeneratorToServerPacketError ) +PluginsChannelSetGeneratorToServerPacketDict = ( + PluginsChannelSetGeneratorToServerPacketErrorDict + | PluginsChannelSetGeneratorToServerPacketCompleteDict + | PluginsChannelSetGeneratorToServerPacketAbortedDict +) class RepositoryRpcGetModelDownloadOptionsParameter( @@ -4889,7 +4929,7 @@ class RepositoryRpcGetModelDownloadOptionsParameterDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - modelSearchResultIdentifier: ModelSearchResultIdentifier + modelSearchResultIdentifier: ModelSearchResultIdentifierDict class PseudoRepositoryRpcGetModelDownloadOptions( @@ -4915,6 +4955,11 @@ class PseudoRepositoryRpcGetModelDownloadOptionsDict(TypedDict): | RepositoryChannelDownloadModelToClientPacketStartFinalizing | RepositoryChannelDownloadModelToClientPacketSuccess ) +RepositoryChannelDownloadModelToClientPacketDict = ( + RepositoryChannelDownloadModelToClientPacketSuccessDict + | RepositoryChannelDownloadModelToClientPacketDownloadProgressDict + | RepositoryChannelDownloadModelToClientPacketStartFinalizingDict +) RepositoryChannelDownloadModelToServerPacket = ( RepositoryChannelDownloadModelToServerPacketCancel ) @@ -4940,8 +4985,8 @@ class PseudoRepositoryChannelDownloadModelDict(TypedDict): """ creationParameter: DownloadModelChannelRequestDict - toClientPacket: RepositoryChannelDownloadModelToClientPacket - toServerPacket: RepositoryChannelDownloadModelToServerPacket + toClientPacket: RepositoryChannelDownloadModelToClientPacketDict + toServerPacket: RepositoryChannelDownloadModelToServerPacketCancelDict RepositoryChannelDownloadArtifactToClientPacket = ( @@ -4949,6 +4994,11 @@ class PseudoRepositoryChannelDownloadModelDict(TypedDict): | RepositoryChannelDownloadArtifactToClientPacketStartFinalizing | RepositoryChannelDownloadArtifactToClientPacketSuccess ) +RepositoryChannelDownloadArtifactToClientPacketDict = ( + RepositoryChannelDownloadArtifactToClientPacketSuccessDict + | RepositoryChannelDownloadArtifactToClientPacketDownloadProgressDict + | RepositoryChannelDownloadArtifactToClientPacketStartFinalizingDict +) RepositoryChannelDownloadArtifactToServerPacket = ( RepositoryChannelDownloadArtifactToServerPacketCancel ) @@ -4976,8 +5026,8 @@ class PseudoRepositoryChannelDownloadArtifactDict(TypedDict): """ creationParameter: RepositoryChannelDownloadArtifactCreationParameterDict - toClientPacket: RepositoryChannelDownloadArtifactToClientPacket - toServerPacket: RepositoryChannelDownloadArtifactToServerPacket + toClientPacket: RepositoryChannelDownloadArtifactToClientPacketDict + toServerPacket: RepositoryChannelDownloadArtifactToServerPacketCancelDict RepositoryChannelPushArtifactToClientPacket = ( @@ -5004,13 +5054,17 @@ class PseudoRepositoryChannelPushArtifactDict(TypedDict): """ creationParameter: RepositoryChannelPushArtifactCreationParameterDict - toClientPacket: RepositoryChannelPushArtifactToClientPacket + toClientPacket: RepositoryChannelPushArtifactToClientPacketMessageDict RepositoryChannelEnsureAuthenticatedToClientPacket = ( RepositoryChannelEnsureAuthenticatedToClientPacketAuthenticationUrl | RepositoryChannelEnsureAuthenticatedToClientPacketAuthenticated ) +RepositoryChannelEnsureAuthenticatedToClientPacketDict = ( + RepositoryChannelEnsureAuthenticatedToClientPacketAuthenticationUrlDict + | RepositoryChannelEnsureAuthenticatedToClientPacketAuthenticatedDict +) class PseudoRepositoryChannelEnsureAuthenticated( @@ -5028,7 +5082,7 @@ class PseudoRepositoryChannelEnsureAuthenticatedDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - toClientPacket: RepositoryChannelEnsureAuthenticatedToClientPacket + toClientPacket: RepositoryChannelEnsureAuthenticatedToClientPacketDict SystemRpcListDownloadedModelsReturns = Sequence[ModelInfo] @@ -5193,6 +5247,10 @@ class ErrorDisplayDataGenericNoModelMatchingQueryDict(TypedDict): KvConfigFieldDependencyCondition = ( KvConfigFieldDependencyConditionEquals | KvConfigFieldDependencyConditionNotEquals ) +KvConfigFieldDependencyConditionDict = ( + KvConfigFieldDependencyConditionEqualsDict + | KvConfigFieldDependencyConditionNotEqualsDict +) class LlmJinjaInputMessagesContentConfigString( @@ -5215,7 +5273,7 @@ class LlmJinjaInputMessagesContentConfigStringDict(TypedDict): """ type: Literal["string"] - imagesConfig: NotRequired[LlmJinjaInputMessagesContentImagesConfig | None] + imagesConfig: NotRequired[LlmJinjaInputMessagesContentImagesConfigDict | None] class LlmJinjaInputMessagesContentConfigArray( @@ -5242,7 +5300,7 @@ class LlmJinjaInputMessagesContentConfigArrayDict(TypedDict): type: Literal["array"] textFieldName: LlmJinjaInputMessagesContentConfigTextFieldName - imagesConfig: NotRequired[LlmJinjaInputMessagesContentImagesConfig | None] + imagesConfig: NotRequired[LlmJinjaInputMessagesContentImagesConfigDict | None] class LlmToolParametersObject( @@ -5423,7 +5481,7 @@ class EmbeddingChannelGetOrLoadToClientPacketUnloadingOtherJITModelDict(TypedDic """ type: Literal["unloadingOtherJITModel"] - info: ModelInstanceInfo + info: ModelInstanceInfoDict class EmbeddingChannelGetOrLoadToClientPacketLoadSuccess( @@ -5564,7 +5622,7 @@ class LlmChannelGetOrLoadToClientPacketUnloadingOtherJITModelDict(TypedDict): """ type: Literal["unloadingOtherJITModel"] - info: ModelInstanceInfo + info: ModelInstanceInfoDict class LlmChannelGetOrLoadToClientPacketLoadSuccess( @@ -5647,11 +5705,15 @@ class PluginsChannelSetGeneratorToClientPacketGenerateDict(TypedDict): ArtifactManifest = PluginManifest | PresetManifest | ModelManifest +ArtifactManifestDict = ModelManifestDict | PluginManifestDict | PresetManifestDict AnyChatMessage = AssistantResponse | UserMessage | SystemPrompt | ToolResultMessage AnyChatMessageDict = ( - AssistantResponseDict | UserMessageDict | SystemPromptDict | ToolResultMessageDict + ToolResultMessageDict | SystemPromptDict | AssistantResponseDict | UserMessageDict ) ChatMessagePartData = TextData | FileHandle | ToolCallRequestData | ToolCallResultData +ChatMessagePartDataDict = ( + ToolCallResultDataDict | ToolCallRequestDataDict | TextDataDict | FileHandleDict +) class EmbeddingLoadModelConfig( @@ -5691,6 +5753,15 @@ class EmbeddingLoadModelConfigDict(TypedDict): | ErrorDisplayDataGenericEngineDoesNotSupportFeature | ErrorDisplayDataGenericPresetNotFound ) +ErrorDisplayDataDict = ( + ErrorDisplayDataGenericPresetNotFoundDict + | ErrorDisplayDataGenericEngineDoesNotSupportFeatureDict + | ErrorDisplayDataGenericDomainMismatchDict + | ErrorDisplayDataGenericIdentifierNotFoundDict + | ErrorDisplayDataGenericPathNotFoundDict + | ErrorDisplayDataGenericSpecificModelUnloadedDict + | ErrorDisplayDataGenericNoModelMatchingQueryDict +) class KvConfigFieldDependency( @@ -5708,7 +5779,7 @@ class KvConfigFieldDependencyDict(TypedDict): """ key: str - condition: KvConfigFieldDependencyCondition + condition: KvConfigFieldDependencyConditionDict class LlmGenInfo(LMStudioStruct["LlmGenInfoDict"], kw_only=True): @@ -5736,6 +5807,10 @@ class LlmGenInfoDict(TypedDict): LlmJinjaInputMessagesContentConfig = ( LlmJinjaInputMessagesContentConfigString | LlmJinjaInputMessagesContentConfigArray ) +LlmJinjaInputMessagesContentConfigDict = ( + LlmJinjaInputMessagesContentConfigStringDict + | LlmJinjaInputMessagesContentConfigArrayDict +) LlmToolParameters = LlmToolParametersObject @@ -5789,7 +5864,7 @@ class ProcessingUpdateStatusCreateDict(TypedDict): type: Literal["status.create"] id: str state: StatusStepStateDict - location: NotRequired[BlockLocation | None] + location: NotRequired[BlockLocationDict | None] indentation: NotRequired[int | None] @@ -5839,7 +5914,7 @@ class ModelSearchResultEntryDataDict(TypedDict): """ name: str - identifier: ModelSearchResultIdentifier + identifier: ModelSearchResultIdentifierDict exact: NotRequired[bool | None] staffPick: NotRequired[bool | None] @@ -5867,8 +5942,8 @@ class PseudoDiagnosticsChannelStreamLogsDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - toClientPacket: DiagnosticsChannelStreamLogsToClientPacket - toServerPacket: DiagnosticsChannelStreamLogsToServerPacket + toClientPacket: DiagnosticsChannelStreamLogsToClientPacketLogDict + toServerPacket: DiagnosticsChannelStreamLogsToServerPacketStopDict class PseudoDiagnostics(LMStudioStruct["PseudoDiagnosticsDict"], kw_only=True): @@ -5906,6 +5981,7 @@ class EmbeddingRpcGetModelInfoParameterDict(TypedDict): EmbeddingRpcGetModelInfoReturns = EmbeddingRpcGetModelInfoReturnValue | None +EmbeddingRpcGetModelInfoReturnsDict = EmbeddingModelInstanceInfoDict | None class PseudoEmbeddingRpcGetModelInfo( @@ -5923,7 +5999,7 @@ class PseudoEmbeddingRpcGetModelInfoDict(TypedDict): """ parameter: EmbeddingRpcGetModelInfoParameterDict - returns: NotRequired[EmbeddingRpcGetModelInfoReturns | None] + returns: NotRequired[EmbeddingRpcGetModelInfoReturnsDict | None] class EmbeddingRpcGetLoadConfigParameter( @@ -6073,6 +6149,11 @@ class PseudoEmbeddingRpcCountTokensDict(TypedDict): | EmbeddingChannelLoadModelToClientPacketProgress | EmbeddingChannelLoadModelToClientPacketSuccess ) +EmbeddingChannelLoadModelToClientPacketDict = ( + EmbeddingChannelLoadModelToClientPacketSuccessDict + | EmbeddingChannelLoadModelToClientPacketResolvedDict + | EmbeddingChannelLoadModelToClientPacketProgressDict +) class PseudoEmbeddingChannelLoadModel( @@ -6097,8 +6178,8 @@ class PseudoEmbeddingChannelLoadModelDict(TypedDict): """ creationParameter: EmbeddingChannelLoadModelCreationParameterDict - toClientPacket: EmbeddingChannelLoadModelToClientPacket - toServerPacket: EmbeddingChannelLoadModelToServerPacket + toClientPacket: EmbeddingChannelLoadModelToClientPacketDict + toServerPacket: EmbeddingChannelLoadModelToServerPacketCancelDict EmbeddingChannelGetOrLoadToClientPacket = ( @@ -6108,6 +6189,13 @@ class PseudoEmbeddingChannelLoadModelDict(TypedDict): | EmbeddingChannelGetOrLoadToClientPacketLoadProgress | EmbeddingChannelGetOrLoadToClientPacketLoadSuccess ) +EmbeddingChannelGetOrLoadToClientPacketDict = ( + EmbeddingChannelGetOrLoadToClientPacketLoadSuccessDict + | EmbeddingChannelGetOrLoadToClientPacketLoadProgressDict + | EmbeddingChannelGetOrLoadToClientPacketUnloadingOtherJITModelDict + | EmbeddingChannelGetOrLoadToClientPacketAlreadyLoadedDict + | EmbeddingChannelGetOrLoadToClientPacketStartLoadingDict +) class PseudoEmbeddingChannelGetOrLoad( @@ -6132,8 +6220,8 @@ class PseudoEmbeddingChannelGetOrLoadDict(TypedDict): """ creationParameter: EmbeddingChannelGetOrLoadCreationParameterDict - toClientPacket: EmbeddingChannelGetOrLoadToClientPacket - toServerPacket: EmbeddingChannelGetOrLoadToServerPacket + toClientPacket: EmbeddingChannelGetOrLoadToClientPacketDict + toServerPacket: EmbeddingChannelGetOrLoadToServerPacketCancelDict class PseudoEmbedding(LMStudioStruct["PseudoEmbeddingDict"], kw_only=True): @@ -6189,6 +6277,7 @@ class LlmRpcGetModelInfoParameterDict(TypedDict): LlmRpcGetModelInfoReturns = LlmRpcGetModelInfoReturnValue | None +LlmRpcGetModelInfoReturnsDict = LlmInstanceInfoDict | None class PseudoLlmRpcGetModelInfo( @@ -6206,7 +6295,7 @@ class PseudoLlmRpcGetModelInfoDict(TypedDict): """ parameter: LlmRpcGetModelInfoParameterDict - returns: NotRequired[LlmRpcGetModelInfoReturns | None] + returns: NotRequired[LlmRpcGetModelInfoReturnsDict | None] class LlmRpcGetLoadConfigParameter( @@ -6352,6 +6441,11 @@ class PseudoLlmRpcPreloadDraftModelDict(TypedDict): | LlmChannelLoadModelToClientPacketProgress | LlmChannelLoadModelToClientPacketSuccess ) +LlmChannelLoadModelToClientPacketDict = ( + LlmChannelLoadModelToClientPacketSuccessDict + | LlmChannelLoadModelToClientPacketResolvedDict + | LlmChannelLoadModelToClientPacketProgressDict +) class PseudoLlmChannelLoadModel( @@ -6372,8 +6466,8 @@ class PseudoLlmChannelLoadModelDict(TypedDict): """ creationParameter: LlmChannelLoadModelCreationParameterDict - toClientPacket: LlmChannelLoadModelToClientPacket - toServerPacket: LlmChannelLoadModelToServerPacket + toClientPacket: LlmChannelLoadModelToClientPacketDict + toServerPacket: LlmChannelLoadModelToServerPacketCancelDict LlmChannelGetOrLoadToClientPacket = ( @@ -6383,6 +6477,13 @@ class PseudoLlmChannelLoadModelDict(TypedDict): | LlmChannelGetOrLoadToClientPacketLoadProgress | LlmChannelGetOrLoadToClientPacketLoadSuccess ) +LlmChannelGetOrLoadToClientPacketDict = ( + LlmChannelGetOrLoadToClientPacketLoadSuccessDict + | LlmChannelGetOrLoadToClientPacketLoadProgressDict + | LlmChannelGetOrLoadToClientPacketUnloadingOtherJITModelDict + | LlmChannelGetOrLoadToClientPacketAlreadyLoadedDict + | LlmChannelGetOrLoadToClientPacketStartLoadingDict +) class PseudoLlmChannelGetOrLoad( @@ -6403,8 +6504,8 @@ class PseudoLlmChannelGetOrLoadDict(TypedDict): """ creationParameter: LlmChannelGetOrLoadCreationParameterDict - toClientPacket: LlmChannelGetOrLoadToClientPacket - toServerPacket: LlmChannelGetOrLoadToServerPacket + toClientPacket: LlmChannelGetOrLoadToClientPacketDict + toServerPacket: LlmChannelGetOrLoadToServerPacketCancelDict LlmChannelPredictToClientPacket = ( @@ -6415,10 +6516,22 @@ class PseudoLlmChannelGetOrLoadDict(TypedDict): | LlmChannelPredictToClientPacketToolCallGenerationFailed | LlmChannelPredictToClientPacketSuccess ) +LlmChannelPredictToClientPacketDict = ( + LlmChannelPredictToClientPacketSuccessDict + | LlmChannelPredictToClientPacketToolCallGenerationFailedDict + | LlmChannelPredictToClientPacketToolCallGenerationEndDict + | LlmChannelPredictToClientPacketToolCallGenerationStartDict + | LlmChannelPredictToClientPacketFragmentDict + | LlmChannelPredictToClientPacketPromptProcessingProgressDict +) PluginsChannelSetGeneratorToClientPacket = ( PluginsChannelSetGeneratorToClientPacketGenerate | PluginsChannelSetGeneratorToClientPacketAbort ) +PluginsChannelSetGeneratorToClientPacketDict = ( + PluginsChannelSetGeneratorToClientPacketGenerateDict + | PluginsChannelSetGeneratorToClientPacketAbortDict +) class PseudoPluginsChannelSetGenerator( @@ -6439,8 +6552,8 @@ class PseudoPluginsChannelSetGeneratorDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - toClientPacket: PluginsChannelSetGeneratorToClientPacket - toServerPacket: PluginsChannelSetGeneratorToServerPacket + toClientPacket: PluginsChannelSetGeneratorToClientPacketDict + toServerPacket: PluginsChannelSetGeneratorToServerPacketDict class RepositoryRpcSearchModelsReturns( @@ -6633,7 +6746,7 @@ class LlmJinjaInputMessagesConfigDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - contentConfig: LlmJinjaInputMessagesContentConfig + contentConfig: LlmJinjaInputMessagesContentConfigDict LlmTool = LlmToolFunction @@ -6650,6 +6763,19 @@ class LlmJinjaInputMessagesConfigDict(TypedDict): | ProcessingUpdateContentBlockSetStyle | ProcessingUpdateSetSenderName ) +GeneratorUpdateDict = ( + ProcessingUpdateSetSenderNameDict + | ProcessingUpdateContentBlockSetStyleDict + | ProcessingUpdateContentBlockAttachGenInfoDict + | ProcessingUpdateContentBlockReplaceTextDict + | ProcessingUpdateContentBlockAppendTextDict + | ProcessingUpdateContentBlockCreateDict + | ProcessingUpdateDebugInfoBlockCreateDict + | ProcessingUpdateCitationBlockCreateDict + | ProcessingUpdateStatusRemoveDict + | ProcessingUpdateStatusCreateDict + | ProcessingUpdateStatusUpdateDict +) PreprocessorUpdate = ( ProcessingUpdateStatusCreate | ProcessingUpdateStatusUpdate @@ -6657,6 +6783,13 @@ class LlmJinjaInputMessagesConfigDict(TypedDict): | ProcessingUpdateCitationBlockCreate | ProcessingUpdateDebugInfoBlockCreate ) +PreprocessorUpdateDict = ( + ProcessingUpdateDebugInfoBlockCreateDict + | ProcessingUpdateCitationBlockCreateDict + | ProcessingUpdateStatusRemoveDict + | ProcessingUpdateStatusCreateDict + | ProcessingUpdateStatusUpdateDict +) ProcessingUpdate = ( ProcessingUpdateStatusCreate | ProcessingUpdateStatusUpdate @@ -6672,6 +6805,21 @@ class LlmJinjaInputMessagesConfigDict(TypedDict): | ProcessingUpdateContentBlockSetStyle | ProcessingUpdateSetSenderName ) +ProcessingUpdateDict = ( + ProcessingUpdateSetSenderNameDict + | ProcessingUpdateContentBlockSetStyleDict + | ProcessingUpdateContentBlockAttachGenInfoDict + | ProcessingUpdateContentBlockSetSuffixDict + | ProcessingUpdateContentBlockSetPrefixDict + | ProcessingUpdateContentBlockReplaceTextDict + | ProcessingUpdateContentBlockAppendTextDict + | ProcessingUpdateContentBlockCreateDict + | ProcessingUpdateDebugInfoBlockCreateDict + | ProcessingUpdateCitationBlockCreateDict + | ProcessingUpdateStatusRemoveDict + | ProcessingUpdateStatusCreateDict + | ProcessingUpdateStatusUpdateDict +) class LlmRpcApplyPromptTemplateParameter( @@ -6758,8 +6906,8 @@ class PseudoLlmChannelPredictDict(TypedDict): """ creationParameter: PredictionChannelRequestDict - toClientPacket: LlmChannelPredictToClientPacket - toServerPacket: LlmChannelPredictToServerPacket + toClientPacket: LlmChannelPredictToClientPacketDict + toServerPacket: LlmChannelPredictToServerPacketCancelDict class PseudoLlm(LMStudioStruct["PseudoLlmDict"], kw_only=True): @@ -6817,7 +6965,7 @@ class PluginsRpcProcessingHandleUpdateParameterDict(TypedDict): pci: str token: str - update: ProcessingUpdate + update: ProcessingUpdateDict class PseudoPluginsRpcProcessingHandleUpdate( @@ -6874,11 +7022,20 @@ class PseudoPluginsRpcProcessingPullHistoryDict(TypedDict): PluginsChannelSetPreprocessorToClientPacketPreprocess | PluginsChannelSetPreprocessorToClientPacketAbort ) +PluginsChannelSetPreprocessorToClientPacketDict = ( + PluginsChannelSetPreprocessorToClientPacketPreprocessDict + | PluginsChannelSetPreprocessorToClientPacketAbortDict +) PluginsChannelSetPreprocessorToServerPacket = ( PluginsChannelSetPreprocessorToServerPacketComplete | PluginsChannelSetPreprocessorToServerPacketAborted | PluginsChannelSetPreprocessorToServerPacketError ) +PluginsChannelSetPreprocessorToServerPacketDict = ( + PluginsChannelSetPreprocessorToServerPacketErrorDict + | PluginsChannelSetPreprocessorToServerPacketCompleteDict + | PluginsChannelSetPreprocessorToServerPacketAbortedDict +) class PseudoPluginsChannelSetPreprocessor( @@ -6899,8 +7056,8 @@ class PseudoPluginsChannelSetPreprocessorDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - toClientPacket: PluginsChannelSetPreprocessorToClientPacket - toServerPacket: PluginsChannelSetPreprocessorToServerPacket + toClientPacket: PluginsChannelSetPreprocessorToClientPacketDict + toServerPacket: PluginsChannelSetPreprocessorToServerPacketDict class PseudoPlugins(LMStudioStruct["PseudoPluginsDict"], kw_only=True): @@ -7193,7 +7350,7 @@ class LlmPredictionConfigDict(TypedDict): as that is what `to_dict()` emits, and what `_from_api_dict()` accepts. """ - maxTokens: NotRequired[MaxTokensModel | None] + maxTokens: NotRequired[MaxTokensModelDict | None] temperature: NotRequired[float | None] stopStrings: NotRequired[StopStrings | None] toolCallStopStrings: NotRequired[ToolCallStopStrings | None]