Skip to content

Commit 0ed84a6

Browse files
committed
Cleanup from PR review
1 parent e0b5221 commit 0ed84a6

File tree

6 files changed

+98
-87
lines changed

6 files changed

+98
-87
lines changed

examples/plugins/dice-tool/src/plugin.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async def list_provided_tools(
6868
else:
6969
permitted_sides = None
7070

71-
# Return value may be any iterable, but a list will typically be simplest
7271
# Tool definitions may use any of the formats described in
7372
# https://lmstudio.ai/docs/python/agent/tools
7473
def roll_dice(count: int, sides: int) -> DiceRollResult:
@@ -88,8 +87,6 @@ def roll_dice(count: int, sides: int) -> DiceRollResult:
8887
for send_notification, status_text in status_updates:
8988
time.sleep(status_duration)
9089
send_notification(status_text)
91-
# TODO: Add a tool calling UI status/warning demo here
92-
time.sleep(inplace_status_duration)
9390
if permitted_sides and sides not in permitted_sides:
9491
expected_die_types = ",".join(map(str, sorted(permitted_sides)))
9592
err_msg = f"{sides} is not a conventional polyhedral die type ({expected_die_types})"

sdk-schema/sync-sdk-schema.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def _infer_schema_unions() -> None:
363363
"LlmChannelPredictCreationParameterDict": "PredictionChannelRequestDict",
364364
"RepositoryChannelDownloadModelCreationParameter": "DownloadModelChannelRequest",
365365
"RepositoryChannelDownloadModelCreationParameterDict": "DownloadModelChannelRequestDict",
366-
# Prettier plugin channel message names
366+
# Prettier prompt preprocessing plugin channel message names
367367
"PluginsChannelSetPromptPreprocessorToClientPacketPreprocess": "PromptPreprocessingRequest",
368368
"PluginsChannelSetPromptPreprocessorToClientPacketPreprocessDict": "PromptPreprocessingRequestDict",
369369
"PluginsChannelSetPromptPreprocessorToServerPacketAborted": "PromptPreprocessingAborted",
@@ -372,6 +372,25 @@ def _infer_schema_unions() -> None:
372372
"PluginsChannelSetPromptPreprocessorToServerPacketCompleteDict": "PromptPreprocessingCompleteDict",
373373
"PluginsChannelSetPromptPreprocessorToServerPacketError": "PromptPreprocessingError",
374374
"PluginsChannelSetPromptPreprocessorToServerPacketErrorDict": "PromptPreprocessingErrorDict",
375+
# Prettier tools provider plugin channel message names
376+
"PluginsChannelSetToolsProviderToClientPacketInitSession": "ProvideToolsInitSession",
377+
"PluginsChannelSetToolsProviderToClientPacketInitSessionDict": "ProvideToolsInitSessionDict",
378+
"PluginsChannelSetToolsProviderToClientPacketAbortToolCall": "ProvideToolsAbortCall",
379+
"PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict": "ProvideToolsAbortCallDict",
380+
"PluginsChannelSetToolsProviderToClientPacketCallTool": "ProvideToolsCallTool",
381+
"PluginsChannelSetToolsProviderToClientPacketCallToolDict": "ProvideToolsCallToolDict",
382+
"PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed": "ProvideToolsInitFailed",
383+
"PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict": "ProvideToolsInitFailedDict",
384+
"PluginsChannelSetToolsProviderToServerPacketSessionInitialized": "ProvideToolsInitialized",
385+
"PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict": "ProvideToolsInitializedDict",
386+
"PluginsChannelSetToolsProviderToServerPacketToolCallComplete": "PluginToolCallComplete",
387+
"PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict": "PluginToolCallCompleteDict",
388+
"PluginsChannelSetToolsProviderToServerPacketToolCallError": "PluginToolCallError",
389+
"PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict": "PluginToolCallErrorDict",
390+
"PluginsChannelSetToolsProviderToServerPacketToolCallStatus": "PluginToolCallStatus",
391+
"PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict": "PluginToolCallStatusDict",
392+
"PluginsChannelSetToolsProviderToServerPacketToolCallWarn": "PluginToolCallWarn",
393+
"PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict": "PluginToolCallWarnDict",
375394
# Prettier config handling type names
376395
"LlmRpcGetLoadConfigReturns": "SerializedKVConfigSettings",
377396
"LlmRpcGetLoadConfigReturnsDict": "SerializedKVConfigSettingsDict",

src/lmstudio/_sdk_models/__init__.py

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@
380380
"ParsedFileIdentifierLocalDict",
381381
"PluginManifest",
382382
"PluginManifestDict",
383+
"PluginToolCallComplete",
384+
"PluginToolCallCompleteDict",
385+
"PluginToolCallError",
386+
"PluginToolCallErrorDict",
387+
"PluginToolCallStatus",
388+
"PluginToolCallStatusDict",
389+
"PluginToolCallWarn",
390+
"PluginToolCallWarnDict",
383391
"PluginsChannelRegisterDevelopmentPluginCreationParameter",
384392
"PluginsChannelRegisterDevelopmentPluginCreationParameterDict",
385393
"PluginsChannelRegisterDevelopmentPluginToClientPacketReady",
@@ -420,26 +428,8 @@
420428
"PluginsChannelSetPredictionLoopHandlerToServerPacketErrorDict",
421429
"PluginsChannelSetPromptPreprocessorToClientPacketAbort",
422430
"PluginsChannelSetPromptPreprocessorToClientPacketAbortDict",
423-
"PluginsChannelSetToolsProviderToClientPacketAbortToolCall",
424-
"PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict",
425-
"PluginsChannelSetToolsProviderToClientPacketCallTool",
426-
"PluginsChannelSetToolsProviderToClientPacketCallToolDict",
427431
"PluginsChannelSetToolsProviderToClientPacketDiscardSession",
428432
"PluginsChannelSetToolsProviderToClientPacketDiscardSessionDict",
429-
"PluginsChannelSetToolsProviderToClientPacketInitSession",
430-
"PluginsChannelSetToolsProviderToClientPacketInitSessionDict",
431-
"PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed",
432-
"PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict",
433-
"PluginsChannelSetToolsProviderToServerPacketSessionInitialized",
434-
"PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict",
435-
"PluginsChannelSetToolsProviderToServerPacketToolCallComplete",
436-
"PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict",
437-
"PluginsChannelSetToolsProviderToServerPacketToolCallError",
438-
"PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict",
439-
"PluginsChannelSetToolsProviderToServerPacketToolCallStatus",
440-
"PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict",
441-
"PluginsChannelSetToolsProviderToServerPacketToolCallWarn",
442-
"PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict",
443433
"PluginsRpcProcessingGetOrLoadModelParameter",
444434
"PluginsRpcProcessingGetOrLoadModelParameterDict",
445435
"PluginsRpcProcessingGetOrLoadModelReturns",
@@ -528,6 +518,16 @@
528518
"PromptPreprocessingErrorDict",
529519
"PromptPreprocessingRequest",
530520
"PromptPreprocessingRequestDict",
521+
"ProvideToolsAbortCall",
522+
"ProvideToolsAbortCallDict",
523+
"ProvideToolsCallTool",
524+
"ProvideToolsCallToolDict",
525+
"ProvideToolsInitFailed",
526+
"ProvideToolsInitFailedDict",
527+
"ProvideToolsInitSession",
528+
"ProvideToolsInitSessionDict",
529+
"ProvideToolsInitialized",
530+
"ProvideToolsInitializedDict",
531531
"PseudoDiagnostics",
532532
"PseudoDiagnosticsChannelStreamLogs",
533533
"PseudoDiagnosticsChannelStreamLogsDict",
@@ -5214,8 +5214,8 @@ class PluginsChannelSetToolsProviderToClientPacketDiscardSessionDict(TypedDict):
52145214
sessionId: str
52155215

52165216

5217-
class PluginsChannelSetToolsProviderToClientPacketCallTool(
5218-
LMStudioStruct["PluginsChannelSetToolsProviderToClientPacketCallToolDict"],
5217+
class ProvideToolsCallTool(
5218+
LMStudioStruct["ProvideToolsCallToolDict"],
52195219
kw_only=True,
52205220
tag_field="type",
52215221
tag="callTool",
@@ -5227,7 +5227,7 @@ class PluginsChannelSetToolsProviderToClientPacketCallTool(
52275227
parameters: JsonSerializable
52285228

52295229

5230-
class PluginsChannelSetToolsProviderToClientPacketCallToolDict(TypedDict):
5230+
class ProvideToolsCallToolDict(TypedDict):
52315231
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToClientPacketCallTool.
52325232
52335233
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5241,8 +5241,8 @@ class PluginsChannelSetToolsProviderToClientPacketCallToolDict(TypedDict):
52415241
parameters: JsonSerializable
52425242

52435243

5244-
class PluginsChannelSetToolsProviderToClientPacketAbortToolCall(
5245-
LMStudioStruct["PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict"],
5244+
class ProvideToolsAbortCall(
5245+
LMStudioStruct["ProvideToolsAbortCallDict"],
52465246
kw_only=True,
52475247
tag_field="type",
52485248
tag="abortToolCall",
@@ -5254,7 +5254,7 @@ class PluginsChannelSetToolsProviderToClientPacketAbortToolCall(
52545254
call_id: str = field(name="callId")
52555255

52565256

5257-
class PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict(TypedDict):
5257+
class ProvideToolsAbortCallDict(TypedDict):
52585258
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToClientPacketAbortToolCall.
52595259
52605260
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5266,10 +5266,8 @@ class PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict(TypedDict):
52665266
callId: str
52675267

52685268

5269-
class PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed(
5270-
LMStudioStruct[
5271-
"PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict"
5272-
],
5269+
class ProvideToolsInitFailed(
5270+
LMStudioStruct["ProvideToolsInitFailedDict"],
52735271
kw_only=True,
52745272
tag_field="type",
52755273
tag="sessionInitializationFailed",
@@ -5281,9 +5279,7 @@ class PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed(
52815279
error: SerializedLMSExtendedError
52825280

52835281

5284-
class PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict(
5285-
TypedDict
5286-
):
5282+
class ProvideToolsInitFailedDict(TypedDict):
52875283
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed.
52885284
52895285
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5295,8 +5291,8 @@ class PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDic
52955291
error: SerializedLMSExtendedErrorDict
52965292

52975293

5298-
class PluginsChannelSetToolsProviderToServerPacketToolCallComplete(
5299-
LMStudioStruct["PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict"],
5294+
class PluginToolCallComplete(
5295+
LMStudioStruct["PluginToolCallCompleteDict"],
53005296
kw_only=True,
53015297
tag_field="type",
53025298
tag="toolCallComplete",
@@ -5309,7 +5305,7 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallComplete(
53095305
result: JsonSerializable
53105306

53115307

5312-
class PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict(TypedDict):
5308+
class PluginToolCallCompleteDict(TypedDict):
53135309
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketToolCallComplete.
53145310
53155311
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5322,8 +5318,8 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict(TypedDict
53225318
result: JsonSerializable
53235319

53245320

5325-
class PluginsChannelSetToolsProviderToServerPacketToolCallError(
5326-
LMStudioStruct["PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict"],
5321+
class PluginToolCallError(
5322+
LMStudioStruct["PluginToolCallErrorDict"],
53275323
kw_only=True,
53285324
tag_field="type",
53295325
tag="toolCallError",
@@ -5336,7 +5332,7 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallError(
53365332
error: SerializedLMSExtendedError
53375333

53385334

5339-
class PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict(TypedDict):
5335+
class PluginToolCallErrorDict(TypedDict):
53405336
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketToolCallError.
53415337
53425338
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5349,8 +5345,8 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict(TypedDict):
53495345
error: SerializedLMSExtendedErrorDict
53505346

53515347

5352-
class PluginsChannelSetToolsProviderToServerPacketToolCallStatus(
5353-
LMStudioStruct["PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict"],
5348+
class PluginToolCallStatus(
5349+
LMStudioStruct["PluginToolCallStatusDict"],
53545350
kw_only=True,
53555351
tag_field="type",
53565352
tag="toolCallStatus",
@@ -5363,7 +5359,7 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallStatus(
53635359
status_text: str = field(name="statusText")
53645360

53655361

5366-
class PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict(TypedDict):
5362+
class PluginToolCallStatusDict(TypedDict):
53675363
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketToolCallStatus.
53685364
53695365
NOTE: Multi-word keys are defined using their camelCase form,
@@ -5376,8 +5372,8 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict(TypedDict):
53765372
statusText: str
53775373

53785374

5379-
class PluginsChannelSetToolsProviderToServerPacketToolCallWarn(
5380-
LMStudioStruct["PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict"],
5375+
class PluginToolCallWarn(
5376+
LMStudioStruct["PluginToolCallWarnDict"],
53815377
kw_only=True,
53825378
tag_field="type",
53835379
tag="toolCallWarn",
@@ -5390,7 +5386,7 @@ class PluginsChannelSetToolsProviderToServerPacketToolCallWarn(
53905386
warn_text: str = field(name="warnText")
53915387

53925388

5393-
class PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict(TypedDict):
5389+
class PluginToolCallWarnDict(TypedDict):
53945390
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketToolCallWarn.
53955391
53965392
NOTE: Multi-word keys are defined using their camelCase form,
@@ -7946,8 +7942,8 @@ class PluginsChannelSetPredictionLoopHandlerToClientPacketHandlePredictionLoopDi
79467942
token: str
79477943

79487944

7949-
class PluginsChannelSetToolsProviderToClientPacketInitSession(
7950-
LMStudioStruct["PluginsChannelSetToolsProviderToClientPacketInitSessionDict"],
7945+
class ProvideToolsInitSession(
7946+
LMStudioStruct["ProvideToolsInitSessionDict"],
79517947
kw_only=True,
79527948
tag_field="type",
79537949
tag="initSession",
@@ -7961,7 +7957,7 @@ class PluginsChannelSetToolsProviderToClientPacketInitSession(
79617957
session_id: str = field(name="sessionId")
79627958

79637959

7964-
class PluginsChannelSetToolsProviderToClientPacketInitSessionDict(TypedDict):
7960+
class ProvideToolsInitSessionDict(TypedDict):
79657961
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToClientPacketInitSession.
79667962
79677963
NOTE: Multi-word keys are defined using their camelCase form,
@@ -9129,15 +9125,15 @@ class PseudoPluginsChannelSetPredictionLoopHandlerDict(TypedDict):
91299125

91309126

91319127
PluginsChannelSetToolsProviderToClientPacket = (
9132-
PluginsChannelSetToolsProviderToClientPacketInitSession
9128+
ProvideToolsInitSession
91339129
| PluginsChannelSetToolsProviderToClientPacketDiscardSession
9134-
| PluginsChannelSetToolsProviderToClientPacketCallTool
9135-
| PluginsChannelSetToolsProviderToClientPacketAbortToolCall
9130+
| ProvideToolsCallTool
9131+
| ProvideToolsAbortCall
91369132
)
91379133
PluginsChannelSetToolsProviderToClientPacketDict = (
9138-
PluginsChannelSetToolsProviderToClientPacketAbortToolCallDict
9139-
| PluginsChannelSetToolsProviderToClientPacketCallToolDict
9140-
| PluginsChannelSetToolsProviderToClientPacketInitSessionDict
9134+
ProvideToolsAbortCallDict
9135+
| ProvideToolsCallToolDict
9136+
| ProvideToolsInitSessionDict
91419137
| PluginsChannelSetToolsProviderToClientPacketDiscardSessionDict
91429138
)
91439139
PluginsChannelSetGeneratorToServerPacket = (
@@ -9339,10 +9335,8 @@ class LlmToolUseSettingToolArrayDict(TypedDict):
93399335
force: NotRequired[bool | None]
93409336

93419337

9342-
class PluginsChannelSetToolsProviderToServerPacketSessionInitialized(
9343-
LMStudioStruct[
9344-
"PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict"
9345-
],
9338+
class ProvideToolsInitialized(
9339+
LMStudioStruct["ProvideToolsInitializedDict"],
93469340
kw_only=True,
93479341
tag_field="type",
93489342
tag="sessionInitialized",
@@ -9354,7 +9348,7 @@ class PluginsChannelSetToolsProviderToServerPacketSessionInitialized(
93549348
tool_definitions: Sequence[LlmTool] = field(name="toolDefinitions")
93559349

93569350

9357-
class PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict(TypedDict):
9351+
class ProvideToolsInitializedDict(TypedDict):
93589352
"""Corresponding typed dictionary definition for PluginsChannelSetToolsProviderToServerPacketSessionInitialized.
93599353
93609354
NOTE: Multi-word keys are defined using their camelCase form,
@@ -9486,20 +9480,20 @@ class ProcessingUpdateToolStatusUpdateDict(TypedDict):
94869480

94879481

94889482
PluginsChannelSetToolsProviderToServerPacket = (
9489-
PluginsChannelSetToolsProviderToServerPacketSessionInitialized
9490-
| PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailed
9491-
| PluginsChannelSetToolsProviderToServerPacketToolCallComplete
9492-
| PluginsChannelSetToolsProviderToServerPacketToolCallError
9493-
| PluginsChannelSetToolsProviderToServerPacketToolCallStatus
9494-
| PluginsChannelSetToolsProviderToServerPacketToolCallWarn
9483+
ProvideToolsInitialized
9484+
| ProvideToolsInitFailed
9485+
| PluginToolCallComplete
9486+
| PluginToolCallError
9487+
| PluginToolCallStatus
9488+
| PluginToolCallWarn
94959489
)
94969490
PluginsChannelSetToolsProviderToServerPacketDict = (
9497-
PluginsChannelSetToolsProviderToServerPacketToolCallWarnDict
9498-
| PluginsChannelSetToolsProviderToServerPacketToolCallStatusDict
9499-
| PluginsChannelSetToolsProviderToServerPacketToolCallErrorDict
9500-
| PluginsChannelSetToolsProviderToServerPacketToolCallCompleteDict
9501-
| PluginsChannelSetToolsProviderToServerPacketSessionInitializedDict
9502-
| PluginsChannelSetToolsProviderToServerPacketSessionInitializationFailedDict
9491+
PluginToolCallWarnDict
9492+
| PluginToolCallStatusDict
9493+
| PluginToolCallErrorDict
9494+
| PluginToolCallCompleteDict
9495+
| ProvideToolsInitializedDict
9496+
| ProvideToolsInitFailedDict
95039497
)
95049498

95059499

src/lmstudio/plugin/hooks/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
# Available as lmstudio.plugin.*
1111
__all__ = [
12+
"AsyncToolCallContext",
1213
"PromptPreprocessorController",
1314
"TokenGeneratorController",
14-
"_BaseToolCallContext",
15+
"ToolCallContext",
1516
"ToolsProviderController",
1617
"get_tool_call_context",
1718
]

src/lmstudio/plugin/hooks/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ..._sdk_models import (
2222
# TODO: Define aliases at schema generation time
2323
PluginsChannelSetGeneratorToClientPacketGenerate as TokenGenerationRequest,
24-
PluginsChannelSetToolsProviderToClientPacketInitSession as ProvideToolsInitSession,
24+
ProvideToolsInitSession,
2525
PromptPreprocessingRequest,
2626
SerializedKVConfigSettings,
2727
StatusStepStatus,

0 commit comments

Comments
 (0)