mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-26 11:35:02 +02:00
release(langgraph): v1 working branch (#6093)
Diff viewer for langgraph v1 alpha releases --------- Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: William FH <13333726+hinthornw@users.noreply.github.com> Co-authored-by: Mason Daugherty <github@mdrxy.com> Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
co-authored by
ccurme
William FH
Mason Daugherty
Mason Daugherty
parent
9b46cba1fb
commit
bce1dcfcd2
File diff suppressed because one or more lines are too long
@@ -74,17 +74,26 @@ class FakeChatModel(GenericFakeChatModel):
|
||||
assert isinstance(content, str)
|
||||
content_chunks = cast(list[str], re.split(r"(\s)", content))
|
||||
|
||||
for token in content_chunks:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(content=token, id=message.id)
|
||||
)
|
||||
for i, token in enumerate(content_chunks):
|
||||
if i == len(content_chunks) - 1:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(
|
||||
content=token, id=message.id, chunk_position="last"
|
||||
)
|
||||
)
|
||||
else:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(content=token, id=message.id)
|
||||
)
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(token, chunk=chunk)
|
||||
yield chunk
|
||||
else:
|
||||
args = message.__dict__
|
||||
args.pop("type")
|
||||
chunk = ChatGenerationChunk(message=AIMessageChunk(**args))
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(**args, chunk_position="last")
|
||||
)
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token("", chunk=chunk)
|
||||
yield chunk
|
||||
@@ -122,17 +131,27 @@ class FakeChatModel(GenericFakeChatModel):
|
||||
assert isinstance(content, str)
|
||||
content_chunks = cast(list[str], re.split(r"(\s)", content))
|
||||
|
||||
for token in content_chunks:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(content=token, id=message.id)
|
||||
)
|
||||
for i, token in enumerate(content_chunks):
|
||||
if i == len(content_chunks) - 1:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(
|
||||
content=token, id=message.id, chunk_position="last"
|
||||
)
|
||||
)
|
||||
else:
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(content=token, id=message.id)
|
||||
)
|
||||
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(token, chunk=chunk)
|
||||
yield chunk
|
||||
else:
|
||||
args = message.__dict__
|
||||
args.pop("type")
|
||||
chunk = ChatGenerationChunk(message=AIMessageChunk(**args))
|
||||
chunk = ChatGenerationChunk(
|
||||
message=AIMessageChunk(**args, chunk_position="last")
|
||||
)
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token("", chunk=chunk)
|
||||
yield chunk
|
||||
|
||||
@@ -1387,6 +1387,7 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
|
||||
"type": "tool_call_chunk",
|
||||
}
|
||||
],
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 1,
|
||||
@@ -1446,6 +1447,7 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
|
||||
"type": "tool_call_chunk",
|
||||
},
|
||||
],
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 3,
|
||||
@@ -1494,6 +1496,7 @@ def test_prebuilt_tool_chat(snapshot: SnapshotAssertion) -> None:
|
||||
(
|
||||
_AnyIdAIMessageChunk(
|
||||
content="answer",
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 5,
|
||||
|
||||
@@ -1140,6 +1140,7 @@ async def test_prebuilt_tool_chat() -> None:
|
||||
"type": "tool_call_chunk",
|
||||
}
|
||||
],
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 1,
|
||||
@@ -1199,6 +1200,7 @@ async def test_prebuilt_tool_chat() -> None:
|
||||
"type": "tool_call_chunk",
|
||||
},
|
||||
],
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 3,
|
||||
@@ -1247,6 +1249,7 @@ async def test_prebuilt_tool_chat() -> None:
|
||||
(
|
||||
_AnyIdAIMessageChunk(
|
||||
content="answer",
|
||||
chunk_position="last",
|
||||
),
|
||||
{
|
||||
"langgraph_step": 5,
|
||||
|
||||
@@ -20,7 +20,10 @@ from langgraph.graph.message import REMOVE_ALL_MESSAGES, MessagesState, push_mes
|
||||
from langgraph.graph.state import StateGraph
|
||||
from tests.messages import _AnyIdHumanMessage
|
||||
|
||||
_, CORE_MINOR, CORE_PATCH = (int(v) for v in langchain_core.__version__.split("."))
|
||||
_, CORE_MINOR, CORE_PATCH = (
|
||||
int("".join(c for c in v if c.isdigit()))
|
||||
for v in langchain_core.__version__.split(".")
|
||||
)
|
||||
|
||||
|
||||
def test_add_single_message():
|
||||
|
||||
@@ -6601,7 +6601,7 @@ def test_tags_stream_mode_messages() -> None:
|
||||
)
|
||||
) == [
|
||||
(
|
||||
_AnyIdAIMessageChunk(content="foo"),
|
||||
_AnyIdAIMessageChunk(content="foo", chunk_position="last"),
|
||||
{
|
||||
"langgraph_step": 1,
|
||||
"langgraph_node": "call_model",
|
||||
|
||||
@@ -7548,7 +7548,7 @@ async def test_tags_stream_mode_messages() -> None:
|
||||
)
|
||||
] == [
|
||||
(
|
||||
_AnyIdAIMessageChunk(content="foo"),
|
||||
_AnyIdAIMessageChunk(content="foo", chunk_position="last"),
|
||||
{
|
||||
"langgraph_step": 1,
|
||||
"langgraph_node": "call_model",
|
||||
|
||||
@@ -17,16 +17,13 @@ import langsmith
|
||||
import pytest
|
||||
from typing_extensions import NotRequired, Required, TypedDict
|
||||
|
||||
from langgraph._internal._config import _is_not_empty
|
||||
from langgraph._internal._config import _is_not_empty, ensure_config
|
||||
from langgraph._internal._fields import (
|
||||
_is_optional_type,
|
||||
get_enhanced_type_hints,
|
||||
get_field_default,
|
||||
)
|
||||
from langgraph._internal._runnable import (
|
||||
is_async_callable,
|
||||
is_async_generator,
|
||||
)
|
||||
from langgraph._internal._runnable import is_async_callable, is_async_generator
|
||||
from langgraph.constants import END
|
||||
from langgraph.graph import StateGraph
|
||||
from langgraph.graph.state import CompiledStateGraph
|
||||
@@ -301,3 +298,24 @@ def test_is_not_empty() -> None:
|
||||
assert not _is_not_empty([])
|
||||
assert not _is_not_empty(())
|
||||
assert not _is_not_empty({})
|
||||
|
||||
|
||||
def test_configurable_metadata():
|
||||
config = {
|
||||
"configurable": {
|
||||
"a-key": "foo",
|
||||
"somesecretval": "bar",
|
||||
"sometoken": "thetoken",
|
||||
"__dontinclude": "bar",
|
||||
"includeme": "hi",
|
||||
"andme": 42,
|
||||
"nested": {"foo": "bar"},
|
||||
"nooverride": -2,
|
||||
},
|
||||
"metadata": {"nooverride": 18},
|
||||
}
|
||||
expected = {"includeme", "andme", "nooverride"}
|
||||
merged = ensure_config(config)
|
||||
metadata = merged["metadata"]
|
||||
assert metadata.keys() == expected
|
||||
assert metadata["nooverride"] == 18
|
||||
|
||||
Reference in New Issue
Block a user