Skip to content

How to get response_metadata from a result with StructuredOutputParser? #25604

Answered by dosubot bot
JANGSOONMYUN asked this question in Q&A
Discussion options

You must be logged in to vote

To access response_metadata when using StructuredOutputParser with response_schemas, you can directly access the dictionary keys since the result is a dictionary. Here is an example of how you can do it:

from langchain.output_parsers.structured import StructuredOutputParser, ResponseSchema
from langchain_openai import ChatOpenAI

# Define your response schemas
response_schemas = [
    ResponseSchema(name="name", description="A good name for the company"),
    ResponseSchema(name="industry", description="The industry the company is in")
]

# Create the parser from the response schemas
output_parser = StructuredOutputParser.from_response_schemas(response_schemas)

# Initialize the language…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@JANGSOONMYUN
Comment options

@dosubot
Comment options

@JANGSOONMYUN
Comment options

@dosubot
Comment options

Answer selected by JANGSOONMYUN
@JANGSOONMYUN
Comment options

@tokyo-s
Comment options

@JANGSOONMYUN
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants