Home / Function/ get_format_instructions() — langchain Function Reference

get_format_instructions() — langchain Function Reference

Architecture documentation for the get_format_instructions() function in pydantic.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad["get_format_instructions()"]
  570792b6_910c_5259_8419_5183ac1b1409["PydanticOutputParser"]
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad -->|defined in| 570792b6_910c_5259_8419_5183ac1b1409
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad["get_format_instructions()"]
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad -->|calls| 6bf20b4d_d595_a2e8_9a0a_c828bb0760ad
  03884eb2_86e4_9795_d1e4_b84eaa05761e["_get_schema()"]
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad -->|calls| 03884eb2_86e4_9795_d1e4_b84eaa05761e
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad["get_format_instructions()"]
  6bf20b4d_d595_a2e8_9a0a_c828bb0760ad -->|calls| 6bf20b4d_d595_a2e8_9a0a_c828bb0760ad
  style 6bf20b4d_d595_a2e8_9a0a_c828bb0760ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/output_parsers/pydantic.py lines 93–111

    def get_format_instructions(self) -> str:
        """Return the format instructions for the JSON output.

        Returns:
            The format instructions for the JSON output.
        """
        # Copy schema to avoid altering original Pydantic schema.
        schema = dict(self._get_schema(self.pydantic_object).items())

        # Remove extraneous fields.
        reduced_schema = schema
        if "title" in reduced_schema:
            del reduced_schema["title"]
        if "type" in reduced_schema:
            del reduced_schema["type"]
        # Ensure json in context is well-formed with double quotes.
        schema_str = json.dumps(reduced_schema, ensure_ascii=False)

        return _PYDANTIC_FORMAT_INSTRUCTIONS.format(schema=schema_str)

Domain

Frequently Asked Questions

What does get_format_instructions() do?
get_format_instructions() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/pydantic.py.
Where is get_format_instructions() defined?
get_format_instructions() is defined in libs/core/langchain_core/output_parsers/pydantic.py at line 93.
What does get_format_instructions() call?
get_format_instructions() calls 2 function(s): _get_schema, get_format_instructions.
What calls get_format_instructions()?
get_format_instructions() is called by 1 function(s): get_format_instructions.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free