get_format_instructions() — langchain Function Reference
Architecture documentation for the get_format_instructions() function in datetime.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 595e7325_93dc_d4e6_4162_86aa22edf649["get_format_instructions()"] 2f806e11_8650_3820_0781_ec967e39cb53["DatetimeOutputParser"] 595e7325_93dc_d4e6_4162_86aa22edf649 -->|defined in| 2f806e11_8650_3820_0781_ec967e39cb53 595e7325_93dc_d4e6_4162_86aa22edf649["get_format_instructions()"] 595e7325_93dc_d4e6_4162_86aa22edf649 -->|calls| 595e7325_93dc_d4e6_4162_86aa22edf649 595e7325_93dc_d4e6_4162_86aa22edf649["get_format_instructions()"] 595e7325_93dc_d4e6_4162_86aa22edf649 -->|calls| 595e7325_93dc_d4e6_4162_86aa22edf649 style 595e7325_93dc_d4e6_4162_86aa22edf649 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/output_parsers/datetime.py lines 17–46
def get_format_instructions(self) -> str:
"""Returns the format instructions for the given format."""
if self.format == "%Y-%m-%dT%H:%M:%S.%fZ":
examples = comma_list(
[
"2023-07-04T14:30:00.000000Z",
"1999-12-31T23:59:59.999999Z",
"2025-01-01T00:00:00.000000Z",
],
)
else:
try:
now = datetime.now(tz=timezone.utc)
examples = comma_list(
[
now.strftime(self.format),
(now.replace(year=now.year - 1)).strftime(self.format),
(now - timedelta(days=1)).strftime(self.format),
],
)
except ValueError:
# Fallback if the format is very unusual
examples = f"e.g., a valid string in the format {self.format}"
return (
f"Write a datetime string that matches the "
f"following pattern: '{self.format}'.\n\n"
f"Examples: {examples}\n\n"
f"Return ONLY this string, no other words!"
)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does get_format_instructions() do?
get_format_instructions() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/output_parsers/datetime.py.
Where is get_format_instructions() defined?
get_format_instructions() is defined in libs/langchain/langchain_classic/output_parsers/datetime.py at line 17.
What does get_format_instructions() call?
get_format_instructions() calls 1 function(s): 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