Home / Function/ aparse() — langchain Function Reference

aparse() — langchain Function Reference

Architecture documentation for the aparse() function in fix.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c06537ac_0eca_0592_087a_610e09bf6218["aparse()"]
  cbd1bd7d_786a_2287_38a2_3e4d067733c2["OutputFixingParser"]
  c06537ac_0eca_0592_087a_610e09bf6218 -->|defined in| cbd1bd7d_786a_2287_38a2_3e4d067733c2
  c5c0daae_f6e5_68d9_5565_5e2f022b06fc["get_format_instructions()"]
  c06537ac_0eca_0592_087a_610e09bf6218 -->|calls| c5c0daae_f6e5_68d9_5565_5e2f022b06fc
  style c06537ac_0eca_0592_087a_610e09bf6218 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/output_parsers/fix.py lines 108–143

    async def aparse(self, completion: str) -> T:
        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(
                        instructions=self.parser.get_format_instructions(),
                        completion=completion,
                        error=repr(e),
                    )
                else:
                    try:
                        completion = await self.retry_chain.ainvoke(
                            {
                                "instructions": self.parser.get_format_instructions(),
                                "completion": completion,
                                "error": repr(e),
                            },
                        )
                    except (NotImplementedError, AttributeError):
                        # Case: self.parser does not have get_format_instructions
                        completion = await self.retry_chain.ainvoke(
                            {
                                "completion": completion,
                                "error": repr(e),
                            },
                        )

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

Domain

Subdomains

Frequently Asked Questions

What does aparse() do?
aparse() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/output_parsers/fix.py.
Where is aparse() defined?
aparse() is defined in libs/langchain/langchain_classic/output_parsers/fix.py at line 108.
What does aparse() call?
aparse() calls 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