|
4 | 4 |
|
5 | 5 | from langchain_core.language_models.chat_models import BaseChatModel |
6 | 6 | from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage |
7 | | -from ldai import ( |
8 | | - AIAgentConfig, |
9 | | - AICompletionConfig, |
10 | | - AIJudgeConfig, |
11 | | - LDMessage, |
12 | | -) |
| 7 | +from ldai import LDMessage |
| 8 | +from ldai.models import AIConfigKind |
13 | 9 | from ldai.providers import AIProvider |
14 | 10 | from ldai.providers.types import ChatResponse, LDAIMetrics, StructuredResponse |
15 | 11 | from ldai.tracker import TokenUsage |
16 | 12 |
|
17 | | -# Type alias matching the one in ldai.models |
18 | | -AIConfigKind = Union[AIAgentConfig, AICompletionConfig, AIJudgeConfig] |
19 | | - |
20 | 13 |
|
21 | 14 | class LangChainProvider(AIProvider): |
22 | 15 | """ |
@@ -44,7 +37,7 @@ async def create(ai_config: AIConfigKind, logger: Optional[Any] = None) -> 'Lang |
44 | 37 | :param logger: Optional logger for the provider |
45 | 38 | :return: Configured LangChainProvider instance |
46 | 39 | """ |
47 | | - llm = await LangChainProvider.create_langchain_model(ai_config) |
| 40 | + llm = LangChainProvider.create_langchain_model(ai_config) |
48 | 41 | return LangChainProvider(llm, logger) |
49 | 42 |
|
50 | 43 | async def invoke_model(self, messages: List[LDMessage]) -> ChatResponse: |
@@ -253,7 +246,7 @@ def convert_messages_to_langchain( |
253 | 246 | return result |
254 | 247 |
|
255 | 248 | @staticmethod |
256 | | - async def create_langchain_model(ai_config: AIConfigKind) -> BaseChatModel: |
| 249 | + def create_langchain_model(ai_config: AIConfigKind) -> BaseChatModel: |
257 | 250 | """ |
258 | 251 | Create a LangChain model from an AI configuration. |
259 | 252 |
|
|
0 commit comments