Skip to content

Commit 3110be6

Browse files
jsonbaileyclaude
andcommitted
fix: Remove accidentally resurrected code from pre-PR-115 merge conflict
- Remove tool_registry parameter from create_langchain_model (matches main) - Remove _resolve_tools_for_langchain (no longer needed) - Remove BaseMessage import (unused) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7c5d067 commit 3110be6

2 files changed

Lines changed: 6 additions & 41 deletions

File tree

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langchain_helper.py

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Any, Dict, List, Optional, Union
33

44
from langchain_core.language_models.chat_models import BaseChatModel
5-
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage
5+
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
66
from ldai import LDMessage, log
77
from ldai.models import AIConfigKind
88
from ldai.providers import ToolRegistry
@@ -52,18 +52,12 @@ def convert_messages_to_langchain(
5252
return result
5353

5454

55-
def create_langchain_model(ai_config: AIConfigKind, tool_registry: Optional[ToolRegistry] = None) -> BaseChatModel:
55+
def create_langchain_model(ai_config: AIConfigKind) -> BaseChatModel:
5656
"""
5757
Create a LangChain BaseChatModel from a LaunchDarkly AI configuration.
5858
59-
If the config includes tool definitions and a tool_registry is provided, tools found
60-
in the registry are bound to the model. Tools not found in the registry are skipped
61-
with a warning. Built-in provider tools (e.g. code_interpreter) are not supported
62-
via LangChain's bind_tools abstraction and are skipped with a warning.
63-
6459
:param ai_config: The LaunchDarkly AI configuration
65-
:param tool_registry: Optional registry mapping tool names to callable implementations
66-
:return: A configured LangChain BaseChatModel, with tools bound if applicable
60+
:return: A configured LangChain BaseChatModel
6761
"""
6862
from langchain.chat_models import init_chat_model
6963

@@ -74,27 +68,20 @@ def create_langchain_model(ai_config: AIConfigKind, tool_registry: Optional[Tool
7468
model_name = model_dict.get('name', '')
7569
provider = provider_dict.get('name', '')
7670
parameters = dict(model_dict.get('parameters') or {})
77-
tool_definitions = parameters.pop('tools', []) or []
71+
parameters.pop('tools', None)
7872
mapped_provider = map_provider(provider)
7973

8074
# Bedrock requires the foundation provider (e.g. Bedrock:Anthropic) passed in
8175
# parameters separately from model_provider, which is used for LangChain routing.
8276
if mapped_provider == 'bedrock_converse' and 'provider' not in parameters:
8377
parameters['provider'] = provider.removeprefix('bedrock:')
8478

85-
model = init_chat_model(
79+
return init_chat_model(
8680
model_name,
8781
model_provider=mapped_provider,
8882
**parameters,
8983
)
9084

91-
if tool_definitions and tool_registry is not None:
92-
bindable = _resolve_tools_for_langchain(tool_definitions, tool_registry)
93-
if bindable:
94-
model = model.bind_tools(bindable)
95-
96-
return model
97-
9885

9986
def _iter_valid_tools(
10087
tool_definitions: List[Dict[str, Any]],
@@ -131,28 +118,6 @@ def _iter_valid_tools(
131118
return valid
132119

133120

134-
def _resolve_tools_for_langchain(
135-
tool_definitions: List[Dict[str, Any]],
136-
tool_registry: ToolRegistry,
137-
) -> List[Dict[str, Any]]:
138-
"""
139-
Match LD tool definitions against a registry, returning function-calling tool dicts
140-
for tools that have a callable implementation. Built-in provider tools and tools
141-
missing from the registry are skipped with a warning.
142-
"""
143-
return [
144-
{
145-
'type': 'function',
146-
'function': {
147-
'name': name,
148-
'description': td.get('description', ''),
149-
'parameters': td.get('parameters', {'type': 'object', 'properties': {}}),
150-
},
151-
}
152-
for name, td in _iter_valid_tools(tool_definitions, tool_registry)
153-
]
154-
155-
156121
def build_tools(ai_config: AIConfigKind, tool_registry: ToolRegistry) -> List[Any]:
157122
"""
158123
Return callables from the registry for each tool defined in the AI config.

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langgraph_agent_graph_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def handle_traversal(node: AgentGraphNode, ctx: dict) -> None:
110110
tool_fns: list = []
111111
if node_config.model:
112112
# We send an empty tool registry to avoid binding tools to the model.
113-
lc_model = create_langchain_model(node_config, tool_registry=None)
113+
lc_model = create_langchain_model(node_config)
114114

115115
tool_fns = build_structured_tools(node_config, tools_ref)
116116

0 commit comments

Comments
 (0)