langchain 0.0.168 → 0.0.170

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 (107) hide show
  1. package/README.md +2 -2
  2. package/agents/format_scratchpad.cjs +1 -0
  3. package/agents/format_scratchpad.d.ts +1 -0
  4. package/agents/format_scratchpad.js +1 -0
  5. package/chat_models/yandex.cjs +1 -0
  6. package/chat_models/yandex.d.ts +1 -0
  7. package/chat_models/yandex.js +1 -0
  8. package/dist/agents/agent.cjs +49 -1
  9. package/dist/agents/agent.d.ts +19 -1
  10. package/dist/agents/agent.js +47 -0
  11. package/dist/agents/executor.cjs +10 -1
  12. package/dist/agents/executor.d.ts +22 -8
  13. package/dist/agents/executor.js +11 -2
  14. package/dist/agents/format_scratchpad.cjs +25 -0
  15. package/dist/agents/format_scratchpad.d.ts +10 -0
  16. package/dist/agents/format_scratchpad.js +21 -0
  17. package/dist/agents/toolkits/aws_sfn.d.ts +4 -1
  18. package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +1 -1
  19. package/dist/agents/toolkits/json/json.d.ts +4 -1
  20. package/dist/agents/toolkits/openapi/openapi.cjs +8 -0
  21. package/dist/agents/toolkits/openapi/openapi.d.ts +12 -1
  22. package/dist/agents/toolkits/openapi/openapi.js +8 -0
  23. package/dist/agents/toolkits/sql/sql.d.ts +4 -1
  24. package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +8 -2
  25. package/dist/agents/types.d.ts +13 -1
  26. package/dist/callbacks/handlers/llmonitor.cjs +21 -17
  27. package/dist/callbacks/handlers/llmonitor.js +21 -17
  28. package/dist/chains/sql_db/sql_db_chain.cjs +9 -0
  29. package/dist/chains/sql_db/sql_db_chain.d.ts +9 -0
  30. package/dist/chains/sql_db/sql_db_chain.js +9 -0
  31. package/dist/chat_models/baiduwenxin.cjs +12 -1
  32. package/dist/chat_models/baiduwenxin.d.ts +3 -1
  33. package/dist/chat_models/baiduwenxin.js +12 -1
  34. package/dist/chat_models/cloudflare_workersai.cjs +7 -2
  35. package/dist/chat_models/cloudflare_workersai.d.ts +1 -1
  36. package/dist/chat_models/cloudflare_workersai.js +7 -2
  37. package/dist/chat_models/yandex.cjs +117 -0
  38. package/dist/chat_models/yandex.d.ts +16 -0
  39. package/dist/chat_models/yandex.js +113 -0
  40. package/dist/document_loaders/web/assemblyai.cjs +63 -114
  41. package/dist/document_loaders/web/assemblyai.d.ts +38 -57
  42. package/dist/document_loaders/web/assemblyai.js +63 -100
  43. package/dist/evaluation/comparison/prompt.d.ts +2 -2
  44. package/dist/experimental/chains/violation_of_expectations/index.cjs +5 -0
  45. package/dist/experimental/chains/violation_of_expectations/index.d.ts +1 -0
  46. package/dist/experimental/chains/violation_of_expectations/index.js +1 -0
  47. package/dist/experimental/chains/violation_of_expectations/types.cjs +49 -0
  48. package/dist/experimental/chains/violation_of_expectations/types.d.ts +69 -0
  49. package/dist/experimental/chains/violation_of_expectations/types.js +46 -0
  50. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.cjs +328 -0
  51. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts +148 -0
  52. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.js +324 -0
  53. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.cjs +49 -0
  54. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.d.ts +5 -0
  55. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.js +46 -0
  56. package/dist/llms/cloudflare_workersai.cjs +14 -7
  57. package/dist/llms/cloudflare_workersai.d.ts +1 -1
  58. package/dist/llms/cloudflare_workersai.js +14 -7
  59. package/dist/load/import_constants.cjs +1 -0
  60. package/dist/load/import_constants.js +1 -0
  61. package/dist/load/import_map.cjs +5 -2
  62. package/dist/load/import_map.d.ts +3 -0
  63. package/dist/load/import_map.js +3 -0
  64. package/dist/memory/index.d.ts +1 -1
  65. package/dist/memory/index.js +1 -1
  66. package/dist/retrievers/time_weighted.cjs +1 -1
  67. package/dist/retrievers/time_weighted.d.ts +1 -1
  68. package/dist/retrievers/time_weighted.js +1 -1
  69. package/dist/retrievers/zep.cjs +29 -3
  70. package/dist/retrievers/zep.d.ts +14 -0
  71. package/dist/retrievers/zep.js +29 -3
  72. package/dist/schema/runnable/base.cjs +4 -1
  73. package/dist/schema/runnable/base.d.ts +1 -0
  74. package/dist/schema/runnable/base.js +4 -1
  75. package/dist/schema/runnable/passthrough.cjs +33 -1
  76. package/dist/schema/runnable/passthrough.d.ts +11 -1
  77. package/dist/schema/runnable/passthrough.js +32 -1
  78. package/dist/sql_db.cjs +12 -0
  79. package/dist/sql_db.d.ts +12 -0
  80. package/dist/sql_db.js +12 -0
  81. package/dist/storage/ioredis.cjs +2 -1
  82. package/dist/storage/ioredis.js +2 -1
  83. package/dist/storage/upstash_redis.cjs +155 -0
  84. package/dist/storage/upstash_redis.d.ts +59 -0
  85. package/dist/storage/upstash_redis.js +151 -0
  86. package/dist/storage/vercel_kv.cjs +2 -1
  87. package/dist/storage/vercel_kv.js +2 -1
  88. package/dist/types/assemblyai-types.cjs +0 -150
  89. package/dist/types/assemblyai-types.d.ts +4 -670
  90. package/dist/types/assemblyai-types.js +1 -149
  91. package/dist/vectorstores/faiss.cjs +38 -6
  92. package/dist/vectorstores/faiss.d.ts +14 -2
  93. package/dist/vectorstores/faiss.js +38 -6
  94. package/dist/vectorstores/pgvector.cjs +1 -1
  95. package/dist/vectorstores/pgvector.js +1 -1
  96. package/dist/vectorstores/weaviate.cjs +13 -2
  97. package/dist/vectorstores/weaviate.js +13 -2
  98. package/experimental/chains/violation_of_expectations.cjs +1 -0
  99. package/experimental/chains/violation_of_expectations.d.ts +1 -0
  100. package/experimental/chains/violation_of_expectations.js +1 -0
  101. package/package.json +47 -10
  102. package/storage/upstash_redis.cjs +1 -0
  103. package/storage/upstash_redis.d.ts +1 -0
  104. package/storage/upstash_redis.js +1 -0
  105. package/dist/util/assemblyai-client.cjs +0 -173
  106. package/dist/util/assemblyai-client.d.ts +0 -63
  107. package/dist/util/assemblyai-client.js +0 -170
@@ -1,173 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AssemblyAIClient = void 0;
4
- const assemblyai_types_js_1 = require("../types/assemblyai-types.cjs");
5
- /**
6
- * A client for the AssemblyAI API.
7
- */
8
- class AssemblyAIClient {
9
- /**
10
- * @param apiKey The API key for the AssemblyAI API.
11
- */
12
- constructor(apiKey) {
13
- Object.defineProperty(this, "apiKey", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: apiKey
18
- });
19
- if (!apiKey)
20
- throw new Error("No AssemblyAI API key provided");
21
- }
22
- /**
23
- * Uploads a file to AssemblyAI CDN.
24
- * The file will only be accessible to AssemblyAI and be removed after a period of time.
25
- * @param file Audio or video file to upload.
26
- * @returns The URL of the uploaded file.
27
- */
28
- async uploadFile(file) {
29
- const response = await fetch(`${AssemblyAIClient.baseUrl}/upload`, {
30
- method: "POST",
31
- headers: {
32
- authorization: this.apiKey,
33
- },
34
- body: file,
35
- });
36
- const json = (await response.json());
37
- AssemblyAIClient.throwIfError(json);
38
- return json.upload_url;
39
- }
40
- /**
41
- * Creates a transcript in the AssemblyAI API. The transcript will be queued for processing,
42
- * but an empty transcript object is returned immediately.
43
- * @param fileUrl The URL of the audio or video file to transcribe.
44
- * @returns Empty transcript object
45
- */
46
- async createTranscript(params) {
47
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript`, {
48
- method: "POST",
49
- headers: {
50
- authorization: this.apiKey,
51
- "Content-Type": "application/json",
52
- },
53
- body: JSON.stringify(params),
54
- });
55
- const transcript = (await response.json());
56
- AssemblyAIClient.throwIfError(transcript);
57
- return transcript;
58
- }
59
- /**
60
- * Gets the transcript by its ID.
61
- * @param id The ID of the transcript to retrieve.
62
- * @returns Transcript object
63
- */
64
- async getTranscript(id) {
65
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}`, {
66
- headers: {
67
- authorization: this.apiKey,
68
- },
69
- });
70
- const transcript = (await response.json());
71
- AssemblyAIClient.throwIfError(transcript);
72
- return transcript;
73
- }
74
- /**
75
- * Polls the transcript status until it is completed, then returns the completed transcript object.
76
- * @param id The ID of the transcript to retrieve.
77
- * @returns Transcript object
78
- */
79
- async waitForTranscriptToComplete(id) {
80
- const pollingEndpoint = `${AssemblyAIClient.baseUrl}/transcript/${id}`;
81
- // infinite loop, same as while(true) but linter doesn't like using true constant
82
- for (;;) {
83
- const pollingResponse = await fetch(pollingEndpoint, {
84
- headers: {
85
- authorization: this.apiKey,
86
- },
87
- });
88
- const transcript = (await pollingResponse.json());
89
- AssemblyAIClient.throwIfError(transcript);
90
- switch (transcript.status) {
91
- case "queued":
92
- case "processing":
93
- await new Promise((resolve) => {
94
- setTimeout(resolve, 3000);
95
- });
96
- break;
97
- case "completed":
98
- return transcript;
99
- default:
100
- throw new Error(`Unexpected transcript status: ${transcript.status}`);
101
- }
102
- }
103
- }
104
- /**
105
- * Gets the paragraphs of the transcript in the specified format.
106
- * @param id The ID of the transcript to retrieve paragraphs fors.
107
- * @returns Paragraphs for the transcript.
108
- */
109
- async getParagraphs(id) {
110
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/paragraphs`, {
111
- headers: {
112
- authorization: this.apiKey,
113
- },
114
- });
115
- const paragraphs = (await response.json());
116
- AssemblyAIClient.throwIfError(paragraphs);
117
- return paragraphs;
118
- }
119
- /**
120
- * Gets the paragraphs of the transcript in the specified format.
121
- * @param id The ID of the transcript to retrieve paragraphs fors.
122
- * @returns Paragraphs for the transcript.
123
- */
124
- async getSentences(id) {
125
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/sentences`, {
126
- headers: {
127
- authorization: this.apiKey,
128
- },
129
- });
130
- const sentences = (await response.json());
131
- AssemblyAIClient.throwIfError(sentences);
132
- return sentences;
133
- }
134
- /**
135
- * Gets the subtitles of the transcript in the specified format.
136
- * @param id The ID of the transcript to retrieve.
137
- * @param subtitleFormat Format of the subtitles to retrieve.
138
- * @returns Subtitles in the specified format as text.
139
- */
140
- async getSubtitles(id, subtitleFormat = assemblyai_types_js_1.SubtitleFormat.Srt) {
141
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/${subtitleFormat}`, {
142
- headers: {
143
- authorization: this.apiKey,
144
- },
145
- });
146
- if (response.status !== 200) {
147
- if (response.headers.get("content-type")?.startsWith("application/json")) {
148
- const errorBody = (await response.json());
149
- AssemblyAIClient.throwIfError(errorBody);
150
- }
151
- else {
152
- throw new Error(`Get Subtitle request returned status ${response.status} ${response.statusText}`);
153
- }
154
- }
155
- const subtitles = await response.text();
156
- return subtitles;
157
- }
158
- /**
159
- * Throws an error if the body is an error object.
160
- * @param body The response object returned by the AssemblyAI API to check.
161
- */
162
- static throwIfError(body) {
163
- if ("error" in body)
164
- throw new Error(body.error);
165
- }
166
- }
167
- Object.defineProperty(AssemblyAIClient, "baseUrl", {
168
- enumerable: true,
169
- configurable: true,
170
- writable: true,
171
- value: "https://api.assemblyai.com/v2"
172
- });
173
- exports.AssemblyAIClient = AssemblyAIClient;
@@ -1,63 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { CreateTranscriptParams, ParagraphsResponse, SentencesResponse, SubtitleFormat, Transcript } from "../types/assemblyai-types.js";
3
- /**
4
- * A client for the AssemblyAI API.
5
- */
6
- export declare class AssemblyAIClient {
7
- private readonly apiKey;
8
- private static readonly baseUrl;
9
- /**
10
- * @param apiKey The API key for the AssemblyAI API.
11
- */
12
- constructor(apiKey: string);
13
- /**
14
- * Uploads a file to AssemblyAI CDN.
15
- * The file will only be accessible to AssemblyAI and be removed after a period of time.
16
- * @param file Audio or video file to upload.
17
- * @returns The URL of the uploaded file.
18
- */
19
- uploadFile(file: Buffer): Promise<string>;
20
- /**
21
- * Creates a transcript in the AssemblyAI API. The transcript will be queued for processing,
22
- * but an empty transcript object is returned immediately.
23
- * @param fileUrl The URL of the audio or video file to transcribe.
24
- * @returns Empty transcript object
25
- */
26
- createTranscript(params: CreateTranscriptParams): Promise<Transcript>;
27
- /**
28
- * Gets the transcript by its ID.
29
- * @param id The ID of the transcript to retrieve.
30
- * @returns Transcript object
31
- */
32
- getTranscript(id: string): Promise<Transcript>;
33
- /**
34
- * Polls the transcript status until it is completed, then returns the completed transcript object.
35
- * @param id The ID of the transcript to retrieve.
36
- * @returns Transcript object
37
- */
38
- waitForTranscriptToComplete(id: string): Promise<Transcript>;
39
- /**
40
- * Gets the paragraphs of the transcript in the specified format.
41
- * @param id The ID of the transcript to retrieve paragraphs fors.
42
- * @returns Paragraphs for the transcript.
43
- */
44
- getParagraphs(id: string): Promise<ParagraphsResponse>;
45
- /**
46
- * Gets the paragraphs of the transcript in the specified format.
47
- * @param id The ID of the transcript to retrieve paragraphs fors.
48
- * @returns Paragraphs for the transcript.
49
- */
50
- getSentences(id: string): Promise<SentencesResponse>;
51
- /**
52
- * Gets the subtitles of the transcript in the specified format.
53
- * @param id The ID of the transcript to retrieve.
54
- * @param subtitleFormat Format of the subtitles to retrieve.
55
- * @returns Subtitles in the specified format as text.
56
- */
57
- getSubtitles(id: string, subtitleFormat?: (typeof SubtitleFormat)[keyof typeof SubtitleFormat]): Promise<string>;
58
- /**
59
- * Throws an error if the body is an error object.
60
- * @param body The response object returned by the AssemblyAI API to check.
61
- */
62
- private static throwIfError;
63
- }
@@ -1,170 +0,0 @@
1
- import { SubtitleFormat, } from "../types/assemblyai-types.js";
2
- /**
3
- * A client for the AssemblyAI API.
4
- */
5
- class AssemblyAIClient {
6
- /**
7
- * @param apiKey The API key for the AssemblyAI API.
8
- */
9
- constructor(apiKey) {
10
- Object.defineProperty(this, "apiKey", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: apiKey
15
- });
16
- if (!apiKey)
17
- throw new Error("No AssemblyAI API key provided");
18
- }
19
- /**
20
- * Uploads a file to AssemblyAI CDN.
21
- * The file will only be accessible to AssemblyAI and be removed after a period of time.
22
- * @param file Audio or video file to upload.
23
- * @returns The URL of the uploaded file.
24
- */
25
- async uploadFile(file) {
26
- const response = await fetch(`${AssemblyAIClient.baseUrl}/upload`, {
27
- method: "POST",
28
- headers: {
29
- authorization: this.apiKey,
30
- },
31
- body: file,
32
- });
33
- const json = (await response.json());
34
- AssemblyAIClient.throwIfError(json);
35
- return json.upload_url;
36
- }
37
- /**
38
- * Creates a transcript in the AssemblyAI API. The transcript will be queued for processing,
39
- * but an empty transcript object is returned immediately.
40
- * @param fileUrl The URL of the audio or video file to transcribe.
41
- * @returns Empty transcript object
42
- */
43
- async createTranscript(params) {
44
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript`, {
45
- method: "POST",
46
- headers: {
47
- authorization: this.apiKey,
48
- "Content-Type": "application/json",
49
- },
50
- body: JSON.stringify(params),
51
- });
52
- const transcript = (await response.json());
53
- AssemblyAIClient.throwIfError(transcript);
54
- return transcript;
55
- }
56
- /**
57
- * Gets the transcript by its ID.
58
- * @param id The ID of the transcript to retrieve.
59
- * @returns Transcript object
60
- */
61
- async getTranscript(id) {
62
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}`, {
63
- headers: {
64
- authorization: this.apiKey,
65
- },
66
- });
67
- const transcript = (await response.json());
68
- AssemblyAIClient.throwIfError(transcript);
69
- return transcript;
70
- }
71
- /**
72
- * Polls the transcript status until it is completed, then returns the completed transcript object.
73
- * @param id The ID of the transcript to retrieve.
74
- * @returns Transcript object
75
- */
76
- async waitForTranscriptToComplete(id) {
77
- const pollingEndpoint = `${AssemblyAIClient.baseUrl}/transcript/${id}`;
78
- // infinite loop, same as while(true) but linter doesn't like using true constant
79
- for (;;) {
80
- const pollingResponse = await fetch(pollingEndpoint, {
81
- headers: {
82
- authorization: this.apiKey,
83
- },
84
- });
85
- const transcript = (await pollingResponse.json());
86
- AssemblyAIClient.throwIfError(transcript);
87
- switch (transcript.status) {
88
- case "queued":
89
- case "processing":
90
- await new Promise((resolve) => {
91
- setTimeout(resolve, 3000);
92
- });
93
- break;
94
- case "completed":
95
- return transcript;
96
- default:
97
- throw new Error(`Unexpected transcript status: ${transcript.status}`);
98
- }
99
- }
100
- }
101
- /**
102
- * Gets the paragraphs of the transcript in the specified format.
103
- * @param id The ID of the transcript to retrieve paragraphs fors.
104
- * @returns Paragraphs for the transcript.
105
- */
106
- async getParagraphs(id) {
107
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/paragraphs`, {
108
- headers: {
109
- authorization: this.apiKey,
110
- },
111
- });
112
- const paragraphs = (await response.json());
113
- AssemblyAIClient.throwIfError(paragraphs);
114
- return paragraphs;
115
- }
116
- /**
117
- * Gets the paragraphs of the transcript in the specified format.
118
- * @param id The ID of the transcript to retrieve paragraphs fors.
119
- * @returns Paragraphs for the transcript.
120
- */
121
- async getSentences(id) {
122
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/sentences`, {
123
- headers: {
124
- authorization: this.apiKey,
125
- },
126
- });
127
- const sentences = (await response.json());
128
- AssemblyAIClient.throwIfError(sentences);
129
- return sentences;
130
- }
131
- /**
132
- * Gets the subtitles of the transcript in the specified format.
133
- * @param id The ID of the transcript to retrieve.
134
- * @param subtitleFormat Format of the subtitles to retrieve.
135
- * @returns Subtitles in the specified format as text.
136
- */
137
- async getSubtitles(id, subtitleFormat = SubtitleFormat.Srt) {
138
- const response = await fetch(`${AssemblyAIClient.baseUrl}/transcript/${id}/${subtitleFormat}`, {
139
- headers: {
140
- authorization: this.apiKey,
141
- },
142
- });
143
- if (response.status !== 200) {
144
- if (response.headers.get("content-type")?.startsWith("application/json")) {
145
- const errorBody = (await response.json());
146
- AssemblyAIClient.throwIfError(errorBody);
147
- }
148
- else {
149
- throw new Error(`Get Subtitle request returned status ${response.status} ${response.statusText}`);
150
- }
151
- }
152
- const subtitles = await response.text();
153
- return subtitles;
154
- }
155
- /**
156
- * Throws an error if the body is an error object.
157
- * @param body The response object returned by the AssemblyAI API to check.
158
- */
159
- static throwIfError(body) {
160
- if ("error" in body)
161
- throw new Error(body.error);
162
- }
163
- }
164
- Object.defineProperty(AssemblyAIClient, "baseUrl", {
165
- enumerable: true,
166
- configurable: true,
167
- writable: true,
168
- value: "https://api.assemblyai.com/v2"
169
- });
170
- export { AssemblyAIClient };