{"id":123759,"date":"2026-11-08T04:41:01","date_gmt":"2026-11-07T20:41:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123759.html"},"modified":"2026-11-08T04:41:01","modified_gmt":"2026-11-07T20:41:01","slug":"langchain-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%8806%ef%bc%89%ef%bc%9a%e7%aa%81%e7%a0%b4%e5%a4%a7%e6%a8%a1%e5%9e%8b%e9%99%90%e5%88%b6-%e7%bb%93%e6%9e%84%e5%8c%96%e8%be%93","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123759.html","title":{"rendered":"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09"},"content":{"rendered":"<h3>&#x1f4cc; \u6838\u5fc3\u7ed3\u8bba&#xff08;TL;DR&#xff09;<\/h3>\n<li>\n<p>\u8303\u5f0f\u8f6c\u6362&#xff1a;\u5927\u6a21\u578b\u7684\u9ed8\u8ba4\u8f93\u51fa\u662f\u81ea\u7136\u8bed\u8a00\u5b57\u7b26\u4e32&#xff0c;\u4e0d\u53ef\u63a7\u3002\u901a\u8fc7 with_structured_output() \u7ed3\u5408 Pydantic \u6a21\u578b&#xff0c;\u53ef\u4ee5\u5f3a\u5236 LLM \u8fd4\u56de\u6807\u51c6\u7684 JSON \u5bf9\u8c61&#xff0c;\u5b9e\u73b0\u201c\u4ece\u5b57\u7b26\u4e32\u5230\u5bf9\u8c61\u201d\u7684\u8303\u5f0f\u8f6c\u6362\u3002<\/p>\n<\/li>\n<li>\n<p>\u5e95\u5c42\u539f\u7406&#xff1a;\u8be5\u65b9\u6cd5\u5e76\u975e\u9b54\u6cd5&#xff0c;\u800c\u662f\u5c06 Pydantic \u6a21\u578b\u8f6c\u6362\u4e3a JSON Schema&#xff0c;\u5229\u7528\u5927\u6a21\u578b\u7684 Function Calling&#xff08;\u5de5\u5177\u8c03\u7528&#xff09;\u6216 JSON Mode \u80fd\u529b&#xff0c;\u7ea6\u675f\u5176\u8f93\u51fa\u683c\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p>\u7cbe\u51c6\u63d0\u53d6&#xff1a;\u5728 Field(description&#061;&#034;&#8230;&#034;) \u4e2d\u586b\u5199\u7684\u63cf\u8ff0\u4f1a\u4f5c\u4e3a\u63d0\u793a\u8bcd\u53d1\u7ed9\u5927\u6a21\u578b&#xff0c;\u63cf\u8ff0\u8d8a\u7cbe\u51c6&#xff0c;\u6570\u636e\u63d0\u53d6\u7684\u6210\u529f\u7387\u8d8a\u9ad8\u3002<\/p>\n<\/li>\n<li>\n<p>\u8054\u5408\u7c7b\u578b&#xff08;Union&#xff09;&#xff1a;\u901a\u8fc7 Union \u53ef\u4ee5\u7ec4\u5408\u591a\u4e2a Pydantic \u6a21\u578b&#xff08;\u5982&#xff1a;\u6b63\u5e38\u56de\u7b54 vs \u8fdd\u89c4\u62d2\u7edd&#xff09;&#xff0c;\u8ba9\u5927\u6a21\u578b\u6839\u636e\u4e0a\u4e0b\u6587\u81ea\u884c\u5224\u65ad\u5e76\u8def\u7531\u8f93\u51fa\u683c\u5f0f\u3002<\/p>\n<\/li>\n<h3>&#x1f50d; \u4e00\u3001 \u539f\u7406\u56fe\u89e3\u4e0e\u6838\u5fc3\u6982\u5ff5<\/h3>\n<h4>1. \u4e3a\u4ec0\u4e48\u7a0b\u5e8f\u9700\u8981 JSON&#xff1f;<\/h4>\n<p>\u5982\u679c\u4f60\u53ea\u5f97\u5230\u4e00\u4e2a\u5b57\u7b26\u4e32\u201c\u738b\u4f1f\u8eab\u9ad8\u4e24\u7c73\u201d&#xff0c;\u4f60\u5fc5\u987b\u5199\u590d\u6742\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u53bb\u62c6\u89e3\u3002\u800c\u5982\u679c\u4f60\u5f97\u5230\u7684\u662f {&#034;name&#034;: &#034;\u738b\u4f1f&#034;, &#034;height&#034;: &#034;2.0&#034;}&#xff0c;\u7a0b\u5e8f\u53ea\u9700\u4e00\u884c data[&#034;name&#034;] \u5373\u53ef\u5b58\u5165\u6570\u636e\u5e93\u3002<\/p>\n<h4>2. LangChain \u5982\u4f55\u5f3a\u5236\u683c\u5f0f&#xff1f;<\/h4>\n<p>\u5f53\u4f60\u8c03\u7528 model.with_structured_output(MySchema) \u65f6&#xff0c;LangChain \u4f1a\u63d0\u53d6\u8be5\u7c7b\u7684\u5185\u90e8\u7ed3\u6784&#xff0c;\u751f\u6210\u4e00\u6bb5\u7cbe\u786e\u7684 JSON Schema\u3002\u8bf7\u6c42 API \u65f6&#xff0c;\u8fd9\u4e2a Schema \u4f1a\u88ab\u4f20\u7ed9\u5927\u6a21\u578b&#xff0c;\u5927\u6a21\u578b\u88ab\u4e25\u683c\u9650\u5236\u53ea\u80fd\u8f93\u51fa\u7b26\u5408\u8be5\u7ed3\u6784\u7684 JSON\u3002<\/p>\n<h3>&#x1f4bb; \u4e8c\u3001 \u7cbe\u9009\u6838\u5fc3\u4ee3\u7801\u7247\u6bb5<\/h3>\n<h4>1. \u57fa\u7840\u4fe1\u606f\u63d0\u53d6&#xff08;Pydantic&#xff09;<\/h4>\n<p>from typing import Optional, List<br \/>\nfrom pydantic import BaseModel, Field<br \/>\nfrom langchain_openai import ChatOpenAI<br \/>\nfrom langchain_core.messages import HumanMessage<\/p>\n<p># \u5b9a\u4e49 Schema \u7ed3\u6784<br \/>\nclass Person(BaseModel):<br \/>\n    &#034;&#034;&#034;\u5355\u4e2a\u4eba\u7684\u4fe1\u606f&#034;&#034;&#034;<br \/>\n    name: Optional[str] &#061; Field(default&#061;None, description&#061;&#034;\u59d3\u540d&#034;)<br \/>\n    height: Optional[str] &#061; Field(default&#061;None, description&#061;&#034;\u8eab\u9ad8&#xff0c;\u5355\u4f4d\u7c73&#034;)<\/p>\n<p>class Data(BaseModel):<br \/>\n    people: List[Person] &#061; Field(description&#061;&#034;\u6240\u6709\u4eba\u7269\u7684\u5217\u8868&#034;)<\/p>\n<p># \u521d\u59cb\u5316\u6a21\u578b\u5e76\u7ed1\u5b9a\u8f93\u51fa<br \/>\nmodel &#061; ChatOpenAI(model&#061;&#034;deepseek-chat&#034;, &#8230;)<br \/>\nstructured_model &#061; model.with_structured_output(Data)<\/p>\n<p># \u8c03\u7528\u5e76\u76f4\u63a5\u83b7\u53d6\u5bf9\u8c61<br \/>\nresult &#061; structured_model.invoke([HumanMessage(content&#061;&#034;\u738b\u4f1f\u8eab\u9ad8\u4e24\u7c73\u3002&#034;)])<br \/>\nprint(result.people[0].name) # \u8f93\u51fa&#xff1a;\u738b\u4f1f<\/p>\n<h4><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"152\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107204100-6aef8cdc87ece.png\" width=\"336\" \/><\/h4>\n<h4>2. \u8054\u5408\u7c7b\u578b\u5206\u6d41&#xff08;Union \u5904\u7406\u591a\u610f\u56fe&#xff09;<\/h4>\n<p>from typing import Union<\/p>\n<p>class Joke(BaseModel):<br \/>\n    setup: str &#061; Field(description&#061;&#034;\u7b11\u8bdd\u5f00\u5934&#034;)<br \/>\n    punchline: str &#061; Field(description&#061;&#034;\u7b11\u8bdd\u5305\u88b1&#034;)<\/p>\n<p>class Refusal(BaseModel):<br \/>\n    reason: str &#061; Field(description&#061;&#034;\u62d2\u7edd\u539f\u56e0&#034;)<\/p>\n<p>class FinalResponse(BaseModel):<br \/>\n    output: Union[Joke, Refusal]<\/p>\n<p>structured_model &#061; model.with_structured_output(FinalResponse)<br \/>\n# \u4f20\u5165\u8fdd\u89c4\u5185\u5bb9&#xff0c;\u6a21\u578b\u4f1a\u81ea\u52a8\u8d70 Refusal \u683c\u5f0f<br \/>\nres &#061; structured_model.invoke(&#034;\u6559\u6211\u600e\u4e48\u76d7\u53f7&#034;)<br \/>\nprint(res.output.reason) # \u8f93\u51fa\u62d2\u7edd\u539f\u56e0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"236\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107204100-6aef8cdcb5ada.png\" width=\"1267\" \/><\/p>\n<p>(\u5b8c\u6574\u7684\u5305\u542b\u5404\u79cd\u63d0\u53d6\u573a\u666f\u7684\u4ee3\u7801\u5df2\u4e0a\u4f20\u81f3 Gitee \u4ed3\u5e93)<\/p>\n<h3>\u26a0\ufe0f \u4e09\u3001 \u8e29\u5751\u6392\u67e5\u6392\u96f7<\/h3>\n<p>\u62a5\u9519 ValidationError \u6216\u63d0\u53d6\u7ed3\u679c\u4e0d\u7406\u60f3&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6392\u67e5&#xff1a;\u9996\u5148\u68c0\u67e5 Field(description&#061;&#034;&#8230;&#034;) \u662f\u5426\u5199\u5f97\u8db3\u591f\u8be6\u7ec6\u3002\u5176\u6b21&#xff0c;\u5c1d\u8bd5\u5c06\u6a21\u578b\u7684 temperature \u8bbe\u7f6e\u4e3a 0.0&#xff0c;\u5f3a\u5236\u5927\u6a21\u578b\u653e\u5f03\u778e\u7f16&#xff0c;\u4e13\u6ce8\u6700\u9ad8\u6982\u7387\u7684\u63d0\u53d6\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u7f3a\u5c11\u5b57\u6bb5\u503c\u5bfc\u81f4\u6a21\u578b\u201c\u5f3a\u884c\u7f16\u9020\u201d&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6392\u67e5&#xff1a;\u5bf9\u4e8e\u53ef\u80fd\u4e0d\u5b58\u5728\u7684\u5b57\u6bb5&#xff0c;\u52a1\u5fc5\u4f7f\u7528 Optional[str] \u5e76\u5728\u63d0\u793a\u8bcd\u4e2d\u5f3a\u8c03\u201c\u5982\u679c\u6587\u672c\u4e2d\u672a\u63d0\u53ca&#xff0c;\u8bf7\u8fd4\u56de null\u201d&#xff0c;\u9632\u6b62\u5927\u6a21\u578b\u6839\u636e\u4e0a\u4e0b\u6587\u81c6\u9020\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u6a21\u578b\u4e0d\u652f\u6301 with_structured_output&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6392\u67e5&#xff1a;\u8be5\u529f\u80fd\u4f9d\u8d56\u5e95\u5c42\u6a21\u578b\u7684 JSON \u6216 Function Calling \u80fd\u529b\u3002\u5982\u679c\u4f60\u4f7f\u7528\u8fc7\u65e7\u7684\u672c\u5730\u6a21\u578b&#xff0c;\u53ef\u80fd\u4f1a\u62a5\u9519\u3002\u5efa\u8bae\u5207\u6362\u5230 DeepSeek\u3001GPT-4 \u6216\u652f\u6301 Function Calling \u7684 Qwen \u7cfb\u5217\u3002<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f4cc; \u6838\u5fc3\u7ed3\u8bba&#xff08;TL;DR&#xff09;\u8303\u5f0f\u8f6c\u6362&#xff1a;\u5927\u6a21\u578b\u7684\u9ed8\u8ba4\u8f93\u51fa\u662f\u81ea\u7136\u8bed\u8a00\u5b57\u7b26\u4e32&#xff0c;\u4e0d\u53ef\u63a7\u3002\u901a\u8fc7 with_structured_output() \u7ed3\u5408 Pydantic \u6a21\u578b&#xff0c;\u53ef\u4ee5\u5f3a\u5236 LLM \u8fd4\u56de\u6807\u51c6\u7684 JSON \u5bf9\u8c61&#xff0c;\u5b9e\u73b0\u201c\u4ece\u5b57\u7b26\u4e32\u5230\u5bf9\u8c61\u201d\u7684\u8303\u5f0f\u8f6c\u6362\u3002\u5e95\u5c42\u539f\u7406&#xff1a;\u8be5\u65b9\u6cd5\u5e76\u975e\u9b54\u6cd5&#xff0c;\u800c\u662f\u5c06 Pydantic \u6a21\u578b\u8f6c\u6362\u4e3a JSON Schema&#xff0c;\u5229\u7528\u5927<\/p>\n","protected":false},"author":2,"featured_media":123757,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[997,149,371,305],"topic":[],"class_list":["post-123759","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-langchain","tag-windows","tag-371","tag-305"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/123759.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f4cc; \u6838\u5fc3\u7ed3\u8bba&#xff08;TL;DR&#xff09;\u8303\u5f0f\u8f6c\u6362&#xff1a;\u5927\u6a21\u578b\u7684\u9ed8\u8ba4\u8f93\u51fa\u662f\u81ea\u7136\u8bed\u8a00\u5b57\u7b26\u4e32&#xff0c;\u4e0d\u53ef\u63a7\u3002\u901a\u8fc7 with_structured_output() \u7ed3\u5408 Pydantic \u6a21\u578b&#xff0c;\u53ef\u4ee5\u5f3a\u5236 LLM \u8fd4\u56de\u6807\u51c6\u7684 JSON \u5bf9\u8c61&#xff0c;\u5b9e\u73b0\u201c\u4ece\u5b57\u7b26\u4e32\u5230\u5bf9\u8c61\u201d\u7684\u8303\u5f0f\u8f6c\u6362\u3002\u5e95\u5c42\u539f\u7406&#xff1a;\u8be5\u65b9\u6cd5\u5e76\u975e\u9b54\u6cd5&#xff0c;\u800c\u662f\u5c06 Pydantic \u6a21\u578b\u8f6c\u6362\u4e3a JSON Schema&#xff0c;\u5229\u7528\u5927\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123759.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-07T20:41:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107204100-6aef8cdc87ece.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123759.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123759.html\",\"name\":\"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-07T20:41:01+00:00\",\"dateModified\":\"2026-11-07T20:41:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123759.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123759.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123759.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/123759.html","og_locale":"zh_CN","og_type":"article","og_title":"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f4cc; \u6838\u5fc3\u7ed3\u8bba&#xff08;TL;DR&#xff09;\u8303\u5f0f\u8f6c\u6362&#xff1a;\u5927\u6a21\u578b\u7684\u9ed8\u8ba4\u8f93\u51fa\u662f\u81ea\u7136\u8bed\u8a00\u5b57\u7b26\u4e32&#xff0c;\u4e0d\u53ef\u63a7\u3002\u901a\u8fc7 with_structured_output() \u7ed3\u5408 Pydantic \u6a21\u578b&#xff0c;\u53ef\u4ee5\u5f3a\u5236 LLM \u8fd4\u56de\u6807\u51c6\u7684 JSON \u5bf9\u8c61&#xff0c;\u5b9e\u73b0\u201c\u4ece\u5b57\u7b26\u4e32\u5230\u5bf9\u8c61\u201d\u7684\u8303\u5f0f\u8f6c\u6362\u3002\u5e95\u5c42\u539f\u7406&#xff1a;\u8be5\u65b9\u6cd5\u5e76\u975e\u9b54\u6cd5&#xff0c;\u800c\u662f\u5c06 Pydantic \u6a21\u578b\u8f6c\u6362\u4e3a JSON Schema&#xff0c;\u5229\u7528\u5927","og_url":"https:\/\/www.wsisp.com\/helps\/123759.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-07T20:41:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107204100-6aef8cdc87ece.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123759.html","url":"https:\/\/www.wsisp.com\/helps\/123759.html","name":"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-07T20:41:01+00:00","dateModified":"2026-11-07T20:41:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123759.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123759.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123759.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"[LangChain] \u5b66\u4e60\u7b14\u8bb0\uff0806\uff09\uff1a\u7a81\u7834\u5927\u6a21\u578b\u9650\u5236\u2014\u2014\u7ed3\u6784\u5316\u8f93\u51fa\uff08Structured Output\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=123759"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123759\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/123757"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123759"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}