From a9c7d47c034390f0bc7bf96cb52e9f039f257efb Mon Sep 17 00:00:00 2001 From: aditya thomas Date: Thu, 25 Apr 2024 00:56:57 +0530 Subject: [PATCH] docs: update openai llm documentation (#20827) **Description:** Bring OpenAI LLM page to the LCEL era **Issue:** See discussion #20810 **Dependencies:** None --- docs/docs/integrations/llms/openai.ipynb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/docs/integrations/llms/openai.ipynb b/docs/docs/integrations/llms/openai.ipynb index 458505c30ec..a368259fb80 100644 --- a/docs/docs/integrations/llms/openai.ipynb +++ b/docs/docs/integrations/llms/openai.ipynb @@ -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": {