Skip to content

Commit fc067ce

Browse files
committed
Review and resolve minor TODO items
* Workaround for lmstudio.js schema export bug is no longer needed * Tool call parameters are validated, update comments accordingly * Test suite covers the essential handle APIs in various test cases * Adding signal subscription support is speculative, not definite
1 parent fbe90f3 commit fc067ce

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

src/lmstudio/json_api.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@
9595
LlmTool,
9696
LlmToolUseSettingToolArray,
9797
ModelInfo,
98-
# TODO: Import this once the definition is fixed in lmstudio.js
99-
# https://github.com/lmstudio-ai/lmstudio.js/pull/222
100-
# ModelInstanceInfo,
98+
ModelInstanceInfo,
10199
ModelSearchOptsDict,
102100
ModelSpecifier,
103101
ModelSpecifierDict,
@@ -197,10 +195,6 @@
197195
EmbeddingRpcUnloadModelParameter | LlmRpcUnloadModelParameter
198196
)
199197

200-
# TODO: Drop this workaround once the lmstudio.js schema export is fixed:
201-
# https://github.com/lmstudio-ai/lmstudio.js/pull/222
202-
ModelInstanceInfo: TypeAlias = EmbeddingModelInstanceInfo | LlmInstanceInfo
203-
204198

205199
class ModelSessionTypes(Generic[TLoadConfig]):
206200
"""Helper class to group related types for code sharing across model namespaces."""
@@ -516,8 +510,8 @@ def __init__(self, logger: StructuredLogger) -> None:
516510
self._last_channel_id = 0
517511
self._pending_calls: dict[int, TQueue] = {}
518512
self._last_call_id = 0
519-
# TODO: add `_last_subscriber_id` when adding signal support
520-
# TODO: add `_active_subscriptions` when adding signal support
513+
# `_active_subscriptions` (if we add signal support)
514+
# `_last_subscriber_id` (if we add signal support)
521515
self._logger = logger
522516

523517
def all_queues(self) -> Iterator[TQueue]:
@@ -1288,6 +1282,7 @@ def request_tool_call(
12881282
)
12891283
result = _ToolCallResultData(content=err_msg, tool_call_id=tool_call_id)
12901284
return lambda: result
1285+
# Validate parameters against their specification
12911286
params_struct, implementation = client_tool
12921287
raw_kwds = request.arguments
12931288
try:
@@ -1300,7 +1295,7 @@ def request_tool_call(
13001295
return lambda: result
13011296
kwds = to_builtins(parsed_kwds)
13021297

1303-
# TODO: Validate parameters against their specification
1298+
# Allow caller to schedule the tool call request for background execution
13041299
def _call_requested_tool() -> _ToolCallResultData:
13051300
call_result = implementation(**kwds)
13061301
return _ToolCallResultData(

tests/async/test_model_handles_async.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ async def test_completion_llm_handle_async(model_id: str, caplog: LogCap) -> Non
4545
assert response.content
4646

4747

48-
# TODO: also test `complete_stream`, `respond`, and `respond_stream`,
49-
# as all the wrappers are implemented independently of each other
50-
51-
5248
@pytest.mark.asyncio
5349
@pytest.mark.lmstudio
5450
@pytest.mark.parametrize("model_id", (EXPECTED_EMBEDDING, EXPECTED_EMBEDDING_ID))

tests/sync/test_model_handles_sync.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ def test_completion_llm_handle_sync(model_id: str, caplog: LogCap) -> None:
5151
assert response.content
5252

5353

54-
# TODO: also test `complete_stream`, `respond`, and `respond_stream`,
55-
# as all the wrappers are implemented independently of each other
56-
57-
5854
@pytest.mark.lmstudio
5955
@pytest.mark.parametrize("model_id", (EXPECTED_EMBEDDING, EXPECTED_EMBEDDING_ID))
6056
def test_embedding_handle_sync(model_id: str, caplog: LogCap) -> None:

0 commit comments

Comments
 (0)