-
Notifications
You must be signed in to change notification settings - Fork 129
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
feat(langgraph): functional API #793
Conversation
948e033
to
bbe374c
Compare
9ae5ec9
to
b666c47
Compare
libs/langgraph/src/func.ts
Outdated
/** | ||
* Wraps a function in a task that can be retried | ||
* | ||
* !!! warning "Experimental" |
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.
Do we actually want this warning in? Seems harsh
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.
Yea this is not the copy I'd want, I think better to say something like
!!! warning "Beta"
This is a new API which might evolve over the next few weeks.
We plan to mark it as stable by X day [next 3 weeks]
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 lifted it directly from the python lib. The @experimental
and @beta
tsdoc tags should ideally convey the same meaning, although per the spec they may be removed by tooling on non-beta releases. I haven't checked the docs build yet to see what actually happens, and whether we can configure this, so I left it in for now as a sort of reminder to myself.
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.
d9328c1
to
e110fb1
Compare
e8ef2f4
to
41e730b
Compare
export const RESERVED = [ | ||
TAG_HIDDEN, | ||
INPUT, | ||
INTERRUPT, | ||
RESUME, | ||
ERROR, | ||
NO_WRITES, | ||
TASKS, | ||
|
||
// reserved config.configurable keys | ||
CONFIG_KEY_SEND, | ||
CONFIG_KEY_READ, | ||
CONFIG_KEY_CHECKPOINTER, | ||
CONFIG_KEY_STREAM, | ||
CONFIG_KEY_RESUMING, | ||
CONFIG_KEY_TASK_ID, | ||
CONFIG_KEY_STREAM, | ||
CONFIG_KEY_CALL, | ||
CONFIG_KEY_RESUME_VALUE, | ||
CONFIG_KEY_SCRATCHPAD, | ||
CONFIG_KEY_PREVIOUS_STATE, | ||
CONFIG_KEY_CHECKPOINT_MAP, | ||
INPUT, | ||
CONFIG_KEY_CHECKPOINT_NS, | ||
CONFIG_KEY_CHECKPOINT_ID, | ||
]; |
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.
aligned order w/ python code so it's easier to check
de58f5e
to
e1a0ec5
Compare
export function skipIf(condition: () => boolean): typeof it | typeof it.skip { | ||
if (condition()) { | ||
return it.skip; | ||
} else { | ||
return it; | ||
} | ||
} | ||
|
||
export async function dumpDebugStream< | ||
Nn extends StrRecord<string, PregelNode>, | ||
Cc extends StrRecord<string, BaseChannel | ManagedValueSpec>, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
ConfigurableFieldType extends Record<string, any> = StrRecord<string, any>, | ||
InputType = PregelInputType, | ||
OutputType = PregelOutputType | ||
>( |
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.
these are actually unused now, but I left them in, in case they're handy.
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.
Overall looks good to me, will leave for @nfcampos for final review
368c671
to
9868059
Compare
9868059
to
f1b1651
Compare
feat(langgraph): Add Functional API
This PR introduces a new functional API to langgraphjs that provides a simpler, more intuitive way to create and compose tasks in a graph. The changes focus on improving developer experience while maintaining the power and flexibility of the existing graph-based system.
Key Changes
1. New Functional API Components
task
andentrypoint
functions for creating graph nodes2. Configuration and Constants Updates
CONFIG_KEY_CALL
)NO_WRITES
,RETURN
)3. Pregel Engine Improvements
4. Type System Enhancements
Implementation Details
The implementation focuses on maintaining backward compatibility while introducing the new functional API. Key architectural decisions include:
Example Usage
Breaking Changes
None. This is a purely additive change that maintains compatibility with existing code.
Testing
Added new test files and cases to cover the functional API functionality:
func.test.ts
for testing the new API