Skip to content

Commit

Permalink
Update app/llm/request_handler/capability_request_handler.py
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
kaancayli and coderabbitai[bot] authored Nov 11, 2024
1 parent 6d3c5ef commit eafbb03
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/llm/request_handler/capability_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,28 @@ def bind_tools(
self,
tools: Sequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]],
) -> LanguageModel:
"""Bind the tools to the models"""
"""Bind the provided tools to the selected ChatModel.
Args:
tools: A sequence of tools to bind. Can be one of:
- Dict[str, Any]: Tool configuration dictionary
- Type[BaseModel]: Pydantic model class
- Callable: Function to be used as a tool
- BaseTool: LangChain tool instance
Returns:
LanguageModel: The selected chat model with tools bound
Raises:
ValueError: If tools sequence is empty or contains unsupported tool types
TypeError: If selected model doesn't support tool binding
"""
if not tools:
raise ValueError("Tools sequence cannot be empty")

llm = self._select_model(ChatModel)
if not hasattr(llm, 'bind_tools'):
raise TypeError(f"Selected model {llm.description} doesn't support tool binding")

llm.bind_tools(tools)
return llm

0 comments on commit eafbb03

Please sign in to comment.