langchain.chains.openai_functions.extraction
.create_extraction_chain_pydantic¶
- langchain.chains.openai_functions.extraction.create_extraction_chain_pydantic(pydantic_schema: Any, llm: BaseLanguageModel, prompt: Optional[BasePromptTemplate] = None, verbose: bool = False) Chain [source]¶
[Deprecated] 创建一个链条,使用pydantic模式从一个段落中提取信息。
- 参数:
pydantic_schema: 要提取的实体的pydantic模式。 llm: 要使用的语言模型。 prompt: 用于提取的提示。 verbose: 是否以详细模式运行。在详细模式下,一些中间日志将打印到控制台。默认为全局`verbose`值,可通过`langchain.globals.get_verbose()`访问。
- 返回:
可用于从段落中提取信息的链条。
Notes
Deprecated since version 0.1.14: LangChain has introduced a method called with_structured_output thatis available on ChatModels capable of tool calling.You can read more about the method here: https://python.langchain.com/docs/modules/model_io/chat/structured_output/Please follow our extraction use case documentation for more guidelineson how to do information extraction with LLMs.https://python.langchain.com/docs/use_cases/extraction/.If you notice other issues, please provide feedback here:https://github.com/langchain-ai/langchain/discussions/18154 Use from langchain_core.pydantic_v1 import BaseModel, Field from langchain_anthropic import ChatAnthropic
- class Joke(BaseModel):
setup: str = Field(description=”The setup of the joke”) punchline: str = Field(description=”The punchline to the joke”)
# Or any other chat model that supports tools. # Please reference to to the documentation of structured_output # to see an up to date list of which models support # with_structured_output. model = ChatAnthropic(model=”claude-3-opus-20240229”, temperature=0) structured_llm = model.with_structured_output(Joke) structured_llm.invoke(“Tell me a joke about cats.
Make sure to call the Joke function.”)
instead.
- Parameters
pydantic_schema (Any) –
llm (BaseLanguageModel) –
prompt (Optional[BasePromptTemplate]) –
verbose (bool) –
- Return type