from langchain_core.pydantic_v1 import BaseModel, Field
# 定义一个类
class Alist(BaseModel):
key_words: list=Field(description="has five keywords list")
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4o-2024-08-06")
llm_out_struct = model.with_structured_output(Alist)
llm_out_struct.invoke("generate five key words about animals")
for i in range(50):
print(llm_out_struct.invoke("generate five key words about animals"))