-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
core[minor]: Add graph functionality to Runnable base #4566
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
langchain-core/src/runnables/base.ts
Outdated
// TODO: what should the inputNode be? | ||
const inputNode = graph.addNode({ | ||
type: "unknown", | ||
config, | ||
}); |
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.
@jacoblee93 Here's where I'm a little bit lost,
I'm trying to find a way to put the schema of the input node of this runnable. I haven't been able to find it yet.
This should be similar to get_input_schema in Python's core lib.
I think for graphing purposes, we might be able to replace this with a placeholder and maybe implement this later when we're going to use Zod.
langchain-core/src/runnables/base.ts
Outdated
// TODO: what should the outputNode be? | ||
const outputNode = graph.addNode({ | ||
type: "unknown", | ||
config, | ||
}); |
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.
Same case as the above.
|
||
interface Node { | ||
id: string; | ||
data: any; |
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.
we prob want to type this
return node.id; | ||
} else { | ||
// Assuming `node.data` has a similar structure to the Python version | ||
let data = node.data.toString(); |
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 want to use node.data.getName()
here
Hey sorry about the delay - will spend some time with this tomorrow and hopefully ship it! |
…feat/core-graph
@@ -550,6 +551,22 @@ export abstract class Runnable< | |||
); | |||
} | |||
|
|||
getGraph(_?: RunnableConfig): Graph { |
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.
Wouldn't be any reason to preemptively make this async right?
I will land @albertpurnama, thank you for this! |
Thank you very much for your patience and the great work @albertpurnama! |
Description
Graph
class port over from Python'sGraph
implementation heregetGraph
to baseRunnable
to allow constructing graph representation of the Runnable. This should be exact port of this function in pythonFailing test case
This is because the implementation of base
Runnable
is still TBD. Specifically here (same for the last node)The solution to this requires the base
Runnable
to be fully implementedFixes #4582