docs: fix structured output doc (#26360)

This commit is contained in:
Bagatur
2024-09-11 16:56:15 -07:00
committed by GitHub
parent cacd68b2a7
commit 28594567de

View File

@@ -257,17 +257,17 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 19,
"id": "9194bcf2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Response(output=Joke(setup='Why was the cat sitting on the computer?', punchline='To keep an eye on the mouse!', rating=8))"
"FinalResponse(final_output=Joke(setup='Why was the cat sitting on the computer?', punchline='Because it wanted to keep an eye on the mouse!', rating=7))"
]
},
"execution_count": 4,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -293,28 +293,28 @@
" response: str = Field(description=\"A conversational response to the user's query\")\n",
"\n",
"\n",
"class Response(BaseModel):\n",
" output: Union[Joke, ConversationalResponse]\n",
"class FinalResponse(BaseModel):\n",
" final_output: Union[Joke, ConversationalResponse]\n",
"\n",
"\n",
"structured_llm = llm.with_structured_output(Response)\n",
"structured_llm = llm.with_structured_output(FinalResponse)\n",
"\n",
"structured_llm.invoke(\"Tell me a joke about cats\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 20,
"id": "84d86132",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Response(output=ConversationalResponse(response=\"I'm just a digital assistant, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?\"))"
"FinalResponse(final_output=ConversationalResponse(response=\"I'm just a bunch of code, so I don't have feelings, but I'm here and ready to help you! How can I assist you today?\"))"
]
},
"execution_count": 5,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
@@ -915,9 +915,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "poetry-venv-2",
"language": "python",
"name": "python3"
"name": "poetry-venv-2"
},
"language_info": {
"codemirror_mode": {