-
Notifications
You must be signed in to change notification settings - Fork 343
feat(langgraph): allow explicit type declaration for interrupt and custom stream events #1612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…stom stream events
🦋 Changeset detectedLatest commit: 0053c17 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| store?: BaseStore; | ||
|
|
||
| writer?: (chunk: unknown) => void; | ||
| writer?: IsEqual<WriterType, unknown> extends true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there cases where writer is not defined? Wonder if we can remove the optionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writer is currently defined only when custom stream mode is requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's not possible to type. In this case, I would advocate to remove the optionality afterall and throw a meaningful error at runtime, because the optionality doesn't really provide any value IMHO.
| ? (chunk: unknown) => void | ||
| : WriterType; | ||
|
|
||
| interrupt?: IsEqual<InterruptType, unknown> extends true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to infer the existence of interrupt based on whether a checkpointer parameter was provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I'd like to support creating the builder separately, that would entail making checkpointer a constructor parameter.
An alternative I think can be always providing the function in runtime but throwing an error in runtime if no checkpointer is passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we throw an error already that is meaningful enough.
| } | ||
|
|
||
| export interface Runtime<ContextType = Record<string, unknown>> { | ||
| export interface Runtime< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is Runtime different from LangGraphRunnableConfig? Both seem to have very similar types. Maybe we can do:
export interface Runtime<
ContextType = Record<string, unknown>,
InterruptType = unknown,
WriterType = unknown
> extends LangGraphRunnableConfig<ContextType, InterruptType, WriterType> {
signal?: AbortSignal;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runtime is a pruned version of LangGraphRunnableConfig, so ideally it should be in reverse.
Sample:
This PR also removes undocumented
typedNodehelper, which has been superseded by this PR