docs: update openai llm documentation (#20827)

**Description:** Bring OpenAI LLM page to the LCEL era
**Issue:** See discussion #20810
**Dependencies:** None
This commit is contained in:
aditya thomas 2024-04-25 00:56:57 +05:30 committed by GitHub
parent 5ab3f9a995
commit a9c7d47c03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,21 +59,20 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"id": "6fb585dd",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain.chains import LLMChain\n",
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_openai import OpenAI"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"id": "035dea0f",
"metadata": {
"tags": []
@ -89,7 +88,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"id": "3f3458d9",
"metadata": {
"tags": []
@ -113,19 +112,19 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"id": "a641dbd9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"llm_chain = LLMChain(prompt=prompt, llm=llm)"
"llm_chain = prompt | llm"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"id": "9f844993",
"metadata": {
"tags": []
@ -134,10 +133,10 @@
{
"data": {
"text/plain": [
"' Justin Bieber was born in 1994, so the NFL team that won the Super Bowl in 1994 was the Dallas Cowboys.'"
"' Justin Bieber was born on March 1, 1994. The Super Bowl is typically played in late January or early February. So, we need to look at the Super Bowl from 1994. In 1994, the Super Bowl was Super Bowl XXVIII, played on January 30, 1994. The winning team of that Super Bowl was the Dallas Cowboys.'"
]
},
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@ -145,7 +144,7 @@
"source": [
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
"\n",
"llm_chain.run(question)"
"llm_chain.invoke(question)"
]
},
{
@ -173,7 +172,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.11.1 64-bit",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -187,7 +186,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.6"
},
"vscode": {
"interpreter": {