Home / Function/ aparse_with_prompt() — langchain Function Reference

aparse_with_prompt() — langchain Function Reference

Architecture documentation for the aparse_with_prompt() function in retry.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  95d8cdd7_ad78_0741_b125_a6ce998f7adf["aparse_with_prompt()"]
  d9504162_cd94_4db4_a3ec_7621a6287225["RetryWithErrorOutputParser"]
  95d8cdd7_ad78_0741_b125_a6ce998f7adf -->|defined in| d9504162_cd94_4db4_a3ec_7621a6287225
  af9365c1_7554_045e_da47_85d942fb6e5c["aparse_with_prompt()"]
  af9365c1_7554_045e_da47_85d942fb6e5c -->|calls| 95d8cdd7_ad78_0741_b125_a6ce998f7adf
  af9365c1_7554_045e_da47_85d942fb6e5c["aparse_with_prompt()"]
  95d8cdd7_ad78_0741_b125_a6ce998f7adf -->|calls| af9365c1_7554_045e_da47_85d942fb6e5c
  style 95d8cdd7_ad78_0741_b125_a6ce998f7adf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/output_parsers/retry.py lines 262–297

    async def aparse_with_prompt(self, completion: str, prompt_value: PromptValue) -> T:
        """Parse the output of an LLM call using a wrapped parser.

        Args:
            completion: The chain completion to parse.
            prompt_value: The prompt to use to parse the completion.

        Returns:
            The parsed completion.
        """
        retries = 0

        while retries <= self.max_retries:
            try:
                return await self.parser.aparse(completion)
            except OutputParserException as e:
                if retries == self.max_retries:
                    raise
                retries += 1
                if self.legacy and hasattr(self.retry_chain, "arun"):
                    completion = await self.retry_chain.arun(
                        prompt=prompt_value.to_string(),
                        completion=completion,
                        error=repr(e),
                    )
                else:
                    completion = await self.retry_chain.ainvoke(
                        {
                            "prompt": prompt_value.to_string(),
                            "completion": completion,
                            "error": repr(e),
                        },
                    )

        msg = "Failed to parse"
        raise OutputParserException(msg)

Domain

Subdomains

Frequently Asked Questions

What does aparse_with_prompt() do?
aparse_with_prompt() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/output_parsers/retry.py.
Where is aparse_with_prompt() defined?
aparse_with_prompt() is defined in libs/langchain/langchain_classic/output_parsers/retry.py at line 262.
What does aparse_with_prompt() call?
aparse_with_prompt() calls 1 function(s): aparse_with_prompt.
What calls aparse_with_prompt()?
aparse_with_prompt() is called by 1 function(s): aparse_with_prompt.

Analyze Your Own Codebase

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

Try Supermodel Free