mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-26 11:35:02 +02:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3318eea2bc | ||
|
|
7f35d73423 | ||
|
|
5dbb56292c | ||
|
|
c9a83a049f | ||
|
|
4079f3fdfa | ||
|
|
95a2e7bc21 | ||
|
|
005a296346 | ||
|
|
fdb26e4224 | ||
|
|
ddb6240ff9 | ||
|
|
4d1e0c59c7 |
@@ -2987,6 +2987,7 @@ class Pregel(
|
||||
output_keys: str | Sequence[str] | None = None,
|
||||
interrupt_before: All | Sequence[str] | None = None,
|
||||
interrupt_after: All | Sequence[str] | None = None,
|
||||
durability: Durability | None = None,
|
||||
**kwargs: Any,
|
||||
) -> dict[str, Any] | Any:
|
||||
"""Run the graph with a single input and config.
|
||||
@@ -3001,6 +3002,10 @@ class Pregel(
|
||||
output_keys: Optional. The output keys to retrieve from the graph run.
|
||||
interrupt_before: Optional. The nodes to interrupt the graph run before.
|
||||
interrupt_after: Optional. The nodes to interrupt the graph run after.
|
||||
durability: The durability mode for the graph execution, defaults to "async". Options are:
|
||||
- `"sync"`: Changes are persisted synchronously before the next step starts.
|
||||
- `"async"`: Changes are persisted asynchronously while the next step executes.
|
||||
- `"exit"`: Changes are persisted only when the graph exits.
|
||||
**kwargs: Additional keyword arguments to pass to the graph run.
|
||||
|
||||
Returns:
|
||||
@@ -3024,6 +3029,7 @@ class Pregel(
|
||||
output_keys=output_keys,
|
||||
interrupt_before=interrupt_before,
|
||||
interrupt_after=interrupt_after,
|
||||
durability=durability,
|
||||
**kwargs,
|
||||
):
|
||||
if stream_mode == "values":
|
||||
@@ -3066,6 +3072,7 @@ class Pregel(
|
||||
output_keys: str | Sequence[str] | None = None,
|
||||
interrupt_before: All | Sequence[str] | None = None,
|
||||
interrupt_after: All | Sequence[str] | None = None,
|
||||
durability: Durability | None = None,
|
||||
**kwargs: Any,
|
||||
) -> dict[str, Any] | Any:
|
||||
"""Asynchronously invoke the graph on a single input.
|
||||
@@ -3080,6 +3087,10 @@ class Pregel(
|
||||
output_keys: Optional. The output keys to include in the result. Default is None.
|
||||
interrupt_before: Optional. The nodes to interrupt before. Default is None.
|
||||
interrupt_after: Optional. The nodes to interrupt after. Default is None.
|
||||
durability: The durability mode for the graph execution, defaults to "async". Options are:
|
||||
- `"sync"`: Changes are persisted synchronously before the next step starts.
|
||||
- `"async"`: Changes are persisted asynchronously while the next step executes.
|
||||
- `"exit"`: Changes are persisted only when the graph exits.
|
||||
**kwargs: Additional keyword arguments.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Script to add durability parameter to ainvoke method signature and update docstring."""
|
||||
|
||||
import re
|
||||
|
||||
def modify_ainvoke_method():
|
||||
file_path = "/home/daytona/langgraph/libs/langgraph/langgraph/pregel/main.py"
|
||||
|
||||
# Read the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find the ainvoke method and add durability parameter
|
||||
# Pattern to match the ainvoke method signature
|
||||
ainvoke_pattern = r'( async def ainvoke\(\s*\n.*?interrupt_after: All \| Sequence\[str\] \| None = None,)\s*\n( \*\*kwargs: Any,)'
|
||||
|
||||
# Replacement with durability parameter added
|
||||
ainvoke_replacement = r'\1\n durability: Durability | None = None,\n\2'
|
||||
|
||||
# Apply the replacement
|
||||
content = re.sub(ainvoke_pattern, ainvoke_replacement, content, flags=re.DOTALL)
|
||||
|
||||
# Update the ainvoke method docstring to include durability parameter
|
||||
docstring_pattern = r'( interrupt_before: Optional\. The nodes to interrupt before\. Default is None\.\s*\n\s*interrupt_after: Optional\. The nodes to interrupt after\. Default is None\.\s*\n)( \*\*kwargs: Additional keyword arguments\.)'
|
||||
|
||||
# Replacement with durability parameter documentation added
|
||||
docstring_replacement = r'\1 durability: The durability mode for the graph execution, defaults to "async". Options are:\n - `"sync"`: Changes are persisted synchronously before the next step starts.\n - `"async"`: Changes are persisted asynchronously while the next step executes.\n - `"exit"`: Changes are persisted only when the graph exits.\n\2'
|
||||
|
||||
# Apply the replacement
|
||||
content = re.sub(docstring_pattern, docstring_replacement, content, flags=re.DOTALL)
|
||||
|
||||
# Write the modified content back
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print("Successfully added durability parameter to ainvoke method signature and updated docstring")
|
||||
|
||||
if __name__ == "__main__":
|
||||
modify_ainvoke_method()
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Script to update ainvoke method implementation to pass durability explicitly."""
|
||||
|
||||
import re
|
||||
|
||||
def modify_ainvoke_implementation():
|
||||
file_path = "/home/daytona/langgraph/libs/langgraph/langgraph/pregel/main.py"
|
||||
|
||||
# Read the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find the ainvoke method astream call and add explicit durability parameter
|
||||
# Pattern to match the astream call in ainvoke method
|
||||
astream_call_pattern = r'( async for chunk in self\.astream\(\s*\n.*?interrupt_after=interrupt_after,)\s*\n( \*\*kwargs,)'
|
||||
|
||||
# Replacement with durability parameter added
|
||||
astream_call_replacement = r'\1\n durability=durability,\n\2'
|
||||
|
||||
# Apply the replacement
|
||||
content = re.sub(astream_call_pattern, astream_call_replacement, content, flags=re.DOTALL)
|
||||
|
||||
# Write the modified content back
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print("Successfully updated ainvoke method implementation to pass durability explicitly")
|
||||
|
||||
if __name__ == "__main__":
|
||||
modify_ainvoke_implementation()
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Script to add durability parameter to invoke method signature and update docstring."""
|
||||
|
||||
import re
|
||||
|
||||
def modify_invoke_method():
|
||||
file_path = "/home/daytona/langgraph/libs/langgraph/langgraph/pregel/main.py"
|
||||
|
||||
# Read the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Update the invoke method docstring to include durability parameter
|
||||
docstring_pattern = r'( interrupt_before: Optional\. The nodes to interrupt the graph run before\.\s*\n\s*interrupt_after: Optional\. The nodes to interrupt the graph run after\.\s*\n)( \*\*kwargs: Additional keyword arguments to pass to the graph run\.)'
|
||||
|
||||
# Replacement with durability parameter documentation added
|
||||
docstring_replacement = r'\1 durability: The durability mode for the graph execution, defaults to "async". Options are:\n - `"sync"`: Changes are persisted synchronously before the next step starts.\n - `"async"`: Changes are persisted asynchronously while the next step executes.\n - `"exit"`: Changes are persisted only when the graph exits.\n\2'
|
||||
|
||||
# Apply the replacement
|
||||
content = re.sub(docstring_pattern, docstring_replacement, content, flags=re.DOTALL)
|
||||
|
||||
# Write the modified content back
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print("Successfully updated invoke method docstring with durability parameter documentation")
|
||||
|
||||
if __name__ == "__main__":
|
||||
modify_invoke_method()
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Script to update invoke method implementation to pass durability explicitly."""
|
||||
|
||||
import re
|
||||
|
||||
def modify_invoke_implementation():
|
||||
file_path = "/home/daytona/langgraph/libs/langgraph/langgraph/pregel/main.py"
|
||||
|
||||
# Read the file
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find the invoke method stream call and add explicit durability parameter
|
||||
# Pattern to match the stream call in invoke method
|
||||
stream_call_pattern = r'( for chunk in self\.stream\(\s*\n.*?interrupt_after=interrupt_after,)\s*\n( \*\*kwargs,)'
|
||||
|
||||
# Replacement with durability parameter added
|
||||
stream_call_replacement = r'\1\n durability=durability,\n\2'
|
||||
|
||||
# Apply the replacement
|
||||
content = re.sub(stream_call_pattern, stream_call_replacement, content, flags=re.DOTALL)
|
||||
|
||||
# Write the modified content back
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print("Successfully updated invoke method implementation to pass durability explicitly")
|
||||
|
||||
if __name__ == "__main__":
|
||||
modify_invoke_implementation()
|
||||
Reference in New Issue
Block a user