langchain 0.0.154 → 0.0.156

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 (78) hide show
  1. package/chat_models/bedrock.cjs +1 -0
  2. package/chat_models/bedrock.d.ts +1 -0
  3. package/chat_models/bedrock.js +1 -0
  4. package/dist/callbacks/base.d.ts +42 -28
  5. package/dist/callbacks/handlers/log_stream.cjs +283 -0
  6. package/dist/callbacks/handlers/log_stream.d.ts +99 -0
  7. package/dist/callbacks/handlers/log_stream.js +277 -0
  8. package/dist/callbacks/handlers/tracer.cjs +34 -18
  9. package/dist/callbacks/handlers/tracer.d.ts +18 -16
  10. package/dist/callbacks/handlers/tracer.js +34 -18
  11. package/dist/chat_models/bedrock.cjs +260 -0
  12. package/dist/chat_models/bedrock.d.ts +58 -0
  13. package/dist/chat_models/bedrock.js +254 -0
  14. package/dist/document_loaders/web/notionapi.cjs +8 -4
  15. package/dist/document_loaders/web/notionapi.js +8 -4
  16. package/dist/document_loaders/web/searchapi.cjs +134 -0
  17. package/dist/document_loaders/web/searchapi.d.ts +65 -0
  18. package/dist/document_loaders/web/searchapi.js +130 -0
  19. package/dist/embeddings/cloudflare_workersai.cjs +69 -0
  20. package/dist/embeddings/cloudflare_workersai.d.ts +28 -0
  21. package/dist/embeddings/cloudflare_workersai.js +65 -0
  22. package/dist/llms/bedrock.cjs +57 -67
  23. package/dist/llms/bedrock.d.ts +8 -35
  24. package/dist/llms/bedrock.js +57 -67
  25. package/dist/load/import_constants.cjs +4 -0
  26. package/dist/load/import_constants.js +4 -0
  27. package/dist/load/import_map.cjs +3 -2
  28. package/dist/load/import_map.d.ts +1 -0
  29. package/dist/load/import_map.js +1 -0
  30. package/dist/schema/runnable/base.cjs +64 -5
  31. package/dist/schema/runnable/base.d.ts +13 -0
  32. package/dist/schema/runnable/base.js +64 -5
  33. package/dist/tools/index.cjs +3 -1
  34. package/dist/tools/index.d.ts +1 -0
  35. package/dist/tools/index.js +1 -0
  36. package/dist/tools/searchapi.cjs +139 -0
  37. package/dist/tools/searchapi.d.ts +64 -0
  38. package/dist/tools/searchapi.js +135 -0
  39. package/dist/util/bedrock.cjs +54 -0
  40. package/dist/util/bedrock.d.ts +59 -0
  41. package/dist/util/bedrock.js +50 -0
  42. package/dist/util/fast-json-patch/index.cjs +48 -0
  43. package/dist/util/fast-json-patch/index.d.ts +21 -0
  44. package/dist/util/fast-json-patch/index.js +15 -0
  45. package/dist/util/fast-json-patch/src/core.cjs +469 -0
  46. package/dist/util/fast-json-patch/src/core.d.ts +111 -0
  47. package/dist/util/fast-json-patch/src/core.js +459 -0
  48. package/dist/util/fast-json-patch/src/helpers.cjs +194 -0
  49. package/dist/util/fast-json-patch/src/helpers.d.ts +36 -0
  50. package/dist/util/fast-json-patch/src/helpers.js +181 -0
  51. package/dist/util/googlevertexai-webauth.cjs +6 -2
  52. package/dist/util/googlevertexai-webauth.d.ts +1 -0
  53. package/dist/util/googlevertexai-webauth.js +6 -2
  54. package/dist/util/stream.cjs +2 -40
  55. package/dist/util/stream.d.ts +1 -2
  56. package/dist/util/stream.js +1 -38
  57. package/dist/vectorstores/cloudflare_vectorize.cjs +200 -0
  58. package/dist/vectorstores/cloudflare_vectorize.d.ts +90 -0
  59. package/dist/vectorstores/cloudflare_vectorize.js +173 -0
  60. package/dist/vectorstores/pgvector.cjs +1 -1
  61. package/dist/vectorstores/pgvector.js +1 -1
  62. package/dist/vectorstores/supabase.d.ts +1 -1
  63. package/dist/vectorstores/vercel_postgres.cjs +300 -0
  64. package/dist/vectorstores/vercel_postgres.d.ts +145 -0
  65. package/dist/vectorstores/vercel_postgres.js +296 -0
  66. package/document_loaders/web/searchapi.cjs +1 -0
  67. package/document_loaders/web/searchapi.d.ts +1 -0
  68. package/document_loaders/web/searchapi.js +1 -0
  69. package/embeddings/cloudflare_workersai.cjs +1 -0
  70. package/embeddings/cloudflare_workersai.d.ts +1 -0
  71. package/embeddings/cloudflare_workersai.js +1 -0
  72. package/package.json +60 -14
  73. package/vectorstores/cloudflare_vectorize.cjs +1 -0
  74. package/vectorstores/cloudflare_vectorize.d.ts +1 -0
  75. package/vectorstores/cloudflare_vectorize.js +1 -0
  76. package/vectorstores/vercel_postgres.cjs +1 -0
  77. package/vectorstores/vercel_postgres.d.ts +1 -0
  78. package/vectorstores/vercel_postgres.js +1 -0
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BedrockLLMInputOutputAdapter = void 0;
4
+ /**
5
+ * A helper class used within the `Bedrock` class. It is responsible for
6
+ * preparing the input and output for the Bedrock service. It formats the
7
+ * input prompt based on the provider (e.g., "anthropic", "ai21",
8
+ * "amazon") and extracts the generated text from the service response.
9
+ */
10
+ class BedrockLLMInputOutputAdapter {
11
+ /** Adapter class to prepare the inputs from Langchain to a format
12
+ that LLM model expects. Also, provides a helper function to extract
13
+ the generated text from the model response. */
14
+ static prepareInput(provider, prompt, maxTokens = 50, temperature = 0, stopSequences = undefined, modelKwargs = {}) {
15
+ const inputBody = {};
16
+ if (provider === "anthropic") {
17
+ inputBody.prompt = prompt;
18
+ inputBody.max_tokens_to_sample = maxTokens;
19
+ inputBody.temperature = temperature;
20
+ inputBody.stop_sequences = stopSequences;
21
+ }
22
+ else if (provider === "ai21") {
23
+ inputBody.prompt = prompt;
24
+ inputBody.maxTokens = maxTokens;
25
+ inputBody.temperature = temperature;
26
+ inputBody.stopSequences = stopSequences;
27
+ }
28
+ else if (provider === "amazon") {
29
+ inputBody.inputText = prompt;
30
+ inputBody.textGenerationConfig = {
31
+ maxTokenCount: maxTokens,
32
+ temperature,
33
+ };
34
+ }
35
+ return { ...inputBody, ...modelKwargs };
36
+ }
37
+ /**
38
+ * Extracts the generated text from the service response.
39
+ * @param provider The provider name.
40
+ * @param responseBody The response body from the service.
41
+ * @returns The generated text.
42
+ */
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ static prepareOutput(provider, responseBody) {
45
+ if (provider === "anthropic") {
46
+ return responseBody.completion;
47
+ }
48
+ else if (provider === "ai21") {
49
+ return responseBody?.completions?.[0]?.data?.text ?? "";
50
+ }
51
+ return responseBody.outputText;
52
+ }
53
+ }
54
+ exports.BedrockLLMInputOutputAdapter = BedrockLLMInputOutputAdapter;
@@ -0,0 +1,59 @@
1
+ import type { AwsCredentialIdentity, Provider } from "@aws-sdk/types";
2
+ export type CredentialType = AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
3
+ /** Bedrock models.
4
+ To authenticate, the AWS client uses the following methods to automatically load credentials:
5
+ https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
6
+ If a specific credential profile should be used, you must pass the name of the profile from the ~/.aws/credentials file that is to be used.
7
+ Make sure the credentials / roles used have the required policies to access the Bedrock service.
8
+ */
9
+ export interface BaseBedrockInput {
10
+ /** Model to use.
11
+ For example, "amazon.titan-tg1-large", this is equivalent to the modelId property in the list-foundation-models api.
12
+ */
13
+ model: string;
14
+ /** The AWS region e.g. `us-west-2`.
15
+ Fallback to AWS_DEFAULT_REGION env variable or region specified in ~/.aws/config in case it is not provided here.
16
+ */
17
+ region?: string;
18
+ /** AWS Credentials.
19
+ If no credentials are provided, the default credentials from `@aws-sdk/credential-provider-node` will be used.
20
+ */
21
+ credentials?: CredentialType;
22
+ /** Temperature. */
23
+ temperature?: number;
24
+ /** Max tokens. */
25
+ maxTokens?: number;
26
+ /** A custom fetch function for low-level access to AWS API. Defaults to fetch(). */
27
+ fetchFn?: typeof fetch;
28
+ /** @deprecated Use endpointHost instead Override the default endpoint url. */
29
+ endpointUrl?: string;
30
+ /** Override the default endpoint hostname. */
31
+ endpointHost?: string;
32
+ /** Optional additional stop sequences to pass to the model. Currently only supported for Anthropic and AI21. */
33
+ stopSequences?: string[];
34
+ /** Additional kwargs to pass to the model. */
35
+ modelKwargs?: Record<string, unknown>;
36
+ }
37
+ type Dict = {
38
+ [key: string]: unknown;
39
+ };
40
+ /**
41
+ * A helper class used within the `Bedrock` class. It is responsible for
42
+ * preparing the input and output for the Bedrock service. It formats the
43
+ * input prompt based on the provider (e.g., "anthropic", "ai21",
44
+ * "amazon") and extracts the generated text from the service response.
45
+ */
46
+ export declare class BedrockLLMInputOutputAdapter {
47
+ /** Adapter class to prepare the inputs from Langchain to a format
48
+ that LLM model expects. Also, provides a helper function to extract
49
+ the generated text from the model response. */
50
+ static prepareInput(provider: string, prompt: string, maxTokens?: number, temperature?: number, stopSequences?: string[] | undefined, modelKwargs?: Record<string, unknown>): Dict;
51
+ /**
52
+ * Extracts the generated text from the service response.
53
+ * @param provider The provider name.
54
+ * @param responseBody The response body from the service.
55
+ * @returns The generated text.
56
+ */
57
+ static prepareOutput(provider: string, responseBody: any): string;
58
+ }
59
+ export {};
@@ -0,0 +1,50 @@
1
+ /**
2
+ * A helper class used within the `Bedrock` class. It is responsible for
3
+ * preparing the input and output for the Bedrock service. It formats the
4
+ * input prompt based on the provider (e.g., "anthropic", "ai21",
5
+ * "amazon") and extracts the generated text from the service response.
6
+ */
7
+ export class BedrockLLMInputOutputAdapter {
8
+ /** Adapter class to prepare the inputs from Langchain to a format
9
+ that LLM model expects. Also, provides a helper function to extract
10
+ the generated text from the model response. */
11
+ static prepareInput(provider, prompt, maxTokens = 50, temperature = 0, stopSequences = undefined, modelKwargs = {}) {
12
+ const inputBody = {};
13
+ if (provider === "anthropic") {
14
+ inputBody.prompt = prompt;
15
+ inputBody.max_tokens_to_sample = maxTokens;
16
+ inputBody.temperature = temperature;
17
+ inputBody.stop_sequences = stopSequences;
18
+ }
19
+ else if (provider === "ai21") {
20
+ inputBody.prompt = prompt;
21
+ inputBody.maxTokens = maxTokens;
22
+ inputBody.temperature = temperature;
23
+ inputBody.stopSequences = stopSequences;
24
+ }
25
+ else if (provider === "amazon") {
26
+ inputBody.inputText = prompt;
27
+ inputBody.textGenerationConfig = {
28
+ maxTokenCount: maxTokens,
29
+ temperature,
30
+ };
31
+ }
32
+ return { ...inputBody, ...modelKwargs };
33
+ }
34
+ /**
35
+ * Extracts the generated text from the service response.
36
+ * @param provider The provider name.
37
+ * @param responseBody The response body from the service.
38
+ * @returns The generated text.
39
+ */
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ static prepareOutput(provider, responseBody) {
42
+ if (provider === "anthropic") {
43
+ return responseBody.completion;
44
+ }
45
+ else if (provider === "ai21") {
46
+ return responseBody?.completions?.[0]?.data?.text ?? "";
47
+ }
48
+ return responseBody.outputText;
49
+ }
50
+ }
@@ -0,0 +1,48 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.unescapePathComponent = exports.escapePathComponent = exports.deepClone = exports.JsonPatchError = void 0;
30
+ __exportStar(require("./src/core.cjs"), exports);
31
+ var helpers_js_1 = require("./src/helpers.cjs");
32
+ Object.defineProperty(exports, "JsonPatchError", { enumerable: true, get: function () { return helpers_js_1.PatchError; } });
33
+ Object.defineProperty(exports, "deepClone", { enumerable: true, get: function () { return helpers_js_1._deepClone; } });
34
+ Object.defineProperty(exports, "escapePathComponent", { enumerable: true, get: function () { return helpers_js_1.escapePathComponent; } });
35
+ Object.defineProperty(exports, "unescapePathComponent", { enumerable: true, get: function () { return helpers_js_1.unescapePathComponent; } });
36
+ /**
37
+ * Default export for backwards compat
38
+ */
39
+ const core = __importStar(require("./src/core.cjs"));
40
+ const helpers_js_2 = require("./src/helpers.cjs");
41
+ exports.default = {
42
+ ...core,
43
+ // ...duplex,
44
+ JsonPatchError: helpers_js_2.PatchError,
45
+ deepClone: helpers_js_2._deepClone,
46
+ escapePathComponent: helpers_js_2.escapePathComponent,
47
+ unescapePathComponent: helpers_js_2.unescapePathComponent,
48
+ };
@@ -0,0 +1,21 @@
1
+ export * from "./src/core.js";
2
+ export { PatchError as JsonPatchError, _deepClone as deepClone, escapePathComponent, unescapePathComponent, } from "./src/helpers.js";
3
+ /**
4
+ * Default export for backwards compat
5
+ */
6
+ import * as core from "./src/core.js";
7
+ import { PatchError as JsonPatchError, _deepClone as deepClone, escapePathComponent, unescapePathComponent } from "./src/helpers.js";
8
+ declare const _default: {
9
+ JsonPatchError: typeof JsonPatchError;
10
+ deepClone: typeof deepClone;
11
+ escapePathComponent: typeof escapePathComponent;
12
+ unescapePathComponent: typeof unescapePathComponent;
13
+ getValueByPointer(document: any, pointer: string): any;
14
+ applyOperation<T>(document: T, operation: core.Operation, validateOperation?: boolean | core.Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean, index?: number): core.OperationResult<T>;
15
+ applyPatch<T_1>(document: T_1, patch: readonly core.Operation[], validateOperation?: boolean | core.Validator<T_1> | undefined, mutateDocument?: boolean, banPrototypeModifications?: boolean): core.PatchResult<T_1>;
16
+ applyReducer<T_2>(document: T_2, operation: core.Operation, index: number): T_2;
17
+ validator(operation: core.Operation, index: number, document?: any, existingPathFragment?: string | undefined): void;
18
+ validate<T_3>(sequence: readonly core.Operation[], document?: T_3 | undefined, externalValidator?: core.Validator<T_3> | undefined): JsonPatchError;
19
+ _areEquals(a: any, b: any): boolean;
20
+ };
21
+ export default _default;
@@ -0,0 +1,15 @@
1
+ export * from "./src/core.js";
2
+ export { PatchError as JsonPatchError, _deepClone as deepClone, escapePathComponent, unescapePathComponent, } from "./src/helpers.js";
3
+ /**
4
+ * Default export for backwards compat
5
+ */
6
+ import * as core from "./src/core.js";
7
+ import { PatchError as JsonPatchError, _deepClone as deepClone, escapePathComponent, unescapePathComponent, } from "./src/helpers.js";
8
+ export default {
9
+ ...core,
10
+ // ...duplex,
11
+ JsonPatchError,
12
+ deepClone,
13
+ escapePathComponent,
14
+ unescapePathComponent,
15
+ };