mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-30 00:04:19 +00:00
x
This commit is contained in:
parent
5d7fbedb21
commit
c26f2447eb
@ -39,7 +39,6 @@ from langchain_core.language_models.base import (
|
||||
)
|
||||
from langchain_core.messages import (
|
||||
AIMessage,
|
||||
BaseMessage,
|
||||
convert_to_openai_image_block,
|
||||
get_buffer_string,
|
||||
is_data_content_block,
|
||||
@ -924,13 +923,13 @@ class BaseChatModelV1(BaseLanguageModel[AIMessageV1], ABC):
|
||||
Returns:
|
||||
The sum of the number of tokens across the messages.
|
||||
"""
|
||||
messages = [_convert_from_v1_message(message) for message in messages]
|
||||
messages_v0 = [_convert_from_v1_message(message) for message in messages]
|
||||
if tools is not None:
|
||||
warnings.warn(
|
||||
"Counting tokens in tool schemas is not yet supported. Ignoring tools.",
|
||||
stacklevel=2,
|
||||
)
|
||||
return sum(self.get_num_tokens(get_buffer_string([m])) for m in messages)
|
||||
return sum(self.get_num_tokens(get_buffer_string([m])) for m in messages_v0)
|
||||
|
||||
|
||||
def _gen_info_and_msg_metadata(
|
||||
|
@ -329,9 +329,9 @@ class AIMessageChunk:
|
||||
def add_chunk_to_invalid_tool_calls(chunk: ToolCallChunk) -> None:
|
||||
invalid_tool_calls.append(
|
||||
create_invalid_tool_call(
|
||||
name=chunk["name"],
|
||||
args=chunk["args"],
|
||||
id=chunk["id"],
|
||||
name=chunk.get("name", ""),
|
||||
args=chunk.get("args", ""),
|
||||
id=chunk.get("id", ""),
|
||||
error=None,
|
||||
)
|
||||
)
|
||||
@ -342,9 +342,9 @@ class AIMessageChunk:
|
||||
if isinstance(args_, dict):
|
||||
tool_calls.append(
|
||||
create_tool_call(
|
||||
name=chunk["name"] or "",
|
||||
name=chunk.get("name", ""),
|
||||
args=args_,
|
||||
id=chunk["id"],
|
||||
id=chunk.get("id", ""),
|
||||
)
|
||||
)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user