langchain 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +0 -4
  3. package/dist/_virtual/rolldown_runtime.js +1 -10
  4. package/dist/agents/ReactAgent.cjs +21 -41
  5. package/dist/agents/ReactAgent.cjs.map +1 -1
  6. package/dist/agents/ReactAgent.js +21 -41
  7. package/dist/agents/ReactAgent.js.map +1 -1
  8. package/dist/agents/annotation.cjs +1 -0
  9. package/dist/agents/annotation.cjs.map +1 -1
  10. package/dist/agents/annotation.js +1 -0
  11. package/dist/agents/annotation.js.map +1 -1
  12. package/dist/agents/index.cjs.map +1 -1
  13. package/dist/agents/index.d.cts +11 -11
  14. package/dist/agents/index.d.cts.map +1 -1
  15. package/dist/agents/index.d.ts +11 -11
  16. package/dist/agents/index.d.ts.map +1 -1
  17. package/dist/agents/index.js.map +1 -1
  18. package/dist/agents/middleware/callLimit.d.cts.map +1 -1
  19. package/dist/agents/middleware/callLimit.d.ts.map +1 -1
  20. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  21. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  22. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  23. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  24. package/dist/agents/middleware/hitl.cjs +7 -2
  25. package/dist/agents/middleware/hitl.cjs.map +1 -1
  26. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  27. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  28. package/dist/agents/middleware/hitl.js +7 -2
  29. package/dist/agents/middleware/hitl.js.map +1 -1
  30. package/dist/agents/middleware/index.cjs +2 -1
  31. package/dist/agents/middleware/index.d.cts +15 -0
  32. package/dist/agents/middleware/index.d.ts +14 -0
  33. package/dist/agents/middleware/index.js +2 -1
  34. package/dist/agents/middleware/modelCallLimit.cjs +145 -0
  35. package/dist/agents/middleware/modelCallLimit.cjs.map +1 -0
  36. package/dist/agents/middleware/modelCallLimit.d.cts +128 -0
  37. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -0
  38. package/dist/agents/middleware/modelCallLimit.d.ts +128 -0
  39. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -0
  40. package/dist/agents/middleware/modelCallLimit.js +144 -0
  41. package/dist/agents/middleware/modelCallLimit.js.map +1 -0
  42. package/dist/agents/middleware/promptCaching.d.cts.map +1 -1
  43. package/dist/agents/middleware/summarization.cjs +4 -2
  44. package/dist/agents/middleware/summarization.cjs.map +1 -1
  45. package/dist/agents/middleware/summarization.d.cts +7 -6
  46. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  47. package/dist/agents/middleware/summarization.d.ts +7 -6
  48. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  49. package/dist/agents/middleware/summarization.js +4 -2
  50. package/dist/agents/middleware/summarization.js.map +1 -1
  51. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
  52. package/dist/agents/middleware/toolCallLimit.cjs +205 -92
  53. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
  54. package/dist/agents/middleware/toolCallLimit.d.cts +46 -37
  55. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  56. package/dist/agents/middleware/toolCallLimit.d.ts +46 -37
  57. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  58. package/dist/agents/middleware/toolCallLimit.js +206 -93
  59. package/dist/agents/middleware/toolCallLimit.js.map +1 -1
  60. package/dist/agents/middleware/toolRetry.cjs +224 -0
  61. package/dist/agents/middleware/toolRetry.cjs.map +1 -0
  62. package/dist/agents/middleware/toolRetry.d.cts +179 -0
  63. package/dist/agents/middleware/toolRetry.d.cts.map +1 -0
  64. package/dist/agents/middleware/toolRetry.d.ts +179 -0
  65. package/dist/agents/middleware/toolRetry.d.ts.map +1 -0
  66. package/dist/agents/middleware/toolRetry.js +223 -0
  67. package/dist/agents/middleware/toolRetry.js.map +1 -0
  68. package/dist/agents/middleware/types.d.cts +21 -19
  69. package/dist/agents/middleware/types.d.cts.map +1 -1
  70. package/dist/agents/middleware/types.d.ts +21 -19
  71. package/dist/agents/middleware/types.d.ts.map +1 -1
  72. package/dist/agents/middleware/utils.cjs +7 -0
  73. package/dist/agents/middleware/utils.cjs.map +1 -1
  74. package/dist/agents/middleware/utils.d.cts.map +1 -1
  75. package/dist/agents/middleware/utils.d.ts.map +1 -1
  76. package/dist/agents/middleware/utils.js +7 -1
  77. package/dist/agents/middleware/utils.js.map +1 -1
  78. package/dist/agents/middleware.cjs.map +1 -1
  79. package/dist/agents/middleware.d.cts +4 -4
  80. package/dist/agents/middleware.d.cts.map +1 -1
  81. package/dist/agents/middleware.d.ts +4 -4
  82. package/dist/agents/middleware.d.ts.map +1 -1
  83. package/dist/agents/middleware.js.map +1 -1
  84. package/dist/agents/nodes/AgentNode.cjs +21 -47
  85. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  86. package/dist/agents/nodes/AgentNode.js +22 -48
  87. package/dist/agents/nodes/AgentNode.js.map +1 -1
  88. package/dist/agents/nodes/ToolNode.cjs +12 -18
  89. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  90. package/dist/agents/nodes/ToolNode.js +12 -18
  91. package/dist/agents/nodes/ToolNode.js.map +1 -1
  92. package/dist/agents/nodes/middleware.cjs +9 -7
  93. package/dist/agents/nodes/middleware.cjs.map +1 -1
  94. package/dist/agents/nodes/middleware.js +10 -8
  95. package/dist/agents/nodes/middleware.js.map +1 -1
  96. package/dist/agents/nodes/types.d.cts +1 -1
  97. package/dist/agents/nodes/types.d.cts.map +1 -1
  98. package/dist/agents/nodes/types.d.ts +1 -1
  99. package/dist/agents/nodes/types.d.ts.map +1 -1
  100. package/dist/agents/nodes/utils.cjs +5 -1
  101. package/dist/agents/nodes/utils.cjs.map +1 -1
  102. package/dist/agents/nodes/utils.js +5 -1
  103. package/dist/agents/nodes/utils.js.map +1 -1
  104. package/dist/agents/runtime.d.cts +11 -27
  105. package/dist/agents/runtime.d.cts.map +1 -1
  106. package/dist/agents/runtime.d.ts +11 -27
  107. package/dist/agents/runtime.d.ts.map +1 -1
  108. package/dist/agents/state.cjs +45 -0
  109. package/dist/agents/state.cjs.map +1 -0
  110. package/dist/agents/state.js +44 -0
  111. package/dist/agents/state.js.map +1 -0
  112. package/dist/agents/types.d.cts +1 -1
  113. package/dist/agents/types.d.cts.map +1 -1
  114. package/dist/agents/types.d.ts +1 -1
  115. package/dist/agents/types.d.ts.map +1 -1
  116. package/dist/agents/utils.cjs +10 -2
  117. package/dist/agents/utils.cjs.map +1 -1
  118. package/dist/agents/utils.js +10 -2
  119. package/dist/agents/utils.js.map +1 -1
  120. package/dist/chat_models/universal.cjs +4 -3
  121. package/dist/chat_models/universal.cjs.map +1 -1
  122. package/dist/chat_models/universal.js +4 -3
  123. package/dist/chat_models/universal.js.map +1 -1
  124. package/dist/embeddings/cache_backed.cjs +140 -0
  125. package/dist/embeddings/cache_backed.cjs.map +1 -0
  126. package/dist/embeddings/cache_backed.d.cts +107 -0
  127. package/dist/embeddings/cache_backed.d.cts.map +1 -0
  128. package/dist/embeddings/cache_backed.d.ts +107 -0
  129. package/dist/embeddings/cache_backed.d.ts.map +1 -0
  130. package/dist/embeddings/cache_backed.js +134 -0
  131. package/dist/embeddings/cache_backed.js.map +1 -0
  132. package/dist/embeddings/fake.cjs +22 -0
  133. package/dist/embeddings/fake.cjs.map +1 -0
  134. package/dist/embeddings/fake.d.cts +1 -0
  135. package/dist/embeddings/fake.d.ts +1 -0
  136. package/dist/embeddings/fake.js +12 -0
  137. package/dist/embeddings/fake.js.map +1 -0
  138. package/dist/hub/base.cjs +4 -17
  139. package/dist/hub/base.cjs.map +1 -1
  140. package/dist/hub/base.js +2 -15
  141. package/dist/hub/base.js.map +1 -1
  142. package/dist/index.cjs +6 -18
  143. package/dist/index.cjs.map +1 -1
  144. package/dist/index.d.cts +3 -3
  145. package/dist/index.d.ts +3 -3
  146. package/dist/index.js +4 -5
  147. package/dist/index.js.map +1 -1
  148. package/package.json +6 -9
@@ -0,0 +1,107 @@
1
+ import { Embeddings, EmbeddingsInterface } from "@langchain/core/embeddings";
2
+ import { BaseStore } from "@langchain/core/stores";
3
+ import { AsyncCallerParams } from "@langchain/core/utils/async_caller";
4
+
5
+ //#region src/embeddings/cache_backed.d.ts
6
+
7
+ /**
8
+ * Interface for the fields required to initialize an instance of the
9
+ * CacheBackedEmbeddings class.
10
+ */
11
+ interface CacheBackedEmbeddingsFields extends AsyncCallerParams {
12
+ underlyingEmbeddings: EmbeddingsInterface;
13
+ documentEmbeddingStore: BaseStore<string, number[]>;
14
+ }
15
+ /**
16
+ * Interface for caching results from embedding models.
17
+ *
18
+ * The interface allows works with any store that implements
19
+ * the abstract store interface accepting keys of type str and values of list of
20
+ * floats.
21
+ *
22
+ * If need be, the interface can be extended to accept other implementations
23
+ * of the value serializer and deserializer, as well as the key encoder.
24
+ * @example
25
+ * ```typescript
26
+ * const underlyingEmbeddings = new OpenAIEmbeddings();
27
+ *
28
+ * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(
29
+ * underlyingEmbeddings,
30
+ * new ConvexKVStore({ ctx }),
31
+ * {
32
+ * namespace: underlyingEmbeddings.modelName,
33
+ * },
34
+ * );
35
+ *
36
+ * const loader = new TextLoader("./state_of_the_union.txt");
37
+ * const rawDocuments = await loader.load();
38
+ * const splitter = new RecursiveCharacterTextSplitter({
39
+ * chunkSize: 1000,
40
+ * chunkOverlap: 0,
41
+ * });
42
+ * const documents = await splitter.splitDocuments(rawDocuments);
43
+ *
44
+ * let time = Date.now();
45
+ * const vectorstore = await ConvexVectorStore.fromDocuments(
46
+ * documents,
47
+ * cacheBackedEmbeddings,
48
+ * { ctx },
49
+ * );
50
+ * console.log(`Initial creation time: ${Date.now() - time}ms`);
51
+ *
52
+ * time = Date.now();
53
+ * const vectorstore2 = await ConvexVectorStore.fromDocuments(
54
+ * documents,
55
+ * cacheBackedEmbeddings,
56
+ * { ctx },
57
+ * );
58
+ * console.log(`Cached creation time: ${Date.now() - time}ms`);
59
+ *
60
+ * ```
61
+ */
62
+ declare class CacheBackedEmbeddings extends Embeddings {
63
+ protected underlyingEmbeddings: EmbeddingsInterface;
64
+ protected documentEmbeddingStore: BaseStore<string, number[]>;
65
+ constructor(fields: CacheBackedEmbeddingsFields);
66
+ /**
67
+ * Embed query text.
68
+ *
69
+ * This method does not support caching at the moment.
70
+ *
71
+ * Support for caching queries is easy to implement, but might make
72
+ * sense to hold off to see the most common patterns.
73
+ *
74
+ * If the cache has an eviction policy, we may need to be a bit more careful
75
+ * about sharing the cache between documents and queries. Generally,
76
+ * one is OK evicting query caches, but document caches should be kept.
77
+ *
78
+ * @param document The text to embed.
79
+ * @returns The embedding for the given text.
80
+ */
81
+ embedQuery(document: string): Promise<number[]>;
82
+ /**
83
+ * Embed a list of texts.
84
+ *
85
+ * The method first checks the cache for the embeddings.
86
+ * If the embeddings are not found, the method uses the underlying embedder
87
+ * to embed the documents and stores the results in the cache.
88
+ *
89
+ * @param documents
90
+ * @returns A list of embeddings for the given texts.
91
+ */
92
+ embedDocuments(documents: string[]): Promise<number[][]>;
93
+ /**
94
+ * Create a new CacheBackedEmbeddings instance from another embeddings instance
95
+ * and a storage instance.
96
+ * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.
97
+ * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.
98
+ * @param options.namespace Optional namespace for store keys.
99
+ * @returns A new CacheBackedEmbeddings instance.
100
+ */
101
+ static fromBytesStore(underlyingEmbeddings: EmbeddingsInterface, documentEmbeddingStore: BaseStore<string, Uint8Array>, options?: {
102
+ namespace?: string;
103
+ }): CacheBackedEmbeddings;
104
+ }
105
+ //#endregion
106
+ export { CacheBackedEmbeddings, CacheBackedEmbeddingsFields };
107
+ //# sourceMappingURL=cache_backed.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache_backed.d.cts","names":["EmbeddingsInterface","Embeddings","BaseStore","AsyncCallerParams","CacheBackedEmbeddingsFields","CacheBackedEmbeddings","Promise","Uint8Array"],"sources":["../../src/embeddings/cache_backed.d.ts"],"sourcesContent":["import { type EmbeddingsInterface, Embeddings } from \"@langchain/core/embeddings\";\nimport { BaseStore } from \"@langchain/core/stores\";\nimport { AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\n/**\n * Interface for the fields required to initialize an instance of the\n * CacheBackedEmbeddings class.\n */\nexport interface CacheBackedEmbeddingsFields extends AsyncCallerParams {\n underlyingEmbeddings: EmbeddingsInterface;\n documentEmbeddingStore: BaseStore<string, number[]>;\n}\n/**\n * Interface for caching results from embedding models.\n *\n * The interface allows works with any store that implements\n * the abstract store interface accepting keys of type str and values of list of\n * floats.\n *\n * If need be, the interface can be extended to accept other implementations\n * of the value serializer and deserializer, as well as the key encoder.\n * @example\n * ```typescript\n * const underlyingEmbeddings = new OpenAIEmbeddings();\n *\n * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(\n * underlyingEmbeddings,\n * new ConvexKVStore({ ctx }),\n * {\n * namespace: underlyingEmbeddings.modelName,\n * },\n * );\n *\n * const loader = new TextLoader(\"./state_of_the_union.txt\");\n * const rawDocuments = await loader.load();\n * const splitter = new RecursiveCharacterTextSplitter({\n * chunkSize: 1000,\n * chunkOverlap: 0,\n * });\n * const documents = await splitter.splitDocuments(rawDocuments);\n *\n * let time = Date.now();\n * const vectorstore = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Initial creation time: ${Date.now() - time}ms`);\n *\n * time = Date.now();\n * const vectorstore2 = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Cached creation time: ${Date.now() - time}ms`);\n *\n * ```\n */\nexport declare class CacheBackedEmbeddings extends Embeddings {\n protected underlyingEmbeddings: EmbeddingsInterface;\n protected documentEmbeddingStore: BaseStore<string, number[]>;\n constructor(fields: CacheBackedEmbeddingsFields);\n /**\n * Embed query text.\n *\n * This method does not support caching at the moment.\n *\n * Support for caching queries is easy to implement, but might make\n * sense to hold off to see the most common patterns.\n *\n * If the cache has an eviction policy, we may need to be a bit more careful\n * about sharing the cache between documents and queries. Generally,\n * one is OK evicting query caches, but document caches should be kept.\n *\n * @param document The text to embed.\n * @returns The embedding for the given text.\n */\n embedQuery(document: string): Promise<number[]>;\n /**\n * Embed a list of texts.\n *\n * The method first checks the cache for the embeddings.\n * If the embeddings are not found, the method uses the underlying embedder\n * to embed the documents and stores the results in the cache.\n *\n * @param documents\n * @returns A list of embeddings for the given texts.\n */\n embedDocuments(documents: string[]): Promise<number[][]>;\n /**\n * Create a new CacheBackedEmbeddings instance from another embeddings instance\n * and a storage instance.\n * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.\n * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.\n * @param options.namespace Optional namespace for store keys.\n * @returns A new CacheBackedEmbeddings instance.\n */\n static fromBytesStore(underlyingEmbeddings: EmbeddingsInterface, documentEmbeddingStore: BaseStore<string, Uint8Array>, options?: {\n namespace?: string;\n }): CacheBackedEmbeddings;\n}\n"],"mappings":";;;;;;;;AAOA;;AAC0BA,UADTI,2BAAAA,SAAoCD,iBAC3BH,CAAAA;EAAmB,oBACjBE,EADFF,mBACEE;EAAS,sBAFgBC,EAEzBD,SAFyBC,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,CAAAA;AAAiB;AAmDtE;;;;;;;;;;;;AAA6D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAxCE,qBAAAA,SAA8BJ,UAAAA;kCACfD;oCACEE;sBACdE;;;;;;;;;;;;;;;;gCAgBUE;;;;;;;;;;;uCAWOA;;;;;;;;;8CASON,6CAA6CE,kBAAkBK;;MAEvGF"}
@@ -0,0 +1,107 @@
1
+ import { BaseStore } from "@langchain/core/stores";
2
+ import { Embeddings, EmbeddingsInterface } from "@langchain/core/embeddings";
3
+ import { AsyncCallerParams } from "@langchain/core/utils/async_caller";
4
+
5
+ //#region src/embeddings/cache_backed.d.ts
6
+
7
+ /**
8
+ * Interface for the fields required to initialize an instance of the
9
+ * CacheBackedEmbeddings class.
10
+ */
11
+ interface CacheBackedEmbeddingsFields extends AsyncCallerParams {
12
+ underlyingEmbeddings: EmbeddingsInterface;
13
+ documentEmbeddingStore: BaseStore<string, number[]>;
14
+ }
15
+ /**
16
+ * Interface for caching results from embedding models.
17
+ *
18
+ * The interface allows works with any store that implements
19
+ * the abstract store interface accepting keys of type str and values of list of
20
+ * floats.
21
+ *
22
+ * If need be, the interface can be extended to accept other implementations
23
+ * of the value serializer and deserializer, as well as the key encoder.
24
+ * @example
25
+ * ```typescript
26
+ * const underlyingEmbeddings = new OpenAIEmbeddings();
27
+ *
28
+ * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(
29
+ * underlyingEmbeddings,
30
+ * new ConvexKVStore({ ctx }),
31
+ * {
32
+ * namespace: underlyingEmbeddings.modelName,
33
+ * },
34
+ * );
35
+ *
36
+ * const loader = new TextLoader("./state_of_the_union.txt");
37
+ * const rawDocuments = await loader.load();
38
+ * const splitter = new RecursiveCharacterTextSplitter({
39
+ * chunkSize: 1000,
40
+ * chunkOverlap: 0,
41
+ * });
42
+ * const documents = await splitter.splitDocuments(rawDocuments);
43
+ *
44
+ * let time = Date.now();
45
+ * const vectorstore = await ConvexVectorStore.fromDocuments(
46
+ * documents,
47
+ * cacheBackedEmbeddings,
48
+ * { ctx },
49
+ * );
50
+ * console.log(`Initial creation time: ${Date.now() - time}ms`);
51
+ *
52
+ * time = Date.now();
53
+ * const vectorstore2 = await ConvexVectorStore.fromDocuments(
54
+ * documents,
55
+ * cacheBackedEmbeddings,
56
+ * { ctx },
57
+ * );
58
+ * console.log(`Cached creation time: ${Date.now() - time}ms`);
59
+ *
60
+ * ```
61
+ */
62
+ declare class CacheBackedEmbeddings extends Embeddings {
63
+ protected underlyingEmbeddings: EmbeddingsInterface;
64
+ protected documentEmbeddingStore: BaseStore<string, number[]>;
65
+ constructor(fields: CacheBackedEmbeddingsFields);
66
+ /**
67
+ * Embed query text.
68
+ *
69
+ * This method does not support caching at the moment.
70
+ *
71
+ * Support for caching queries is easy to implement, but might make
72
+ * sense to hold off to see the most common patterns.
73
+ *
74
+ * If the cache has an eviction policy, we may need to be a bit more careful
75
+ * about sharing the cache between documents and queries. Generally,
76
+ * one is OK evicting query caches, but document caches should be kept.
77
+ *
78
+ * @param document The text to embed.
79
+ * @returns The embedding for the given text.
80
+ */
81
+ embedQuery(document: string): Promise<number[]>;
82
+ /**
83
+ * Embed a list of texts.
84
+ *
85
+ * The method first checks the cache for the embeddings.
86
+ * If the embeddings are not found, the method uses the underlying embedder
87
+ * to embed the documents and stores the results in the cache.
88
+ *
89
+ * @param documents
90
+ * @returns A list of embeddings for the given texts.
91
+ */
92
+ embedDocuments(documents: string[]): Promise<number[][]>;
93
+ /**
94
+ * Create a new CacheBackedEmbeddings instance from another embeddings instance
95
+ * and a storage instance.
96
+ * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.
97
+ * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.
98
+ * @param options.namespace Optional namespace for store keys.
99
+ * @returns A new CacheBackedEmbeddings instance.
100
+ */
101
+ static fromBytesStore(underlyingEmbeddings: EmbeddingsInterface, documentEmbeddingStore: BaseStore<string, Uint8Array>, options?: {
102
+ namespace?: string;
103
+ }): CacheBackedEmbeddings;
104
+ }
105
+ //#endregion
106
+ export { CacheBackedEmbeddings, CacheBackedEmbeddingsFields };
107
+ //# sourceMappingURL=cache_backed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache_backed.d.ts","names":["EmbeddingsInterface","Embeddings","BaseStore","AsyncCallerParams","CacheBackedEmbeddingsFields","CacheBackedEmbeddings","Promise","Uint8Array"],"sources":["../../src/embeddings/cache_backed.d.ts"],"sourcesContent":["import { type EmbeddingsInterface, Embeddings } from \"@langchain/core/embeddings\";\nimport { BaseStore } from \"@langchain/core/stores\";\nimport { AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\n/**\n * Interface for the fields required to initialize an instance of the\n * CacheBackedEmbeddings class.\n */\nexport interface CacheBackedEmbeddingsFields extends AsyncCallerParams {\n underlyingEmbeddings: EmbeddingsInterface;\n documentEmbeddingStore: BaseStore<string, number[]>;\n}\n/**\n * Interface for caching results from embedding models.\n *\n * The interface allows works with any store that implements\n * the abstract store interface accepting keys of type str and values of list of\n * floats.\n *\n * If need be, the interface can be extended to accept other implementations\n * of the value serializer and deserializer, as well as the key encoder.\n * @example\n * ```typescript\n * const underlyingEmbeddings = new OpenAIEmbeddings();\n *\n * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(\n * underlyingEmbeddings,\n * new ConvexKVStore({ ctx }),\n * {\n * namespace: underlyingEmbeddings.modelName,\n * },\n * );\n *\n * const loader = new TextLoader(\"./state_of_the_union.txt\");\n * const rawDocuments = await loader.load();\n * const splitter = new RecursiveCharacterTextSplitter({\n * chunkSize: 1000,\n * chunkOverlap: 0,\n * });\n * const documents = await splitter.splitDocuments(rawDocuments);\n *\n * let time = Date.now();\n * const vectorstore = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Initial creation time: ${Date.now() - time}ms`);\n *\n * time = Date.now();\n * const vectorstore2 = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Cached creation time: ${Date.now() - time}ms`);\n *\n * ```\n */\nexport declare class CacheBackedEmbeddings extends Embeddings {\n protected underlyingEmbeddings: EmbeddingsInterface;\n protected documentEmbeddingStore: BaseStore<string, number[]>;\n constructor(fields: CacheBackedEmbeddingsFields);\n /**\n * Embed query text.\n *\n * This method does not support caching at the moment.\n *\n * Support for caching queries is easy to implement, but might make\n * sense to hold off to see the most common patterns.\n *\n * If the cache has an eviction policy, we may need to be a bit more careful\n * about sharing the cache between documents and queries. Generally,\n * one is OK evicting query caches, but document caches should be kept.\n *\n * @param document The text to embed.\n * @returns The embedding for the given text.\n */\n embedQuery(document: string): Promise<number[]>;\n /**\n * Embed a list of texts.\n *\n * The method first checks the cache for the embeddings.\n * If the embeddings are not found, the method uses the underlying embedder\n * to embed the documents and stores the results in the cache.\n *\n * @param documents\n * @returns A list of embeddings for the given texts.\n */\n embedDocuments(documents: string[]): Promise<number[][]>;\n /**\n * Create a new CacheBackedEmbeddings instance from another embeddings instance\n * and a storage instance.\n * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.\n * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.\n * @param options.namespace Optional namespace for store keys.\n * @returns A new CacheBackedEmbeddings instance.\n */\n static fromBytesStore(underlyingEmbeddings: EmbeddingsInterface, documentEmbeddingStore: BaseStore<string, Uint8Array>, options?: {\n namespace?: string;\n }): CacheBackedEmbeddings;\n}\n"],"mappings":";;;;;;;;AAOA;;AAC0BA,UADTI,2BAAAA,SAAoCD,iBAC3BH,CAAAA;EAAmB,oBACjBE,EADFF,mBACEE;EAAS,sBAFgBC,EAEzBD,SAFyBC,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,CAAAA;AAAiB;AAmDtE;;;;;;;;;;;;AAA6D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAxCE,qBAAAA,SAA8BJ,UAAAA;kCACfD;oCACEE;sBACdE;;;;;;;;;;;;;;;;gCAgBUE;;;;;;;;;;;uCAWOA;;;;;;;;;8CASON,6CAA6CE,kBAAkBK;;MAEvGF"}
@@ -0,0 +1,134 @@
1
+ import { __export } from "../_virtual/rolldown_runtime.js";
2
+ import { EncoderBackedStore } from "../storage/encoder_backed.js";
3
+ import { sha256 } from "@langchain/core/utils/hash";
4
+ import { Embeddings } from "@langchain/core/embeddings";
5
+
6
+ //#region src/embeddings/cache_backed.ts
7
+ var cache_backed_exports = {};
8
+ __export(cache_backed_exports, { CacheBackedEmbeddings: () => CacheBackedEmbeddings });
9
+ /**
10
+ * Interface for caching results from embedding models.
11
+ *
12
+ * The interface allows works with any store that implements
13
+ * the abstract store interface accepting keys of type str and values of list of
14
+ * floats.
15
+ *
16
+ * If need be, the interface can be extended to accept other implementations
17
+ * of the value serializer and deserializer, as well as the key encoder.
18
+ * @example
19
+ * ```typescript
20
+ * const underlyingEmbeddings = new OpenAIEmbeddings();
21
+ *
22
+ * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(
23
+ * underlyingEmbeddings,
24
+ * new ConvexKVStore({ ctx }),
25
+ * {
26
+ * namespace: underlyingEmbeddings.modelName,
27
+ * },
28
+ * );
29
+ *
30
+ * const loader = new TextLoader("./state_of_the_union.txt");
31
+ * const rawDocuments = await loader.load();
32
+ * const splitter = new RecursiveCharacterTextSplitter({
33
+ * chunkSize: 1000,
34
+ * chunkOverlap: 0,
35
+ * });
36
+ * const documents = await splitter.splitDocuments(rawDocuments);
37
+ *
38
+ * let time = Date.now();
39
+ * const vectorstore = await ConvexVectorStore.fromDocuments(
40
+ * documents,
41
+ * cacheBackedEmbeddings,
42
+ * { ctx },
43
+ * );
44
+ * console.log(`Initial creation time: ${Date.now() - time}ms`);
45
+ *
46
+ * time = Date.now();
47
+ * const vectorstore2 = await ConvexVectorStore.fromDocuments(
48
+ * documents,
49
+ * cacheBackedEmbeddings,
50
+ * { ctx },
51
+ * );
52
+ * console.log(`Cached creation time: ${Date.now() - time}ms`);
53
+ *
54
+ * ```
55
+ */
56
+ var CacheBackedEmbeddings = class extends Embeddings {
57
+ underlyingEmbeddings;
58
+ documentEmbeddingStore;
59
+ constructor(fields) {
60
+ super(fields);
61
+ this.underlyingEmbeddings = fields.underlyingEmbeddings;
62
+ this.documentEmbeddingStore = fields.documentEmbeddingStore;
63
+ }
64
+ /**
65
+ * Embed query text.
66
+ *
67
+ * This method does not support caching at the moment.
68
+ *
69
+ * Support for caching queries is easy to implement, but might make
70
+ * sense to hold off to see the most common patterns.
71
+ *
72
+ * If the cache has an eviction policy, we may need to be a bit more careful
73
+ * about sharing the cache between documents and queries. Generally,
74
+ * one is OK evicting query caches, but document caches should be kept.
75
+ *
76
+ * @param document The text to embed.
77
+ * @returns The embedding for the given text.
78
+ */
79
+ async embedQuery(document) {
80
+ return this.underlyingEmbeddings.embedQuery(document);
81
+ }
82
+ /**
83
+ * Embed a list of texts.
84
+ *
85
+ * The method first checks the cache for the embeddings.
86
+ * If the embeddings are not found, the method uses the underlying embedder
87
+ * to embed the documents and stores the results in the cache.
88
+ *
89
+ * @param documents
90
+ * @returns A list of embeddings for the given texts.
91
+ */
92
+ async embedDocuments(documents) {
93
+ const vectors = await this.documentEmbeddingStore.mget(documents);
94
+ const missingIndicies = [];
95
+ const missingDocuments = [];
96
+ for (let i = 0; i < vectors.length; i += 1) if (vectors[i] === void 0) {
97
+ missingIndicies.push(i);
98
+ missingDocuments.push(documents[i]);
99
+ }
100
+ if (missingDocuments.length) {
101
+ const missingVectors = await this.underlyingEmbeddings.embedDocuments(missingDocuments);
102
+ const keyValuePairs = missingDocuments.map((document, i) => [document, missingVectors[i]]);
103
+ await this.documentEmbeddingStore.mset(keyValuePairs);
104
+ for (let i = 0; i < missingIndicies.length; i += 1) vectors[missingIndicies[i]] = missingVectors[i];
105
+ }
106
+ return vectors;
107
+ }
108
+ /**
109
+ * Create a new CacheBackedEmbeddings instance from another embeddings instance
110
+ * and a storage instance.
111
+ * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.
112
+ * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.
113
+ * @param options.namespace Optional namespace for store keys.
114
+ * @returns A new CacheBackedEmbeddings instance.
115
+ */
116
+ static fromBytesStore(underlyingEmbeddings, documentEmbeddingStore, options) {
117
+ const encoder = new TextEncoder();
118
+ const decoder = new TextDecoder();
119
+ const encoderBackedStore = new EncoderBackedStore({
120
+ store: documentEmbeddingStore,
121
+ keyEncoder: (key) => (options?.namespace ?? "") + sha256(key),
122
+ valueSerializer: (value) => encoder.encode(JSON.stringify(value)),
123
+ valueDeserializer: (serializedValue) => JSON.parse(decoder.decode(serializedValue))
124
+ });
125
+ return new this({
126
+ underlyingEmbeddings,
127
+ documentEmbeddingStore: encoderBackedStore
128
+ });
129
+ }
130
+ };
131
+
132
+ //#endregion
133
+ export { CacheBackedEmbeddings, cache_backed_exports };
134
+ //# sourceMappingURL=cache_backed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache_backed.js","names":["fields: CacheBackedEmbeddingsFields","document: string","documents: string[]","keyValuePairs: [string, number[]][]","underlyingEmbeddings: EmbeddingsInterface","documentEmbeddingStore: BaseStore<string, Uint8Array>","options?: {\n namespace?: string;\n }"],"sources":["../../src/embeddings/cache_backed.ts"],"sourcesContent":["import { sha256 } from \"@langchain/core/utils/hash\";\nimport {\n type EmbeddingsInterface,\n Embeddings,\n} from \"@langchain/core/embeddings\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\nimport { AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\nimport { EncoderBackedStore } from \"../storage/encoder_backed.js\";\n\n/**\n * Interface for the fields required to initialize an instance of the\n * CacheBackedEmbeddings class.\n */\nexport interface CacheBackedEmbeddingsFields extends AsyncCallerParams {\n underlyingEmbeddings: EmbeddingsInterface;\n documentEmbeddingStore: BaseStore<string, number[]>;\n}\n\n/**\n * Interface for caching results from embedding models.\n *\n * The interface allows works with any store that implements\n * the abstract store interface accepting keys of type str and values of list of\n * floats.\n *\n * If need be, the interface can be extended to accept other implementations\n * of the value serializer and deserializer, as well as the key encoder.\n * @example\n * ```typescript\n * const underlyingEmbeddings = new OpenAIEmbeddings();\n *\n * const cacheBackedEmbeddings = CacheBackedEmbeddings.fromBytesStore(\n * underlyingEmbeddings,\n * new ConvexKVStore({ ctx }),\n * {\n * namespace: underlyingEmbeddings.modelName,\n * },\n * );\n *\n * const loader = new TextLoader(\"./state_of_the_union.txt\");\n * const rawDocuments = await loader.load();\n * const splitter = new RecursiveCharacterTextSplitter({\n * chunkSize: 1000,\n * chunkOverlap: 0,\n * });\n * const documents = await splitter.splitDocuments(rawDocuments);\n *\n * let time = Date.now();\n * const vectorstore = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Initial creation time: ${Date.now() - time}ms`);\n *\n * time = Date.now();\n * const vectorstore2 = await ConvexVectorStore.fromDocuments(\n * documents,\n * cacheBackedEmbeddings,\n * { ctx },\n * );\n * console.log(`Cached creation time: ${Date.now() - time}ms`);\n *\n * ```\n */\nexport class CacheBackedEmbeddings extends Embeddings {\n protected underlyingEmbeddings: EmbeddingsInterface;\n\n protected documentEmbeddingStore: BaseStore<string, number[]>;\n\n constructor(fields: CacheBackedEmbeddingsFields) {\n super(fields);\n this.underlyingEmbeddings = fields.underlyingEmbeddings;\n this.documentEmbeddingStore = fields.documentEmbeddingStore;\n }\n\n /**\n * Embed query text.\n *\n * This method does not support caching at the moment.\n *\n * Support for caching queries is easy to implement, but might make\n * sense to hold off to see the most common patterns.\n *\n * If the cache has an eviction policy, we may need to be a bit more careful\n * about sharing the cache between documents and queries. Generally,\n * one is OK evicting query caches, but document caches should be kept.\n *\n * @param document The text to embed.\n * @returns The embedding for the given text.\n */\n async embedQuery(document: string): Promise<number[]> {\n return this.underlyingEmbeddings.embedQuery(document);\n }\n\n /**\n * Embed a list of texts.\n *\n * The method first checks the cache for the embeddings.\n * If the embeddings are not found, the method uses the underlying embedder\n * to embed the documents and stores the results in the cache.\n *\n * @param documents\n * @returns A list of embeddings for the given texts.\n */\n async embedDocuments(documents: string[]): Promise<number[][]> {\n const vectors = await this.documentEmbeddingStore.mget(documents);\n const missingIndicies = [];\n const missingDocuments = [];\n for (let i = 0; i < vectors.length; i += 1) {\n if (vectors[i] === undefined) {\n missingIndicies.push(i);\n missingDocuments.push(documents[i]);\n }\n }\n if (missingDocuments.length) {\n const missingVectors = await this.underlyingEmbeddings.embedDocuments(\n missingDocuments\n );\n const keyValuePairs: [string, number[]][] = missingDocuments.map(\n (document, i) => [document, missingVectors[i]]\n );\n await this.documentEmbeddingStore.mset(keyValuePairs);\n for (let i = 0; i < missingIndicies.length; i += 1) {\n vectors[missingIndicies[i]] = missingVectors[i];\n }\n }\n return vectors as number[][];\n }\n\n /**\n * Create a new CacheBackedEmbeddings instance from another embeddings instance\n * and a storage instance.\n * @param underlyingEmbeddings Embeddings used to populate the cache for new documents.\n * @param documentEmbeddingStore Stores raw document embedding values. Keys are hashes of the document content.\n * @param options.namespace Optional namespace for store keys.\n * @returns A new CacheBackedEmbeddings instance.\n */\n static fromBytesStore(\n underlyingEmbeddings: EmbeddingsInterface,\n documentEmbeddingStore: BaseStore<string, Uint8Array>,\n options?: {\n namespace?: string;\n }\n ) {\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n const encoderBackedStore = new EncoderBackedStore<\n string,\n number[],\n Uint8Array\n >({\n store: documentEmbeddingStore,\n keyEncoder: (key) => (options?.namespace ?? \"\") + sha256(key),\n valueSerializer: (value) => encoder.encode(JSON.stringify(value)),\n valueDeserializer: (serializedValue) =>\n JSON.parse(decoder.decode(serializedValue)),\n });\n return new this({\n underlyingEmbeddings,\n documentEmbeddingStore: encoderBackedStore,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAa,wBAAb,cAA2C,WAAW;CACpD,AAAU;CAEV,AAAU;CAEV,YAAYA,QAAqC;EAC/C,MAAM,OAAO;EACb,KAAK,uBAAuB,OAAO;EACnC,KAAK,yBAAyB,OAAO;CACtC;;;;;;;;;;;;;;;;CAiBD,MAAM,WAAWC,UAAqC;AACpD,SAAO,KAAK,qBAAqB,WAAW,SAAS;CACtD;;;;;;;;;;;CAYD,MAAM,eAAeC,WAA0C;EAC7D,MAAM,UAAU,MAAM,KAAK,uBAAuB,KAAK,UAAU;EACjE,MAAM,kBAAkB,CAAE;EAC1B,MAAM,mBAAmB,CAAE;AAC3B,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK,EACvC,KAAI,QAAQ,OAAO,QAAW;GAC5B,gBAAgB,KAAK,EAAE;GACvB,iBAAiB,KAAK,UAAU,GAAG;EACpC;AAEH,MAAI,iBAAiB,QAAQ;GAC3B,MAAM,iBAAiB,MAAM,KAAK,qBAAqB,eACrD,iBACD;GACD,MAAMC,gBAAsC,iBAAiB,IAC3D,CAAC,UAAU,MAAM,CAAC,UAAU,eAAe,EAAG,EAC/C;GACD,MAAM,KAAK,uBAAuB,KAAK,cAAc;AACrD,QAAK,IAAI,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK,GAC/C,QAAQ,gBAAgB,MAAM,eAAe;EAEhD;AACD,SAAO;CACR;;;;;;;;;CAUD,OAAO,eACLC,sBACAC,wBACAC,SAGA;EACA,MAAM,UAAU,IAAI;EACpB,MAAM,UAAU,IAAI;EACpB,MAAM,qBAAqB,IAAI,mBAI7B;GACA,OAAO;GACP,YAAY,CAAC,SAAS,SAAS,aAAa,MAAM,OAAO,IAAI;GAC7D,iBAAiB,CAAC,UAAU,QAAQ,OAAO,KAAK,UAAU,MAAM,CAAC;GACjE,mBAAmB,CAAC,oBAClB,KAAK,MAAM,QAAQ,OAAO,gBAAgB,CAAC;EAC9C;AACD,SAAO,IAAI,KAAK;GACd;GACA,wBAAwB;EACzB;CACF;AACF"}
@@ -0,0 +1,22 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+
3
+ //#region src/embeddings/fake.ts
4
+ var fake_exports = {};
5
+ require_rolldown_runtime.__reExport(fake_exports, require("@langchain/core/utils/testing"));
6
+
7
+ //#endregion
8
+ Object.defineProperty(exports, 'fake_exports', {
9
+ enumerable: true,
10
+ get: function () {
11
+ return fake_exports;
12
+ }
13
+ });
14
+ var __langchain_core_utils_testing = require("@langchain/core/utils/testing");
15
+ Object.keys(__langchain_core_utils_testing).forEach(function (k) {
16
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
+ enumerable: true,
18
+ get: function () { return __langchain_core_utils_testing[k]; }
19
+ });
20
+ });
21
+
22
+ //# sourceMappingURL=fake.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake.cjs","names":[],"sources":["../../src/embeddings/fake.ts"],"sourcesContent":["export * from \"@langchain/core/utils/testing\";\n"],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from "@langchain/core/utils/testing";
@@ -0,0 +1 @@
1
+ export * from "@langchain/core/utils/testing";
@@ -0,0 +1,12 @@
1
+ import { __reExport } from "../_virtual/rolldown_runtime.js";
2
+
3
+ export * from "@langchain/core/utils/testing"
4
+
5
+ //#region src/embeddings/fake.ts
6
+ var fake_exports = {};
7
+ import * as import___langchain_core_utils_testing from "@langchain/core/utils/testing";
8
+ __reExport(fake_exports, import___langchain_core_utils_testing);
9
+
10
+ //#endregion
11
+ export { fake_exports };
12
+ //# sourceMappingURL=fake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake.js","names":[],"sources":["../../src/embeddings/fake.ts"],"sourcesContent":["export * from \"@langchain/core/utils/testing\";\n"],"mappings":""}
package/dist/hub/base.cjs CHANGED
@@ -1,3 +1,5 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const langsmith = require_rolldown_runtime.__toESM(require("langsmith"));
1
3
 
2
4
  //#region src/hub/base.ts
3
5
  /**
@@ -9,8 +11,7 @@
9
11
  * @returns The URL of the newly pushed prompt in the hub.
10
12
  */
11
13
  async function basePush(repoFullName, runnable, options) {
12
- const Client = await loadLangSmith();
13
- const client = new Client(options);
14
+ const client = new langsmith.Client(options);
14
15
  const payloadOptions = {
15
16
  object: runnable,
16
17
  parentCommitHash: options?.parentCommitHash,
@@ -22,8 +23,7 @@ async function basePush(repoFullName, runnable, options) {
22
23
  return client.pushPrompt(repoFullName, payloadOptions);
23
24
  }
24
25
  async function basePull(ownerRepoCommit, options) {
25
- const Client = await loadLangSmith();
26
- const client = new Client(options);
26
+ const client = new langsmith.Client(options);
27
27
  const promptObject = await client.pullPromptCommit(ownerRepoCommit, { includeModel: options?.includeModel });
28
28
  if (promptObject.manifest.kwargs?.metadata === void 0) promptObject.manifest.kwargs = {
29
29
  ...promptObject.manifest.kwargs,
@@ -90,19 +90,6 @@ function bindOutputSchema(loadedSequence) {
90
90
  }
91
91
  return loadedSequence;
92
92
  }
93
- /**
94
- * Dynamically load the LangSmith client.
95
- * @returns The LangSmith client.
96
- */
97
- async function loadLangSmith() {
98
- try {
99
- const { Client } = await Promise.resolve().then(() => require("../node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/index.cjs"));
100
- return Client;
101
- } catch (error) {
102
- const errorMessage = error instanceof Error ? error.message : String(error);
103
- throw new Error(`Error loading "langsmith" package, install it via \`npm install langsmith\` before you use this function.\nError: ${errorMessage}`);
104
- }
105
- }
106
93
 
107
94
  //#endregion
108
95
  exports.basePull = basePull;
@@ -1 +1 @@
1
- {"version":3,"file":"base.cjs","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }","ownerRepoCommit: string","options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport type { Client, ClientConfig } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }\n): Promise<string> {\n const Client = await loadLangSmith();\n const client = new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }\n): Promise<PromptCommit> {\n const Client = await loadLangSmith();\n const client = new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n\n/**\n * Dynamically load the LangSmith client.\n * @returns The LangSmith client.\n */\nasync function loadLangSmith(): Promise<new (config?: ClientConfig) => Client> {\n try {\n const { Client } = await import(\"langsmith\");\n return Client;\n } catch (error) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Error loading \"langsmith\" package, install it via \\`npm install langsmith\\` before you use this function.\\nError: ${errorMessage}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,eAAsB,SACpBA,cACA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AK,qBACxC,eAAe,MAAM,OACtB;CACF;AAEH,QAAO;AACR;;;;;AAMD,eAAe,gBAAgE;AAC7E,KAAI;EACF,MAAM,EAAE,QAAQ,GAAG,2CAAM;AACzB,SAAO;CACR,SAAQ,OAAO;EAEd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,QAAM,IAAI,MACR,CAAC,kHAAkH,EAAE,cAAc;CAEtI;AACF"}
1
+ {"version":3,"file":"base.cjs","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }","Client","ownerRepoCommit: string","options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport { Client } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }\n): Promise<string> {\n const client = new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }\n): Promise<PromptCommit> {\n const client = new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,eAAsB,SACpBA,cACAC,UACAC,SASiB;CACjB,MAAM,SAAS,IAAIC,iBAAO;CAC1B,MAAM,iBAAiB;EACrB,QAAQ;EACR,kBAAkB,SAAS;EAC3B,UAAU,SAAS;EACnB,aAAa,SAAS;EACtB,QAAQ,SAAS;EACjB,MAAM,SAAS;CAChB;AACD,QAAO,OAAO,WAAW,cAAc,eAAe;AACvD;AAED,eAAsB,SACpBC,iBACAC,SACuB;CACvB,MAAM,SAAS,IAAIF,iBAAO;CAE1B,MAAM,eAAe,MAAM,OAAO,iBAAiB,iBAAiB,EAClE,cAAc,SAAS,aACxB,EAAC;AAEF,KAAI,aAAa,SAAS,QAAQ,aAAa,QAC7C,aAAa,SAAS,SAAS;EAC7B,GAAG,aAAa,SAAS;EACzB,UAAU,CAAE;CACb;CAGH,aAAa,SAAS,OAAO,WAAW;EACtC,GAAG,aAAa,SAAS,OAAO;EAChC,cAAc,aAAa;EAC3B,aAAa,aAAa;EAC1B,oBAAoB,aAAa;CAClC;AAGD,KAAI,aAAa,SAAS,OAAO,oBAAoB,YAAY;EAC/D,MAAM,mBAAmB,CAACG,YAAoB,QAAQ,MAAM,IAAI,CAAC;EAEjE,MAAM,EAAE,iBAAiB,GAAG,aAAa,SAAS;AAClD,MAAI,MAAM,QAAQ,gBAAgB,EAChC,aAAa,SAAS,OAAO,kBAC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AAY,eAAe,SAC3B,UAAU,kBACV,eAAe,SAAS,QACxB,OAAO,eAAe,SAAS,UAE/B;MACE,WAAW,eAAe,QAC1B,eAAe,KAAK,UAAU,QAC9B,OAAO,eAAe,KAAK,UAAU,YACrC,0BAA0B,eAAe,KAAK,SAC9C,OAAO,eAAe,KAAK,MAAM,yBAAyB,YAE1D,eAAe,KAAK,QAClB,eAAe,KAAK,MAAM,qBACxB,eAAe,MAAM,OACtB;WAEH,0BAA0B,eAAe,QACzC,OAAO,eAAe,KAAK,yBAAyB,YAEpD,eAAe,OAAO,eAAe,KAAK,qBACxC,eAAe,MAAM,OACtB;CACF;AAEH,QAAO;AACR"}
package/dist/hub/base.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { Client } from "langsmith";
2
+
1
3
  //#region src/hub/base.ts
2
4
  /**
3
5
  * Push a prompt to the hub.
@@ -8,7 +10,6 @@
8
10
  * @returns The URL of the newly pushed prompt in the hub.
9
11
  */
10
12
  async function basePush(repoFullName, runnable, options) {
11
- const Client = await loadLangSmith();
12
13
  const client = new Client(options);
13
14
  const payloadOptions = {
14
15
  object: runnable,
@@ -21,7 +22,6 @@ async function basePush(repoFullName, runnable, options) {
21
22
  return client.pushPrompt(repoFullName, payloadOptions);
22
23
  }
23
24
  async function basePull(ownerRepoCommit, options) {
24
- const Client = await loadLangSmith();
25
25
  const client = new Client(options);
26
26
  const promptObject = await client.pullPromptCommit(ownerRepoCommit, { includeModel: options?.includeModel });
27
27
  if (promptObject.manifest.kwargs?.metadata === void 0) promptObject.manifest.kwargs = {
@@ -89,19 +89,6 @@ function bindOutputSchema(loadedSequence) {
89
89
  }
90
90
  return loadedSequence;
91
91
  }
92
- /**
93
- * Dynamically load the LangSmith client.
94
- * @returns The LangSmith client.
95
- */
96
- async function loadLangSmith() {
97
- try {
98
- const { Client } = await import("../node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/index.js");
99
- return Client;
100
- } catch (error) {
101
- const errorMessage = error instanceof Error ? error.message : String(error);
102
- throw new Error(`Error loading "langsmith" package, install it via \`npm install langsmith\` before you use this function.\nError: ${errorMessage}`);
103
- }
104
- }
105
92
 
106
93
  //#endregion
107
94
  export { basePull, basePush, bindOutputSchema, generateModelImportMap, generateOptionalImportMap };
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }","ownerRepoCommit: string","options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport type { Client, ClientConfig } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }\n): Promise<string> {\n const Client = await loadLangSmith();\n const client = new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }\n): Promise<PromptCommit> {\n const Client = await loadLangSmith();\n const client = new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n\n/**\n * Dynamically load the LangSmith client.\n * @returns The LangSmith client.\n */\nasync function loadLangSmith(): Promise<new (config?: ClientConfig) => Client> {\n try {\n const { Client } = await import(\"langsmith\");\n return Client;\n } catch (error) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Error loading \"langsmith\" package, install it via \\`npm install langsmith\\` before you use this function.\\nError: ${errorMessage}`\n );\n }\n}\n"],"mappings":";;;;;;;;;AAcA,eAAsB,SACpBA,cACAC,UACAC,SASiB;CACjB,MAAM,SAAS,MAAM,eAAe;CACpC,MAAM,SAAS,IAAI,OAAO;CAC1B,MAAM,iBAAiB;EACrB,QAAQ;EACR,kBAAkB,SAAS;EAC3B,UAAU,SAAS;EACnB,aAAa,SAAS;EACtB,QAAQ,SAAS;EACjB,MAAM,SAAS;CAChB;AACD,QAAO,OAAO,WAAW,cAAc,eAAe;AACvD;AAED,eAAsB,SACpBC,iBACAC,SACuB;CACvB,MAAM,SAAS,MAAM,eAAe;CACpC,MAAM,SAAS,IAAI,OAAO;CAE1B,MAAM,eAAe,MAAM,OAAO,iBAAiB,iBAAiB,EAClE,cAAc,SAAS,aACxB,EAAC;AAEF,KAAI,aAAa,SAAS,QAAQ,aAAa,QAC7C,aAAa,SAAS,SAAS;EAC7B,GAAG,aAAa,SAAS;EACzB,UA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C,CAAE;AACjD,KAAI,eAAe,QAAW;EAE5B,MAAM,cAAe,YAAoB,SAAS;EAClD,IAAI;AACJ,MAAI,gBAAgB,0BAClB,uBAAuB;WACd,gBAAgB,uBACzB,uBAAuB;WACd,gBAAgB,YACzB,uBAAuB;AAEzB,MAAI,yBAAyB,QAC3B,kBAAkB,wBAAwB,GACvC,cAAc,WAChB;CAEJ;AACD,QAAO;AACR;AAED,SAAgB,iBAAqCC,gBAAmB;AACtE,KACE,WAAW,kBACX,eAAe,UAAU,QACzB,OAAO,eAAe,UAAU,YAChC,YAAY,eAAe,SAC3B,UAAU,kBACV,eAAe,SAAS,QACxB,OAAO,eAAe,SAAS,UAE/B;MACE,WAAW,eAAe,QAC1B,eAAe,KAAK,UAAU,QAC9B,OAAO,eAAe,KAAK,UAAU,YACrC,0BAA0B,eAAe,KAAK,SAC9C,OAAO,eAAe,KAAK,MAAM,yBAAyB,YAE1D,eAAe,KAAK,QAClB,eAAe,KAAK,MAAM,qBACxB,eAAe,MAAM,OACtB;WAEH,0BAA0B,eAAe,QACzC,OAAO,eAAe,KAAK,yBAAyB,YAEpD,eAAe,OAAO,eAAe,KAAK,qBACxC,eAAe,MAAM,OACtB;CACF;AAEH,QAAO;AACR;;;;;AAMD,eAAe,gBAAgE;AAC7E,KAAI;EACF,MAAM,EAAE,QAAQ,GAAG,MAAM,OAAO;AAChC,SAAO;CACR,SAAQ,OAAO;EAEd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,QAAM,IAAI,MACR,CAAC,kHAAkH,EAAE,cAAc;CAEtI;AACF"}
1
+ {"version":3,"file":"base.js","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }","ownerRepoCommit: string","options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport { Client } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }\n): Promise<string> {\n const client = new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }\n): Promise<PromptCommit> {\n const client = new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n"],"mappings":";;;;;;;;;;;AAcA,eAAsB,SACpBA,cACAC,UACAC,SASiB;CACjB,MAAM,SAAS,IAAI,OAAO;CAC1B,MAAM,iBAAiB;EACrB,QAAQ;EACR,kBAAkB,SAAS;EAC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