-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(@langchain/core): migrate subset of agent primitives to @langchain/core
#9179
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
base: v1
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
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.
for posterity: I think it's worth exploring how we can make the middleware types in core more generic. We're indirectly introducing langgraph primitives (e.g. we are name dropping Command
in core middleware, but filling that type information in only if we import createMiddleware
from langchain. It wires us in sort of an awkward way, but this is better than working against circular dependency errors.
Probably best to mark all of these in core as @internal
so they're hidden in references, and then have a type alias which is where the jsdocs live.
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 this is just invalidating the point of dep tests. Fine to either disable for this pass, but I think the fix for the latest tests is to allow for pre-release versions if thats what's in dependencies (since we're just pnpm add @langchain/core
'ing within the script)
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.
yes, ideally we need to be able to push dev releases from branches and then adjust the peer dep in langchain
.
Runtime< | ||
TContextSchema extends InteropZodObject | ||
? InferInteropZodOutput<TContextSchema> | ||
: TContextSchema extends InteropZodDefault<any> | ||
? InferInteropZodOutput<TContextSchema> | ||
: TContextSchema extends InteropZodOptional<any> | ||
? Partial<InferInteropZodOutput<TContextSchema>> | ||
: never | ||
> |
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 dedupe the TContextSchema extends InteropZodObject...
closures into a utility type?
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.
Will do in a separate PR.
/** | ||
* Cast the promptCachingMiddleware to `any` to avoid the following error: | ||
* > Type instantiation is excessively deep and possibly infinite. | ||
* | ||
* This is because the actual `promptCachingMiddleware` is implemented within | ||
* the `@langchain/anthropic` package and tesed in here. To avoid circular dependencies, | ||
* we have to run the unit and integration tests here as we need `createAgent`. | ||
*/ | ||
const anthropicPromptCachingMiddleware = promptCachingMiddleware as 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.
this is surprising to me actually. Can get that rolldown is detecting circular dependencies, but typescript is throwing errors like this also? My intuition would be that there's no circular type trees since anthropic is only a dev dependency
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.
For TypeScript it seems to not matter if it is a dev, optional or peer dependency.
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.
should these prompt caching tests just be living inside of @langchain/anthropic
?
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.
Ideally yes, but they use createAgent
which lives in langchain
so we are having the same problem. This brings me back of saying: let's collapse all into one langchain package.
Co-authored-by: Hunter Lovell <[email protected]>
1f97249
to
120800d
Compare
Moving back to draft due to:
|
This allows to create middleware without depending on
langchain
or@langchain/langgraph
.