@@ -7,12 +7,34 @@ import {
77 bindOutputSchema ,
88} from "./base.js" ;
99import { load } from "../load/index.js" ;
10- import { arraysEqual } from "../util/misc.js" ;
1110
1211// TODO: Make this the default, add web entrypoint in next breaking release
1312
1413export { basePush as push } ;
1514
15+ function _idEquals ( a : string [ ] , b : string [ ] ) : boolean {
16+ if ( ! Array . isArray ( a ) || ! Array . isArray ( b ) ) {
17+ return false ;
18+ }
19+ if ( a . length !== b . length ) {
20+ return false ;
21+ }
22+ for ( let i = 0 ; i < a . length ; i ++ ) {
23+ if ( a [ i ] !== b [ i ] ) {
24+ return false ;
25+ }
26+ }
27+ return true ;
28+ }
29+
30+ function isRunnableBinding ( a : string [ ] ) : boolean {
31+ const wellKnownIds = [
32+ [ "langchain_core" , "runnables" , "RunnableBinding" ] ,
33+ [ "langchain" , "schema" , "runnable" , "RunnableBinding" ] ,
34+ ] ;
35+ return wellKnownIds . some ( ( id ) => _idEquals ( a , id ) ) ;
36+ }
37+
1638/**
1739 * Pull a prompt from the hub.
1840 * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
@@ -34,9 +56,8 @@ export async function pull<T extends Runnable>(
3456 const promptObject = await basePull ( ownerRepoCommit , options ) ;
3557 let modelClass ;
3658 if ( options ?. includeModel ) {
37- const chatModelObject = arraysEqual (
38- promptObject . manifest . kwargs ?. last ?. id ,
39- [ "langchain_core" , "runnables" , "RunnableBinding" ]
59+ const chatModelObject = isRunnableBinding (
60+ promptObject . manifest . kwargs ?. last ?. id
4061 )
4162 ? promptObject . manifest . kwargs ?. last ?. kwargs ?. bound
4263 : promptObject . manifest . kwargs ?. last ;
0 commit comments