LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicoutput_parsersstructuredStructuredOutputParserget_format_instructions
    Method●Since v1.0

    get_format_instructions

    Get format instructions for the output parser.

    Example:

    from langchain_classic.output_parsers.structured import (
        StructuredOutputParser, ResponseSchema
    )
    
    response_schemas = [
        ResponseSchema(
            name="foo",
            description="a list of strings",
            type="List[string]"
            ),
        ResponseSchema(
            name="bar",
            description="a string",
            type="string"
            ),
    ]
    
    parser = StructuredOutputParser.from_response_schemas(response_schemas)
    
    print(parser.get_format_instructions())  # noqa: T201
    
    output:
    # The output should be a Markdown code snippet formatted in the following
    # schema, including the leading and trailing "```json" and "```":
    #
    # ```json
    # {
    #     "foo": List[string]  // a list of strings
    #     "bar": string  // a string
    # }
    # ```
    
    Args:
        only_json: If `True`, only the json in the Markdown code snippet
            will be returned, without the introducing text.
    Copy
    get_format_instructions(
        self,
        only_json: bool = False,
    ) -> str
    View source on GitHub