Skip to content

Commit d72da29

Browse files
authored
docs: Fix classification notebook small mistake (#32636)
Fix some minor issues in the Classification Notebook. While some code still using hardcoded OpenAI model instead of selected chat model. Specifically, on page [Classify Text into Labels](https://python.langchain.com/docs/tutorials/classification/) We selected chat model before and have init_chat_model with our chosen mode. <img width="1262" height="576" alt="image" src="https://github.com/user-attachments/assets/14eb436b-d2ef-4074-96d8-71640a13c0f7" /> But the following sample code still uses the hard-coded OpenAI model, which in my case is obviously unrunable (lack of openai api key) <img width="1263" height="543" alt="image" src="https://github.com/user-attachments/assets/d13846aa-1c4b-4dee-b9c1-c66570ba3461" />
1 parent 653b090 commit d72da29

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

docs/docs/tutorials/classification.ipynb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"outputs": [],
9696
"source": [
9797
"from langchain_core.prompts import ChatPromptTemplate\n",
98-
"from langchain_openai import ChatOpenAI\n",
9998
"from pydantic import BaseModel, Field\n",
10099
"\n",
101100
"tagging_prompt = ChatPromptTemplate.from_template(\n",
@@ -253,9 +252,7 @@
253252
"\"\"\"\n",
254253
")\n",
255254
"\n",
256-
"llm = ChatOpenAI(temperature=0, model=\"gpt-4o-mini\").with_structured_output(\n",
257-
" Classification\n",
258-
")"
255+
"structured_llm = llm.with_structured_output(Classification)"
259256
]
260257
},
261258
{
@@ -286,7 +283,7 @@
286283
"source": [
287284
"inp = \"Estoy increiblemente contento de haberte conocido! Creo que seremos muy buenos amigos!\"\n",
288285
"prompt = tagging_prompt.invoke({\"input\": inp})\n",
289-
"llm.invoke(prompt)"
286+
"structured_llm.invoke(prompt)"
290287
]
291288
},
292289
{
@@ -309,7 +306,7 @@
309306
"source": [
310307
"inp = \"Estoy muy enojado con vos! Te voy a dar tu merecido!\"\n",
311308
"prompt = tagging_prompt.invoke({\"input\": inp})\n",
312-
"llm.invoke(prompt)"
309+
"structured_llm.invoke(prompt)"
313310
]
314311
},
315312
{
@@ -332,7 +329,7 @@
332329
"source": [
333330
"inp = \"Weather is ok here, I can go outside without much more than a coat\"\n",
334331
"prompt = tagging_prompt.invoke({\"input\": inp})\n",
335-
"llm.invoke(prompt)"
332+
"structured_llm.invoke(prompt)"
336333
]
337334
},
338335
{

0 commit comments

Comments
 (0)