mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
core[patch]: update LanguageModelInput from List to Sequence (#14405)
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
4dab37741a
commit
cda68d717c
@ -48,7 +48,7 @@ def _get_token_ids_default_method(text: str) -> List[int]:
|
||||
return tokenizer.encode(text)
|
||||
|
||||
|
||||
LanguageModelInput = Union[PromptValue, str, List[BaseMessage]]
|
||||
LanguageModelInput = Union[PromptValue, str, Sequence[BaseMessage]]
|
||||
LanguageModelOutput = Union[BaseMessage, str]
|
||||
LanguageModelLike = Runnable[LanguageModelInput, LanguageModelOutput]
|
||||
LanguageModelOutputVar = TypeVar("LanguageModelOutputVar", BaseMessage, str)
|
||||
|
@ -142,7 +142,7 @@ class BaseChatModel(BaseLanguageModel[BaseMessage], ABC):
|
||||
return input
|
||||
elif isinstance(input, str):
|
||||
return StringPromptValue(text=input)
|
||||
elif isinstance(input, list):
|
||||
elif isinstance(input, Sequence):
|
||||
return ChatPromptValue(messages=input)
|
||||
else:
|
||||
raise ValueError(
|
||||
|
@ -205,7 +205,7 @@ class BaseLLM(BaseLanguageModel[str], ABC):
|
||||
return input
|
||||
elif isinstance(input, str):
|
||||
return StringPromptValue(text=input)
|
||||
elif isinstance(input, list):
|
||||
elif isinstance(input, Sequence):
|
||||
return ChatPromptValue(messages=input)
|
||||
else:
|
||||
raise ValueError(
|
||||
|
Loading…
Reference in New Issue
Block a user