langchain[patch], core[patch]: Make common utils public (#13932)

- rename `langchain_core.chat_models.base._generate_from_stream` -> `generate_from_stream`
- rename `langchain_core.chat_models.base._agenerate_from_stream` -> `agenerate_from_stream`
- export `langchain_core.utils.utils.build_extra_kwargs` from `langchain_core.utils`
This commit is contained in:
Bagatur
2023-11-27 15:34:46 -08:00
committed by GitHub
parent c0277d06e8
commit 10a6e7cbb6
16 changed files with 45 additions and 42 deletions

View File

@@ -55,7 +55,7 @@ def _get_verbosity() -> bool:
return get_verbose()
def _generate_from_stream(stream: Iterator[ChatGenerationChunk]) -> ChatResult:
def generate_from_stream(stream: Iterator[ChatGenerationChunk]) -> ChatResult:
generation: Optional[ChatGenerationChunk] = None
for chunk in stream:
if generation is None:
@@ -66,7 +66,7 @@ def _generate_from_stream(stream: Iterator[ChatGenerationChunk]) -> ChatResult:
return ChatResult(generations=[generation])
async def _agenerate_from_stream(
async def agenerate_from_stream(
stream: AsyncIterator[ChatGenerationChunk],
) -> ChatResult:
generation: Optional[ChatGenerationChunk] = None

View File

@@ -13,6 +13,7 @@ from langchain_core.utils.input import (
)
from langchain_core.utils.loading import try_load_from_hub
from langchain_core.utils.utils import (
build_extra_kwargs,
check_package_version,
convert_to_secret_str,
get_pydantic_field_names,
@@ -37,4 +38,5 @@ __all__ = [
"raise_for_status_with_text",
"xor_args",
"try_load_from_hub",
"build_extra_kwargs",
]

View File

@@ -15,6 +15,7 @@ EXPECTED_ALL = [
"raise_for_status_with_text",
"xor_args",
"try_load_from_hub",
"build_extra_kwargs",
]