Datetime parser | ğŸ¦œï¸�ğŸ”— Langchain






Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/â€‹OPromptsLanguage modelsOutput parsersList parserDatetime parserEnum parserAuto-fixing parserPydantic (JSON) parserRetry parserStructured output parserXML parserRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/â€‹OOutput parsersDatetime parserDatetime parserThis OutputParser can be used to parse LLM output into datetime format.from langchain.prompts import PromptTemplatefrom langchain.output_parsers import DatetimeOutputParserfrom langchain.chains import LLMChainfrom langchain.llms import OpenAIoutput_parser = DatetimeOutputParser()template = """Answer the users question:{question}{format_instructions}"""prompt = PromptTemplate.from_template(    template,    partial_variables={"format_instructions": output_parser.get_format_instructions()},)chain = LLMChain(prompt=prompt, llm=OpenAI())output = chain.run("around when was bitcoin founded?")output    '\n\n2008-01-03T18:15:05.000000Z'output_parser.parse(output)    datetime.datetime(2008, 1, 3, 18, 15, 5)PreviousList parserNextEnum parserCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.
This OutputParser can be used to parse LLM output into datetime format.
This OutputParser can be used to parse LLM output into datetime format. ->: Datetime parser | ğŸ¦œï¸�ğŸ”— Langchain






Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/â€‹OPromptsLanguage modelsOutput parsersList parserDatetime parserEnum parserAuto-fixing parserPydantic (JSON) parserRetry parserStructured output parserXML parserRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/â€‹OOutput parsersDatetime parserDatetime parserThis OutputParser can be used to parse LLM output into datetime format.from langchain.prompts import PromptTemplatefrom langchain.output_parsers import DatetimeOutputParserfrom langchain.chains import LLMChainfrom langchain.llms import OpenAIoutput_parser = DatetimeOutputParser()template = """Answer the users question:{question}{format_instructions}"""prompt = PromptTemplate.from_template(    template,    partial_variables={"format_instructions": output_parser.get_format_instructions()},)chain = LLMChain(prompt=prompt, llm=OpenAI())output = chain.run("around when was bitcoin founded?")output    '\n\n2008-01-03T18:15:05.000000Z'output_parser.parse(output)    datetime.datetime(2008, 1, 3, 18, 15, 5)PreviousList parserNextEnum parserCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.