Home / Function/ _to_chat_result() — langchain Function Reference

_to_chat_result() — langchain Function Reference

Architecture documentation for the _to_chat_result() function in huggingface.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  de46fdd9_0f79_97fa_7be9_db461cf70b2c["_to_chat_result()"]
  8cf0d6c0_abf8_3ee2_fd00_8bfc8c02058a["ChatHuggingFace"]
  de46fdd9_0f79_97fa_7be9_db461cf70b2c -->|defined in| 8cf0d6c0_abf8_3ee2_fd00_8bfc8c02058a
  0e798408_eb45_2a4b_1ddb_579fdb006f07["_generate()"]
  0e798408_eb45_2a4b_1ddb_579fdb006f07 -->|calls| de46fdd9_0f79_97fa_7be9_db461cf70b2c
  f159f0cd_7dad_a4c8_5648_66f72caa1ece["_agenerate()"]
  f159f0cd_7dad_a4c8_5648_66f72caa1ece -->|calls| de46fdd9_0f79_97fa_7be9_db461cf70b2c
  style de46fdd9_0f79_97fa_7be9_db461cf70b2c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py lines 981–992

    def _to_chat_result(llm_result: LLMResult) -> ChatResult:
        chat_generations = []

        for g in llm_result.generations[0]:
            chat_generation = ChatGeneration(
                message=AIMessage(content=g.text), generation_info=g.generation_info
            )
            chat_generations.append(chat_generation)

        return ChatResult(
            generations=chat_generations, llm_output=llm_result.llm_output
        )

Domain

Subdomains

Frequently Asked Questions

What does _to_chat_result() do?
_to_chat_result() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py.
Where is _to_chat_result() defined?
_to_chat_result() is defined in libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py at line 981.
What calls _to_chat_result()?
_to_chat_result() is called by 2 function(s): _agenerate, _generate.

Analyze Your Own Codebase

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

Try Supermodel Free