Home / Function/ get_format_instructions() — langchain Function Reference

get_format_instructions() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  26f39076_94a6_44ef_5396_69f52b286a72["get_format_instructions()"]
  0d9a7db1_a024_a63e_d6da_4108a6cd2019["JsonOutputParser"]
  26f39076_94a6_44ef_5396_69f52b286a72 -->|defined in| 0d9a7db1_a024_a63e_d6da_4108a6cd2019
  26f39076_94a6_44ef_5396_69f52b286a72["get_format_instructions()"]
  26f39076_94a6_44ef_5396_69f52b286a72 -->|calls| 26f39076_94a6_44ef_5396_69f52b286a72
  03884eb2_86e4_9795_d1e4_b84eaa05761e["_get_schema()"]
  26f39076_94a6_44ef_5396_69f52b286a72 -->|calls| 03884eb2_86e4_9795_d1e4_b84eaa05761e
  26f39076_94a6_44ef_5396_69f52b286a72["get_format_instructions()"]
  26f39076_94a6_44ef_5396_69f52b286a72 -->|calls| 26f39076_94a6_44ef_5396_69f52b286a72
  style 26f39076_94a6_44ef_5396_69f52b286a72 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/output_parsers/json.py lines 104–123

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

        Returns:
            The format instructions for the JSON output.
        """
        if self.pydantic_object is None:
            return "Return a JSON object."
        # 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 JSON_FORMAT_INSTRUCTIONS.format(schema=schema_str)

Domain

Subdomains

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/json.py.
Where is get_format_instructions() defined?
get_format_instructions() is defined in libs/core/langchain_core/output_parsers/json.py at line 104.
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