https://github.com/nickchecan/graph-async
AI Application Development - Concept Study - Asynchronous node execution
https://github.com/nickchecan/graph-async
async asynchronous langchain langgraph poetry python
Last synced: 2 months ago
JSON representation
AI Application Development - Concept Study - Asynchronous node execution
- Host: GitHub
- URL: https://github.com/nickchecan/graph-async
- Owner: NickChecan
- Created: 2025-02-14T21:26:12.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-14T23:04:11.000Z (11 months ago)
- Last Synced: 2025-02-14T23:23:56.355Z (11 months ago)
- Topics: async, asynchronous, langchain, langgraph, poetry, python
- Language: Python
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graph-async
This project covers the asynchronous execution of nodes in a graph.
```mermaid
%%{init: {'flowchart': {'curve': 'linear'}}}%%
graph TD;
__start__([
__start__
]):::first
a(a)
b(b)
c(c)
d(d)
__end__([__end__
]):::last
__start__ --> a;
a --> b;
a --> c;
b --> d;
c --> d;
d --> __end__;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
```
Controlling different execution paths in a graph.
```mermaid
%%{init: {'flowchart': {'curve': 'linear'}}}%%
graph TD;
__start__([
__start__
]):::first
a(a)
b(b)
b2(b2)
c(c)
d(d)
__end__([__end__
]):::last
__start__ --> a;
a --> b;
a --> c;
b --> b2;
b2 --> d;
c --> d;
d --> __end__;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
```
Conditional Branching with async execution:
```mermaid
%%{init: {'flowchart': {'curve': 'linear'}}}%%
graph TD;
__start__([
__start__
]):::first
a(a)
b(b)
c(c)
d(d)
e(e)
__end__([__end__
]):::last
__start__ --> a;
b --> e;
c --> e;
d --> e;
e --> __end__;
a -.-> b;
a -.-> c;
a -.-> d;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
```
### Utilities
Poetry command to install project dependencies:
```sh
poetry add python-dotenv langgraph grandalf
```
Environment variables:
```
LANGCHAIN_API_KEY=
LANGCHAIN_TRACING=true
LANGCHAIN_PROJECT=AsyncProject
```
### Drawbacks
- State Conflicts: The nodes in the graph may share and change the same state, which can lead to conflicts.
- Debugging asynchronous code can be difficult.
The best practice is to isolate state updates. Each node should write to a different attribute of the state object to conserve data integrity and prevents overwriting values.
### References
[How to create branches for parallel node execution](https://langchain-ai.github.io/langgraph/how-tos/branching/)