parse_result() — langchain Function Reference
Architecture documentation for the parse_result() function in test_base_parsers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 25fd0a7f_3c3d_d9f7_0cbd_520068021510["parse_result()"] 9521b311_e9e2_a1c2_b324_bd7449374ca5["StrInvertCase"] 25fd0a7f_3c3d_d9f7_0cbd_520068021510 -->|defined in| 9521b311_e9e2_a1c2_b324_bd7449374ca5 6777a403_618b_6329_886e_6bb4224e04fe["test_base_generation_parser()"] 6777a403_618b_6329_886e_6bb4224e04fe -->|calls| 25fd0a7f_3c3d_d9f7_0cbd_520068021510 ca5fabf7_107e_cdd5_a7a6_2f608c56533a["test_base_transform_output_parser()"] ca5fabf7_107e_cdd5_a7a6_2f608c56533a -->|calls| 25fd0a7f_3c3d_d9f7_0cbd_520068021510 style 25fd0a7f_3c3d_d9f7_0cbd_520068021510 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/output_parsers/test_base_parsers.py lines 22–46
def parse_result(
self, result: list[Generation], *, partial: bool = False
) -> str:
"""Parse a list of model Generations into a specific format.
Args:
result: A list of `Generation` to be parsed. The Generations are assumed
to be different candidate outputs for a single model input.
Many parsers assume that only a single generation is passed it in.
We will assert for that
partial: Whether to allow partial results. This is used for parsers
that support streaming
"""
if len(result) != 1:
msg = "This output parser can only be used with a single generation."
raise NotImplementedError(msg)
generation = result[0]
if not isinstance(generation, ChatGeneration):
# Say that this one only works with chat generations
msg = "This output parser can only be used with a chat generation."
raise OutputParserException(msg)
content = generation.message.content
assert isinstance(content, str)
return content.swapcase()
Domain
Subdomains
Source
Frequently Asked Questions
What does parse_result() do?
parse_result() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/output_parsers/test_base_parsers.py.
Where is parse_result() defined?
parse_result() is defined in libs/core/tests/unit_tests/output_parsers/test_base_parsers.py at line 22.
What calls parse_result()?
parse_result() is called by 2 function(s): test_base_generation_parser, test_base_transform_output_parser.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free