Skip to content

Adds Documentation about Channels, Checkpoints, and Pregel Graphs to CONTRIBUTING.md#96

Merged
Nuno Campos (nfcampos) merged 4 commits intolangchain-ai:mainfrom
janvi-codaio:janvi-langraph-documentation
Mar 23, 2024
Merged

Adds Documentation about Channels, Checkpoints, and Pregel Graphs to CONTRIBUTING.md#96
Nuno Campos (nfcampos) merged 4 commits intolangchain-ai:mainfrom
janvi-codaio:janvi-langraph-documentation

Conversation

@janvi-codaio
Copy link
Copy Markdown
Contributor

@janvi-codaio Janvi Kalra (janvi-codaio) commented Mar 22, 2024

Based on conversations with Nuno Campos (@nfcampos) yesterday, learned a lot about the underlying behavior of LangGraph

This information is pretty crucial to be able to contribute meaningfully in this code base, so added this information to the CONTRIBUTING.md

While I was here, made some flyby changes to help clarify things that I thought were confusing

Comment on lines -66 to +74
- __Required__: `--workspace <workspace name>`. eg: `--workspace @langchain/langgraph` (always appended as the first flag when running `yarn release`)
- __Optional__: `--bump-deps` eg `--bump-deps` Will find all packages in the repo which depend on this workspace and checkout a new branch, update the dep version, run yarn install, commit & push to new branch.
- __Optional__: `--tag <tag>` eg `--tag beta` Add a tag to the NPM release.
- **Required**: `--workspace <workspace name>`. eg: `--workspace @langchain/langgraph` (always appended as the first flag when running `yarn release`)
- **Optional**: `--bump-deps` eg `--bump-deps` Will find all packages in the repo which depend on this workspace and checkout a new branch, update the dep version, run yarn install, commit & push to new branch.
- **Optional**: `--tag <tag>` eg `--tag beta` Add a tag to the NPM release.

This script automatically bumps the package version, creates a new release branch with the changes, pushes the branch to GitHub, uses `release-it` to automatically release to NPM, and more depending on the flags passed.

Halfway through this script, you'll be prompted to enter an NPM OTP (typically from an authenticator app). This value is not stored anywhere and is only used to authenticate the NPM release.

Full example: `yarn release @langchain/langgraph --bump-deps --tag beta`.
Full example: `yarn release @langchain/langgraph --bump-deps --tag beta`.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not change this explicitly, happened when i ran yarn format

4. Since `outputChannelName` is defined as the graph's output, the execution ends and returns `3`.

```ts
const addOne = jest.fn((x: number): number => x + 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove indent

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or wrap in test/it

Some key concepts:
- Pregel graphs take an `input` and `output` as parameters which represent where the graph starts and ends
- Pregel graphs take a mapping of nodes represented as `{nodeName: node}`
- Each node subscribes to (one or more) channels. This defines when a node executes. Specifically, for a given `node N` that subscribes to `channel M`, whenever the _value_ of `channel M` changes, `node N` must be executed. Intuitively, it represents what the current node is _dependent_ on.
Copy link
Copy Markdown
Collaborator

@jacoblee93 Jacob Lee (jacoblee93) Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between a channel and an edge? That is the terminology most people think of when they hear "graph".

Would be worth clarifying here

Invocation 1:
1. When the graph is invoked with `2`, `input` channels value becomes `2`
2. Node `one` runs because it is subscribed to `input`. The node tranforms `2` to `2` by running `inputPlusTotal`.
3. The value of channels `output` and `total` get set to `2` because node `one` writes to both channels
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no total referenced above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the description is above the example
i can change that if that's confusing

1. When the graph is invoked with `2`, `input` channels value becomes `2`
2. Node `one` runs because it is subscribed to `input`. The node tranforms `2` to `2` by running `inputPlusTotal`.
3. The value of channels `output` and `total` get set to `2` because node `one` writes to both channels
4. Because `memory` is passed into the graph, `total` at threadId of `1` is saved as a value of `2`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also no memory passed above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above^

@nfcampos Nuno Campos (nfcampos) merged commit ee7c331 into langchain-ai:main Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants