docs: ChatOpenAI update module import path and calling method (#18169)

**Description:**
(a) Update to the module import path to reflect the splitting up of
langchain into separate packages
(b) Update to the documentation to include the new calling method
(invoke)
This commit is contained in:
aditya thomas
2024-03-02 02:02:20 +05:30
committed by GitHub
parent 4adac20d7b
commit e6e60e2492

View File

@@ -29,12 +29,12 @@
},
"outputs": [],
"source": [
"from langchain.prompts.chat import (\n",
"from langchain_core.messages import HumanMessage, SystemMessage\n",
"from langchain_core.prompts.chat import (\n",
" ChatPromptTemplate,\n",
" HumanMessagePromptTemplate,\n",
" SystemMessagePromptTemplate,\n",
")\n",
"from langchain_core.messages import HumanMessage, SystemMessage\n",
"from langchain_openai import ChatOpenAI"
]
},
@@ -91,7 +91,7 @@
" content=\"Translate this sentence from English to French. I love programming.\"\n",
" ),\n",
"]\n",
"chat(messages)"
"chat.invoke(messages)"
]
},
{
@@ -144,7 +144,7 @@
")\n",
"\n",
"# get a chat completion from the formatted messages\n",
"chat(\n",
"chat.invoke(\n",
" chat_prompt.format_prompt(\n",
" input_language=\"English\", output_language=\"French\", text=\"I love programming.\"\n",
" ).to_messages()\n",