LangChain Python

Usage

The following code snippet

from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage

llm = ChatOpenAI(
    model_name="gpt-3.5-turbo",
    openai_api_key="My OPENAI Key"
)

messages = [HumanMessage(content="Say this is a test")]

llm.invoke(messages)

becomes

from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage

llm = ChatOpenAI(
    model_name="router",
    openai_api_base="https://withmartian.com/api/openai/v1",
    openai_api_key="My MARTIAN Key"
)

messages = [HumanMessage(content="Say this is a test")]

llm.invoke(messages)

Last updated