ChatEdenAI()model name for above provider (eg: 'gpt-4' for openai) available models are shown on https://docs.edenai.co/ under 'available providers'
EdenAI chat large language models.
EdenAI is a versatile platform that allows you to access various language models
from different providers such as Google, OpenAI, Cohere, Mistral and more.
To get started, make sure you have the environment variable EDENAI_API_KEY
set with your API key, or pass it as a named parameter to the constructor.
Additionally, EdenAI provides the flexibility to choose from a variety of models,
including the ones like "gpt-4".
Example:
.. code-block:: python
from langchain_community.chat_models import ChatEdenAI from langchain_core.messages import HumanMessage
ChatEdenAI with the desired configurationchat = ChatEdenAI( provider="openai", model="gpt-4", max_tokens=256, temperature=0.75)
messages = [HumanMessage(content="hello")]
chat.invoke(messages)
EdenAI goes beyond mere model invocation. It empowers you with advanced features :
Multiple Providers: access to a diverse range of llms offered by various providers giving you the freedom to choose the best-suited model for your use case.
Fallback Mechanism: Set a fallback mechanism to ensure seamless operations even if the primary provider is unavailable, you can easily switches to an alternative provider.
Usage Statistics: Track usage statistics on a per-project and per-API key basis. This feature allows you to monitor and manage resource consumption effectively.
Monitoring and Observability: EdenAI provides comprehensive monitoring
and observability tools on the platform.
Example of setting up a fallback mechanism:
.. code-block:: python
ChatEdenAI with a fallback providerchat_with_fallback = ChatEdenAI( provider="openai", model="gpt-4", max_tokens=256, temperature=0.75, fallback_provider="google")
you can find more details here : https://docs.edenai.co/reference/text_chat_create