Compare commits

...

7 Commits

Author SHA1 Message Date
Eugene Yurtsev
9daa06974d Merge branch 'master' into eugene/update_llm_result_types 2024-08-01 17:05:19 -04:00
Eugene Yurtsev
0092c10edc Merge branch 'master' into eugene/update_llm_result_types 2024-08-01 15:34:33 -04:00
Eugene Yurtsev
5d2c582794 x 2024-08-01 15:34:29 -04:00
Eugene Yurtsev
304e938ec3 Update 2024-08-01 15:33:51 -04:00
Eugene Yurtsev
053bb03f7f fix linting 2024-08-01 15:32:20 -04:00
Eugene Yurtsev
e17a67d679 x 2024-08-01 10:54:46 -04:00
Eugene Yurtsev
d80018e355 MANUAL: FIX LLM Result (PORT NOW) Needs discriminated union 2024-08-01 10:54:00 -04:00

View File

@@ -1,9 +1,10 @@
from __future__ import annotations
from copy import deepcopy
from typing import List, Optional
from typing import List, Optional, Union
from langchain_core.outputs.generation import Generation
from langchain_core.outputs.chat_generation import ChatGeneration, ChatGenerationChunk
from langchain_core.outputs.generation import Generation, GenerationChunk
from langchain_core.outputs.run_info import RunInfo
from langchain_core.pydantic_v1 import BaseModel
@@ -16,7 +17,9 @@ class LLMResult(BaseModel):
wants to return.
"""
generations: List[List[Generation]]
generations: List[
List[Union[Generation, ChatGeneration, GenerationChunk, ChatGenerationChunk]]
]
"""Generated outputs.
The first dimension of the list represents completions for different input
@@ -28,6 +31,9 @@ class LLMResult(BaseModel):
When returned from an LLM the type is List[List[Generation]].
When returned from a chat model the type is List[List[ChatGeneration]].
The type has been annotated as List of List of Union rather than Union of List
of List to avoid mypy issues.
ChatGeneration is a subclass of Generation that has a field for a structured
chat message.
"""