langchain 0.0.213 → 0.0.214

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/openai_functions/index.cjs +2 -0
  3. package/dist/agents/openai_functions/index.d.ts +2 -0
  4. package/dist/agents/openai_functions/index.js +2 -0
  5. package/dist/agents/openai_tools/index.cjs +2 -0
  6. package/dist/agents/openai_tools/index.d.ts +2 -0
  7. package/dist/agents/openai_tools/index.js +2 -0
  8. package/dist/agents/react/index.cjs +2 -0
  9. package/dist/agents/react/index.d.ts +2 -0
  10. package/dist/agents/react/index.js +2 -0
  11. package/dist/agents/structured_chat/index.cjs +2 -0
  12. package/dist/agents/structured_chat/index.d.ts +2 -0
  13. package/dist/agents/structured_chat/index.js +2 -0
  14. package/dist/agents/xml/index.cjs +2 -0
  15. package/dist/agents/xml/index.d.ts +2 -0
  16. package/dist/agents/xml/index.js +2 -0
  17. package/dist/callbacks/index.cjs +1 -4
  18. package/dist/callbacks/index.d.ts +1 -2
  19. package/dist/callbacks/index.js +1 -2
  20. package/dist/chains/openai_functions/structured_output.cjs +63 -21
  21. package/dist/chains/openai_functions/structured_output.d.ts +25 -17
  22. package/dist/chains/openai_functions/structured_output.js +62 -20
  23. package/dist/experimental/autogpt/prompt.cjs +1 -1
  24. package/dist/experimental/autogpt/prompt.d.ts +1 -1
  25. package/dist/experimental/autogpt/prompt.js +1 -1
  26. package/dist/retrievers/multi_vector.cjs +11 -2
  27. package/dist/retrievers/multi_vector.d.ts +5 -3
  28. package/dist/retrievers/multi_vector.js +11 -2
  29. package/dist/retrievers/parent_document.cjs +1 -2
  30. package/dist/retrievers/parent_document.d.ts +1 -1
  31. package/dist/retrievers/parent_document.js +1 -2
  32. package/dist/retrievers/remote/chatgpt-plugin.cjs +5 -4
  33. package/dist/retrievers/remote/chatgpt-plugin.d.ts +5 -2
  34. package/dist/retrievers/remote/chatgpt-plugin.js +3 -2
  35. package/dist/retrievers/remote/index.cjs +2 -2
  36. package/dist/retrievers/remote/index.d.ts +1 -1
  37. package/dist/retrievers/remote/index.js +1 -1
  38. package/dist/retrievers/remote/remote-retriever.cjs +3 -2
  39. package/dist/retrievers/remote/remote-retriever.d.ts +3 -1
  40. package/dist/retrievers/remote/remote-retriever.js +2 -1
  41. package/dist/retrievers/vespa.cjs +15 -78
  42. package/dist/retrievers/vespa.d.ts +1 -54
  43. package/dist/retrievers/vespa.js +1 -76
  44. package/dist/schema/runnable/config.d.ts +1 -1
  45. package/dist/util/entrypoint_deprecation.cjs +18 -0
  46. package/dist/util/entrypoint_deprecation.d.ts +5 -0
  47. package/dist/util/entrypoint_deprecation.js +14 -0
  48. package/package.json +2 -2
  49. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +0 -17
  50. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +0 -1
  51. package/dist/callbacks/handlers/tracer_langchain_v1.js +0 -1
  52. package/dist/retrievers/remote/base.cjs +0 -68
  53. package/dist/retrievers/remote/base.d.ts +0 -60
  54. package/dist/retrievers/remote/base.js +0 -64
@@ -1,13 +1,15 @@
1
1
  import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
2
2
  import type { VectorStoreInterface } from "@langchain/core/vectorstores";
3
- import { BaseStoreInterface } from "../schema/storage.js";
3
+ import { BaseStore, BaseStoreInterface } from "../schema/storage.js";
4
4
  import { Document } from "../document.js";
5
5
  /**
6
6
  * Arguments for the MultiVectorRetriever class.
7
7
  */
8
8
  export interface MultiVectorRetrieverInput extends BaseRetrieverInput {
9
9
  vectorstore: VectorStoreInterface;
10
- docstore: BaseStoreInterface<string, Document>;
10
+ /** @deprecated Prefer `byteStore`. */
11
+ docstore?: BaseStoreInterface<string, Document>;
12
+ byteStore?: BaseStore<string, Uint8Array>;
11
13
  idKey?: string;
12
14
  childK?: number;
13
15
  parentK?: number;
@@ -20,7 +22,7 @@ export interface MultiVectorRetrieverInput extends BaseRetrieverInput {
20
22
  * ```typescript
21
23
  * const retriever = new MultiVectorRetriever({
22
24
  * vectorstore: new FaissStore(),
23
- * docstore: new InMemoryStore(),
25
+ * byteStore: new InMemoryStore<Unit8Array>(),
24
26
  * idKey: "doc_id",
25
27
  * childK: 20,
26
28
  * parentK: 5,
@@ -1,4 +1,5 @@
1
1
  import { BaseRetriever, } from "@langchain/core/retrievers";
2
+ import { createDocumentStoreFromByteStore } from "../storage/encoder_backed.js";
2
3
  /**
3
4
  * A retriever that retrieves documents from a vector store and a document
4
5
  * store. It uses the vector store to find relevant documents based on a
@@ -7,7 +8,7 @@ import { BaseRetriever, } from "@langchain/core/retrievers";
7
8
  * ```typescript
8
9
  * const retriever = new MultiVectorRetriever({
9
10
  * vectorstore: new FaissStore(),
10
- * docstore: new InMemoryStore(),
11
+ * byteStore: new InMemoryStore<Unit8Array>(),
11
12
  * idKey: "doc_id",
12
13
  * childK: 20,
13
14
  * parentK: 5,
@@ -60,7 +61,15 @@ export class MultiVectorRetriever extends BaseRetriever {
60
61
  value: void 0
61
62
  });
62
63
  this.vectorstore = args.vectorstore;
63
- this.docstore = args.docstore;
64
+ if (args.byteStore) {
65
+ this.docstore = createDocumentStoreFromByteStore(args.byteStore);
66
+ }
67
+ else if (args.docstore) {
68
+ this.docstore = args.docstore;
69
+ }
70
+ else {
71
+ throw new Error("byteStore and docstore are undefined. Please provide at least one.");
72
+ }
64
73
  this.idKey = args.idKey ?? "doc_id";
65
74
  this.childK = args.childK;
66
75
  this.parentK = args.parentK;
@@ -39,7 +39,7 @@ const multi_vector_js_1 = require("./multi_vector.cjs");
39
39
  * ```typescript
40
40
  * const retriever = new ParentDocumentRetriever({
41
41
  * vectorstore: new MemoryVectorStore(new OpenAIEmbeddings()),
42
- * docstore: new InMemoryStore(),
42
+ * byteStore: new InMemoryStore<Uint8Array>(),
43
43
  * parentSplitter: new RecursiveCharacterTextSplitter({
44
44
  * chunkOverlap: 0,
45
45
  * chunkSize: 500,
@@ -112,7 +112,6 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
112
112
  value: void 0
113
113
  });
114
114
  this.vectorstore = fields.vectorstore;
115
- this.docstore = fields.docstore;
116
115
  this.childSplitter = fields.childSplitter;
117
116
  this.parentSplitter = fields.parentSplitter;
118
117
  this.idKey = fields.idKey ?? this.idKey;
@@ -27,7 +27,7 @@ export type ParentDocumentRetrieverFields = MultiVectorRetrieverInput & {
27
27
  * ```typescript
28
28
  * const retriever = new ParentDocumentRetriever({
29
29
  * vectorstore: new MemoryVectorStore(new OpenAIEmbeddings()),
30
- * docstore: new InMemoryStore(),
30
+ * byteStore: new InMemoryStore<Uint8Array>(),
31
31
  * parentSplitter: new RecursiveCharacterTextSplitter({
32
32
  * chunkOverlap: 0,
33
33
  * chunkSize: 500,
@@ -13,7 +13,7 @@ import { MultiVectorRetriever, } from "./multi_vector.js";
13
13
  * ```typescript
14
14
  * const retriever = new ParentDocumentRetriever({
15
15
  * vectorstore: new MemoryVectorStore(new OpenAIEmbeddings()),
16
- * docstore: new InMemoryStore(),
16
+ * byteStore: new InMemoryStore<Uint8Array>(),
17
17
  * parentSplitter: new RecursiveCharacterTextSplitter({
18
18
  * chunkOverlap: 0,
19
19
  * chunkSize: 500,
@@ -86,7 +86,6 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
86
86
  value: void 0
87
87
  });
88
88
  this.vectorstore = fields.vectorstore;
89
- this.docstore = fields.docstore;
90
89
  this.childSplitter = fields.childSplitter;
91
90
  this.parentSplitter = fields.parentSplitter;
92
91
  this.idKey = fields.idKey ?? this.idKey;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChatGPTPluginRetriever = void 0;
4
- const document_js_1 = require("../../document.cjs");
5
- const base_js_1 = require("./base.cjs");
4
+ const documents_1 = require("@langchain/core/documents");
5
+ const remote_1 = require("@langchain/community/retrievers/remote");
6
6
  /**
7
+ * @deprecated ChatGPT Plugins have been deprecated in favor of GPTs.
7
8
  * Class that connects ChatGPT to third-party applications via plugins. It
8
9
  * extends the RemoteRetriever class and implements the
9
10
  * ChatGPTPluginRetrieverParams interface.
@@ -18,7 +19,7 @@ const base_js_1 = require("./base.cjs");
18
19
  * const docs = await retriever.getRelevantDocuments("hello world");
19
20
  * ```
20
21
  */
21
- class ChatGPTPluginRetriever extends base_js_1.RemoteRetriever {
22
+ class ChatGPTPluginRetriever extends remote_1.RemoteRetriever {
22
23
  constructor({ topK = 4, filter, ...rest }) {
23
24
  super(rest);
24
25
  Object.defineProperty(this, "lc_namespace", {
@@ -73,7 +74,7 @@ class ChatGPTPluginRetriever extends base_js_1.RemoteRetriever {
73
74
  }
74
75
  return results.map(
75
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- (result) => new document_js_1.Document({
77
+ (result) => new documents_1.Document({
77
78
  pageContent: result.text,
78
79
  metadata: result.metadata,
79
80
  }));
@@ -1,6 +1,7 @@
1
- import { Document } from "../../document.js";
2
- import { RemoteRetriever, RemoteRetrieverParams, RemoteRetrieverValues } from "./base.js";
1
+ import { Document } from "@langchain/core/documents";
2
+ import { RemoteRetriever, RemoteRetrieverParams, RemoteRetrieverValues } from "@langchain/community/retrievers/remote";
3
3
  /**
4
+ * @deprecated
4
5
  * Interface for the filter parameters used when querying the
5
6
  * ChatGPTRetrievalPlugin server.
6
7
  */
@@ -12,6 +13,7 @@ export interface ChatGPTPluginRetrieverFilter {
12
13
  start_date?: string;
13
14
  end_date?: string;
14
15
  }
16
+ /** @deprecated */
15
17
  export interface ChatGPTPluginRetrieverParams extends RemoteRetrieverParams {
16
18
  /**
17
19
  * The number of results to request from the ChatGPTRetrievalPlugin server
@@ -23,6 +25,7 @@ export interface ChatGPTPluginRetrieverParams extends RemoteRetrieverParams {
23
25
  filter?: ChatGPTPluginRetrieverFilter;
24
26
  }
25
27
  /**
28
+ * @deprecated ChatGPT Plugins have been deprecated in favor of GPTs.
26
29
  * Class that connects ChatGPT to third-party applications via plugins. It
27
30
  * extends the RemoteRetriever class and implements the
28
31
  * ChatGPTPluginRetrieverParams interface.
@@ -1,6 +1,7 @@
1
- import { Document } from "../../document.js";
2
- import { RemoteRetriever, } from "./base.js";
1
+ import { Document } from "@langchain/core/documents";
2
+ import { RemoteRetriever, } from "@langchain/community/retrievers/remote";
3
3
  /**
4
+ * @deprecated ChatGPT Plugins have been deprecated in favor of GPTs.
4
5
  * Class that connects ChatGPT to third-party applications via plugins. It
5
6
  * extends the RemoteRetriever class and implements the
6
7
  * ChatGPTPluginRetrieverParams interface.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoteLangChainRetriever = exports.ChatGPTPluginRetriever = exports.RemoteRetriever = void 0;
4
- var base_js_1 = require("./base.cjs");
5
- Object.defineProperty(exports, "RemoteRetriever", { enumerable: true, get: function () { return base_js_1.RemoteRetriever; } });
4
+ var remote_1 = require("@langchain/community/retrievers/remote");
5
+ Object.defineProperty(exports, "RemoteRetriever", { enumerable: true, get: function () { return remote_1.RemoteRetriever; } });
6
6
  var chatgpt_plugin_js_1 = require("./chatgpt-plugin.cjs");
7
7
  Object.defineProperty(exports, "ChatGPTPluginRetriever", { enumerable: true, get: function () { return chatgpt_plugin_js_1.ChatGPTPluginRetriever; } });
8
8
  var remote_retriever_js_1 = require("./remote-retriever.cjs");
@@ -1,3 +1,3 @@
1
- export { RemoteRetriever, type RemoteRetrieverParams, type RemoteRetrieverAuth, type RemoteRetrieverValues, } from "./base.js";
1
+ export { RemoteRetriever, type RemoteRetrieverParams, type RemoteRetrieverAuth, type RemoteRetrieverValues, } from "@langchain/community/retrievers/remote";
2
2
  export { ChatGPTPluginRetriever, type ChatGPTPluginRetrieverFilter, type ChatGPTPluginRetrieverParams, } from "./chatgpt-plugin.js";
3
3
  export { RemoteLangChainRetriever, type RemoteLangChainRetrieverParams, } from "./remote-retriever.js";
@@ -1,3 +1,3 @@
1
- export { RemoteRetriever, } from "./base.js";
1
+ export { RemoteRetriever, } from "@langchain/community/retrievers/remote";
2
2
  export { ChatGPTPluginRetriever, } from "./chatgpt-plugin.js";
3
3
  export { RemoteLangChainRetriever, } from "./remote-retriever.js";
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoteLangChainRetriever = void 0;
4
+ const remote_1 = require("@langchain/community/retrievers/remote");
4
5
  const document_js_1 = require("../../document.cjs");
5
- const base_js_1 = require("./base.cjs");
6
6
  /**
7
+ * @deprecated Use RemoteRetriever instead.
7
8
  * Specific implementation of the `RemoteRetriever` class designed to
8
9
  * retrieve documents from a remote source using a JSON-based API. It
9
10
  * implements the `RemoteLangChainRetrieverParams` interface which defines
10
11
  * the keys used to interact with the JSON API.
11
12
  */
12
- class RemoteLangChainRetriever extends base_js_1.RemoteRetriever {
13
+ class RemoteLangChainRetriever extends remote_1.RemoteRetriever {
13
14
  constructor({ inputKey = "message", responseKey = "response", pageContentKey = "page_content", metadataKey = "metadata", ...rest }) {
14
15
  super(rest);
15
16
  Object.defineProperty(this, "lc_namespace", {
@@ -1,5 +1,6 @@
1
+ import { RemoteRetriever, RemoteRetrieverParams, RemoteRetrieverValues } from "@langchain/community/retrievers/remote";
1
2
  import { Document } from "../../document.js";
2
- import { RemoteRetriever, RemoteRetrieverParams, RemoteRetrieverValues } from "./base.js";
3
+ /** @deprecated */
3
4
  export interface RemoteLangChainRetrieverParams extends RemoteRetrieverParams {
4
5
  /**
5
6
  * The key in the JSON body to put the query in
@@ -19,6 +20,7 @@ export interface RemoteLangChainRetrieverParams extends RemoteRetrieverParams {
19
20
  metadataKey?: string;
20
21
  }
21
22
  /**
23
+ * @deprecated Use RemoteRetriever instead.
22
24
  * Specific implementation of the `RemoteRetriever` class designed to
23
25
  * retrieve documents from a remote source using a JSON-based API. It
24
26
  * implements the `RemoteLangChainRetrieverParams` interface which defines
@@ -1,6 +1,7 @@
1
+ import { RemoteRetriever, } from "@langchain/community/retrievers/remote";
1
2
  import { Document } from "../../document.js";
2
- import { RemoteRetriever, } from "./base.js";
3
3
  /**
4
+ * @deprecated Use RemoteRetriever instead.
4
5
  * Specific implementation of the `RemoteRetriever` class designed to
5
6
  * retrieve documents from a remote source using a JSON-based API. It
6
7
  * implements the `RemoteLangChainRetrieverParams` interface which defines
@@ -1,80 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VespaRetriever = void 0;
4
- const document_js_1 = require("../document.cjs");
5
- const base_js_1 = require("./remote/base.cjs");
6
- /**
7
- * Class responsible for retrieving data from Vespa. It extends the
8
- * `RemoteRetriever` class and includes methods for creating the JSON body
9
- * for a query and processing the JSON response from Vespa.
10
- * @example
11
- * ```typescript
12
- * const retriever = new VespaRetriever({
13
- * url: "https:
14
- * auth: false,
15
- * query_body: {
16
- * yql: "select content from paragraph where userQuery()",
17
- * hits: 5,
18
- * ranking: "documentation",
19
- * locale: "en-us",
20
- * },
21
- * content_field: "content",
22
- * });
23
- * const result = await retriever.getRelevantDocuments("what is vespa?");
24
- * ```
25
- */
26
- class VespaRetriever extends base_js_1.RemoteRetriever {
27
- static lc_name() {
28
- return "VespaRetriever";
29
- }
30
- constructor(fields) {
31
- super(fields);
32
- Object.defineProperty(this, "lc_namespace", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: ["langchain", "retrievers", "vespa"]
37
- });
38
- Object.defineProperty(this, "query_body", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "content_field", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- this.query_body = fields.query_body;
51
- this.content_field = fields.content_field;
52
- this.url = `${this.url}/search/?`;
53
- }
54
- /**
55
- * Method that takes a query string as input and returns a JSON object
56
- * that includes the query and the original `query_body`.
57
- * @param query The query string to be sent to Vespa.
58
- * @returns A JSON object that includes the query and the original `query_body`.
59
- */
60
- createJsonBody(query) {
61
- return {
62
- ...this.query_body,
63
- query,
64
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
65
7
  }
66
- /**
67
- * Method that processes the JSON response from Vespa into an array of
68
- * `Document` instances. Each `Document` instance includes the content
69
- * from the specified `content_field` and the document's ID.
70
- * @param json The JSON response from Vespa.
71
- * @returns An array of `Document` instances.
72
- */
73
- processJsonResponse(json) {
74
- return json.root.children.map((doc) => new document_js_1.Document({
75
- pageContent: doc.fields[this.content_field],
76
- metadata: { id: doc.id },
77
- }));
78
- }
79
- }
80
- exports.VespaRetriever = VespaRetriever;
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@langchain/community/retrievers/vespa"), exports);
@@ -1,54 +1 @@
1
- import { Document } from "../document.js";
2
- import { RemoteRetriever, RemoteRetrieverValues, RemoteRetrieverParams } from "./remote/base.js";
3
- export interface VespaRetrieverParams extends RemoteRetrieverParams {
4
- /**
5
- * The body of the query to send to Vespa
6
- */
7
- query_body: object;
8
- /**
9
- * The name of the field the content resides in
10
- */
11
- content_field: string;
12
- }
13
- /**
14
- * Class responsible for retrieving data from Vespa. It extends the
15
- * `RemoteRetriever` class and includes methods for creating the JSON body
16
- * for a query and processing the JSON response from Vespa.
17
- * @example
18
- * ```typescript
19
- * const retriever = new VespaRetriever({
20
- * url: "https:
21
- * auth: false,
22
- * query_body: {
23
- * yql: "select content from paragraph where userQuery()",
24
- * hits: 5,
25
- * ranking: "documentation",
26
- * locale: "en-us",
27
- * },
28
- * content_field: "content",
29
- * });
30
- * const result = await retriever.getRelevantDocuments("what is vespa?");
31
- * ```
32
- */
33
- export declare class VespaRetriever extends RemoteRetriever {
34
- static lc_name(): string;
35
- lc_namespace: string[];
36
- query_body: object;
37
- content_field: string;
38
- constructor(fields: VespaRetrieverParams);
39
- /**
40
- * Method that takes a query string as input and returns a JSON object
41
- * that includes the query and the original `query_body`.
42
- * @param query The query string to be sent to Vespa.
43
- * @returns A JSON object that includes the query and the original `query_body`.
44
- */
45
- createJsonBody(query: string): RemoteRetrieverValues;
46
- /**
47
- * Method that processes the JSON response from Vespa into an array of
48
- * `Document` instances. Each `Document` instance includes the content
49
- * from the specified `content_field` and the document's ID.
50
- * @param json The JSON response from Vespa.
51
- * @returns An array of `Document` instances.
52
- */
53
- processJsonResponse(json: RemoteRetrieverValues): Document[];
54
- }
1
+ export * from "@langchain/community/retrievers/vespa";
@@ -1,76 +1 @@
1
- import { Document } from "../document.js";
2
- import { RemoteRetriever, } from "./remote/base.js";
3
- /**
4
- * Class responsible for retrieving data from Vespa. It extends the
5
- * `RemoteRetriever` class and includes methods for creating the JSON body
6
- * for a query and processing the JSON response from Vespa.
7
- * @example
8
- * ```typescript
9
- * const retriever = new VespaRetriever({
10
- * url: "https:
11
- * auth: false,
12
- * query_body: {
13
- * yql: "select content from paragraph where userQuery()",
14
- * hits: 5,
15
- * ranking: "documentation",
16
- * locale: "en-us",
17
- * },
18
- * content_field: "content",
19
- * });
20
- * const result = await retriever.getRelevantDocuments("what is vespa?");
21
- * ```
22
- */
23
- export class VespaRetriever extends RemoteRetriever {
24
- static lc_name() {
25
- return "VespaRetriever";
26
- }
27
- constructor(fields) {
28
- super(fields);
29
- Object.defineProperty(this, "lc_namespace", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: ["langchain", "retrievers", "vespa"]
34
- });
35
- Object.defineProperty(this, "query_body", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "content_field", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- this.query_body = fields.query_body;
48
- this.content_field = fields.content_field;
49
- this.url = `${this.url}/search/?`;
50
- }
51
- /**
52
- * Method that takes a query string as input and returns a JSON object
53
- * that includes the query and the original `query_body`.
54
- * @param query The query string to be sent to Vespa.
55
- * @returns A JSON object that includes the query and the original `query_body`.
56
- */
57
- createJsonBody(query) {
58
- return {
59
- ...this.query_body,
60
- query,
61
- };
62
- }
63
- /**
64
- * Method that processes the JSON response from Vespa into an array of
65
- * `Document` instances. Each `Document` instance includes the content
66
- * from the specified `content_field` and the document's ID.
67
- * @param json The JSON response from Vespa.
68
- * @returns An array of `Document` instances.
69
- */
70
- processJsonResponse(json) {
71
- return json.root.children.map((doc) => new Document({
72
- pageContent: doc.fields[this.content_field],
73
- metadata: { id: doc.id },
74
- }));
75
- }
76
- }
1
+ export * from "@langchain/community/retrievers/vespa";
@@ -1 +1 @@
1
- export { getCallbackMangerForConfig, RunnableConfig, } from "@langchain/core/runnables";
1
+ export { RunnableConfig } from "@langchain/core/runnables";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logVersion010MigrationWarning = void 0;
4
+ function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName = "@langchain/community", }) {
5
+ /* #__PURE__ */ console.warn([
6
+ `[WARNING]: Importing from "langchain/${oldEntrypointName}" is deprecated.\n`,
7
+ `Instead, please add the "${newPackageName}" package to your project with e.g.`,
8
+ ``,
9
+ ` $ npm install ${newPackageName}`,
10
+ ``,
11
+ `and import from "${newPackageName}${newEntrypointName === undefined
12
+ ? `/${oldEntrypointName}`
13
+ : newEntrypointName}".`,
14
+ ``,
15
+ `This will be mandatory after the next "langchain" minor version bump to 0.2.`,
16
+ ].join("\n"));
17
+ }
18
+ exports.logVersion010MigrationWarning = logVersion010MigrationWarning;
@@ -0,0 +1,5 @@
1
+ export declare function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName, }: {
2
+ oldEntrypointName: string;
3
+ newEntrypointName?: string;
4
+ newPackageName?: string;
5
+ }): void;
@@ -0,0 +1,14 @@
1
+ export function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName = "@langchain/community", }) {
2
+ /* #__PURE__ */ console.warn([
3
+ `[WARNING]: Importing from "langchain/${oldEntrypointName}" is deprecated.\n`,
4
+ `Instead, please add the "${newPackageName}" package to your project with e.g.`,
5
+ ``,
6
+ ` $ npm install ${newPackageName}`,
7
+ ``,
8
+ `and import from "${newPackageName}${newEntrypointName === undefined
9
+ ? `/${oldEntrypointName}`
10
+ : newEntrypointName}".`,
11
+ ``,
12
+ `This will be mandatory after the next "langchain" minor version bump to 0.2.`,
13
+ ].join("\n"));
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.213",
3
+ "version": "0.0.214",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1190,7 +1190,7 @@
1190
1190
  },
1191
1191
  "dependencies": {
1192
1192
  "@anthropic-ai/sdk": "^0.9.1",
1193
- "@langchain/community": "~0.0.12",
1193
+ "@langchain/community": "~0.0.13",
1194
1194
  "@langchain/core": "~0.1.5",
1195
1195
  "@langchain/openai": "~0.0.9",
1196
1196
  "binary-extensions": "^2.2.0",
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@langchain/core/tracers/tracer_langchain_v1"), exports);
@@ -1 +0,0 @@
1
- export * from "@langchain/core/tracers/tracer_langchain_v1";
@@ -1 +0,0 @@
1
- export * from "@langchain/core/tracers/tracer_langchain_v1";
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteRetriever = void 0;
4
- const retrievers_1 = require("@langchain/core/retrievers");
5
- const async_caller_js_1 = require("../../util/async_caller.cjs");
6
- /**
7
- * Abstract class for interacting with a remote server to retrieve
8
- * relevant documents based on a given query.
9
- */
10
- class RemoteRetriever extends retrievers_1.BaseRetriever {
11
- get lc_secrets() {
12
- return {
13
- "auth.bearer": "REMOTE_RETRIEVER_AUTH_BEARER",
14
- };
15
- }
16
- constructor(fields) {
17
- super(fields);
18
- Object.defineProperty(this, "url", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- Object.defineProperty(this, "auth", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: void 0
29
- });
30
- Object.defineProperty(this, "headers", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
36
- Object.defineProperty(this, "asyncCaller", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- const { url, auth, ...rest } = fields;
43
- this.url = url;
44
- this.auth = auth;
45
- this.headers = {
46
- Accept: "application/json",
47
- "Content-Type": "application/json",
48
- ...(this.auth && this.auth.bearer
49
- ? { Authorization: `Bearer ${this.auth.bearer}` }
50
- : {}),
51
- };
52
- this.asyncCaller = new async_caller_js_1.AsyncCaller(rest);
53
- }
54
- async _getRelevantDocuments(query) {
55
- const body = this.createJsonBody(query);
56
- const response = await this.asyncCaller.call(() => fetch(this.url, {
57
- method: "POST",
58
- headers: this.headers,
59
- body: JSON.stringify(body),
60
- }));
61
- if (!response.ok) {
62
- throw new Error(`Failed to retrieve documents from ${this.url}: ${response.status} ${response.statusText}`);
63
- }
64
- const json = await response.json();
65
- return this.processJsonResponse(json);
66
- }
67
- }
68
- exports.RemoteRetriever = RemoteRetriever;