Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lmstudio/json_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"PredictionRoundResult",
"PromptProcessingCallback",
"SerializedLMSExtendedError",
"ToolDefinition",
"ToolFunctionDef",
"ToolFunctionDefDict",
]
Expand Down Expand Up @@ -1361,6 +1362,9 @@ def _additional_config_options(cls) -> DictObject:
return {"for_text_completion": True}


ToolDefinition: TypeAlias = ToolFunctionDef | ToolFunctionDefDict | Callable[..., Any]


class ChatResponseEndpoint(PredictionEndpoint[TPrediction]):
"""API channel endpoint for requesting a chat response from a model."""

Expand All @@ -1371,7 +1375,7 @@ class ChatResponseEndpoint(PredictionEndpoint[TPrediction]):
# TODO: Consider implementing this conversion in _kv_config.py
@staticmethod
def parse_tools(
tools: Iterable[ToolFunctionDef | ToolFunctionDefDict | Callable[..., Any]],
tools: Iterable[ToolDefinition],
) -> tuple[LlmToolUseSettingToolArray, ClientToolMap]:
"""Split tool function definitions into server and client details."""
if not tools:
Expand Down
5 changes: 2 additions & 3 deletions src/lmstudio/sync_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@
RemoteCallHandler,
TModelInfo,
TPrediction,
ToolFunctionDef,
ToolFunctionDefDict,
ToolDefinition,
check_model_namespace,
load_struct,
_model_spec_to_api_dict,
Expand Down Expand Up @@ -1547,7 +1546,7 @@ def respond(
def act(
self,
chat: Chat | ChatHistoryDataDict | str,
tools: Iterable[ToolFunctionDef | ToolFunctionDefDict],
tools: Iterable[ToolDefinition],
*,
max_prediction_rounds: int | None = None,
config: LlmPredictionConfig | LlmPredictionConfigDict | None = None,
Expand Down
Loading