langchain/libs/partners/ai21/langchain_ai21/chat/chat_factory.py
Leonid Ganeline a70b7a688e
ai21: docstrings (#23142)
Added missed docstrings. Format docstrings to the consistent format
(used in the API Reference)
2024-06-19 08:51:15 -04:00

24 lines
516 B
Python

from langchain_ai21.chat.chat_adapter import (
ChatAdapter,
J2ChatAdapter,
JambaChatCompletionsAdapter,
)
def create_chat_adapter(model: str) -> ChatAdapter:
"""Create a chat adapter based on the model.
Args:
model: The model to create the chat adapter for.
Returns:
The chat adapter.
"""
if "j2" in model:
return J2ChatAdapter()
if "jamba" in model:
return JambaChatCompletionsAdapter()
raise ValueError(f"Model {model} not supported.")