manual mapping (#14422)

This commit is contained in:
Harrison Chase
2023-12-08 16:29:33 -08:00
committed by GitHub
parent c24f277b7c
commit f5befe3b89
48 changed files with 1094 additions and 194 deletions

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from typing import Any, Dict, Literal
from typing import Any, Dict, List, Literal
from langchain_core.messages import BaseMessage, BaseMessageChunk
from langchain_core.outputs.generation import Generation
@@ -27,6 +27,11 @@ class ChatGeneration(Generation):
raise ValueError("Error while initializing ChatGeneration") from e
return values
@classmethod
def get_lc_namespace(cls) -> List[str]:
"""Get the namespace of the langchain object."""
return ["langchain", "schema", "output"]
class ChatGenerationChunk(ChatGeneration):
"""A ChatGeneration chunk, which can be concatenated with other
@@ -41,6 +46,11 @@ class ChatGenerationChunk(ChatGeneration):
type: Literal["ChatGenerationChunk"] = "ChatGenerationChunk" # type: ignore[assignment] # noqa: E501
"""Type is used exclusively for serialization purposes."""
@classmethod
def get_lc_namespace(cls) -> List[str]:
"""Get the namespace of the langchain object."""
return ["langchain", "schema", "output"]
def __add__(self, other: ChatGenerationChunk) -> ChatGenerationChunk:
if isinstance(other, ChatGenerationChunk):
generation_info = (

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from typing import Any, Dict, Literal, Optional
from typing import Any, Dict, List, Literal, Optional
from langchain_core.load import Serializable
@@ -24,10 +24,20 @@ class Generation(Serializable):
"""Return whether this class is serializable."""
return True
@classmethod
def get_lc_namespace(cls) -> List[str]:
"""Get the namespace of the langchain object."""
return ["langchain", "schema", "output"]
class GenerationChunk(Generation):
"""A Generation chunk, which can be concatenated with other Generation chunks."""
@classmethod
def get_lc_namespace(cls) -> List[str]:
"""Get the namespace of the langchain object."""
return ["langchain", "schema", "output"]
def __add__(self, other: GenerationChunk) -> GenerationChunk:
if isinstance(other, GenerationChunk):
generation_info = (