Skip to content

Commit 7e21a98

Browse files
committed
fix lint
1 parent 717c80b commit 7e21a98

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from langchain_core.language_models.chat_models import BaseChatModel
66
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage
7-
87
from ldai import (
98
AIAgentConfig,
109
AICompletionConfig,
@@ -22,7 +21,7 @@
2221
class LangChainProvider(AIProvider):
2322
"""
2423
LangChain implementation of AIProvider.
25-
24+
2625
This provider integrates LangChain models with LaunchDarkly's tracking capabilities.
2726
"""
2827

@@ -36,7 +35,6 @@ def __init__(self, llm: BaseChatModel, logger: Optional[Any] = None):
3635
super().__init__(logger)
3736
self._llm = llm
3837

39-
4038
@staticmethod
4139
async def create(ai_config: AIConfigKind, logger: Optional[Any] = None) -> 'LangChainProvider':
4240
"""
@@ -166,7 +164,7 @@ def get_chat_model(self) -> BaseChatModel:
166164
def map_provider(ld_provider_name: str) -> str:
167165
"""
168166
Map LaunchDarkly provider names to LangChain provider names.
169-
167+
170168
This method enables seamless integration between LaunchDarkly's standardized
171169
provider naming and LangChain's naming conventions.
172170
@@ -185,7 +183,7 @@ def map_provider(ld_provider_name: str) -> str:
185183
def get_ai_metrics_from_response(response: BaseMessage) -> LDAIMetrics:
186184
"""
187185
Get AI metrics from a LangChain provider response.
188-
186+
189187
This method extracts token usage information and success status from LangChain responses
190188
and returns a LaunchDarkly AIMetrics object.
191189
@@ -217,7 +215,7 @@ def get_ai_metrics_from_response(response: BaseMessage) -> LDAIMetrics:
217215
def create_ai_metrics(langchain_response: BaseMessage) -> LDAIMetrics:
218216
"""
219217
Create AI metrics information from a LangChain provider response.
220-
218+
221219
.. deprecated::
222220
Use `get_ai_metrics_from_response()` instead.
223221
@@ -232,7 +230,7 @@ def convert_messages_to_langchain(
232230
) -> List[Union[HumanMessage, SystemMessage, AIMessage]]:
233231
"""
234232
Convert LaunchDarkly messages to LangChain messages.
235-
233+
236234
This helper method enables developers to work directly with LangChain message types
237235
while maintaining compatibility with LaunchDarkly's standardized message format.
238236
@@ -241,7 +239,7 @@ def convert_messages_to_langchain(
241239
:raises ValueError: If an unsupported message role is encountered
242240
"""
243241
result: List[Union[HumanMessage, SystemMessage, AIMessage]] = []
244-
242+
245243
for msg in messages:
246244
if msg.role == 'system':
247245
result.append(SystemMessage(content=msg.content))
@@ -251,14 +249,14 @@ def convert_messages_to_langchain(
251249
result.append(AIMessage(content=msg.content))
252250
else:
253251
raise ValueError(f'Unsupported message role: {msg.role}')
254-
252+
255253
return result
256254

257255
@staticmethod
258256
async def create_langchain_model(ai_config: AIConfigKind) -> BaseChatModel:
259257
"""
260258
Create a LangChain model from an AI configuration.
261-
259+
262260
This public helper method enables developers to initialize their own LangChain models
263261
using LaunchDarkly AI configurations.
264262
@@ -270,7 +268,7 @@ async def create_langchain_model(ai_config: AIConfigKind) -> BaseChatModel:
270268
model_name = ai_config.model.name if ai_config.model else ''
271269
provider = ai_config.provider.name if ai_config.provider else ''
272270
parameters = {}
273-
271+
274272
if ai_config.model and hasattr(ai_config.model, '_parameters') and ai_config.model._parameters:
275273
parameters = ai_config.model._parameters.copy()
276274

0 commit comments

Comments
 (0)