langchain 0.0.177 → 0.0.178

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 (35) hide show
  1. package/chat_models/iflytek_xinghuo/web.cjs +1 -0
  2. package/chat_models/iflytek_xinghuo/web.d.ts +1 -0
  3. package/chat_models/iflytek_xinghuo/web.js +1 -0
  4. package/chat_models/iflytek_xinghuo.cjs +1 -0
  5. package/chat_models/iflytek_xinghuo.d.ts +1 -0
  6. package/chat_models/iflytek_xinghuo.js +1 -0
  7. package/dist/chat_models/cloudflare_workersai.cjs +70 -24
  8. package/dist/chat_models/cloudflare_workersai.d.ts +6 -2
  9. package/dist/chat_models/cloudflare_workersai.js +71 -25
  10. package/dist/chat_models/iflytek_xinghuo/common.cjs +335 -0
  11. package/dist/chat_models/iflytek_xinghuo/common.d.ts +165 -0
  12. package/dist/chat_models/iflytek_xinghuo/common.js +331 -0
  13. package/dist/chat_models/iflytek_xinghuo/index.cjs +35 -0
  14. package/dist/chat_models/iflytek_xinghuo/index.d.ts +5 -0
  15. package/dist/chat_models/iflytek_xinghuo/index.js +28 -0
  16. package/dist/chat_models/iflytek_xinghuo/web.cjs +30 -0
  17. package/dist/chat_models/iflytek_xinghuo/web.d.ts +5 -0
  18. package/dist/chat_models/iflytek_xinghuo/web.js +26 -0
  19. package/dist/graphs/neo4j_graph.cjs +36 -5
  20. package/dist/graphs/neo4j_graph.js +14 -3
  21. package/dist/llms/cloudflare_workersai.cjs +59 -13
  22. package/dist/llms/cloudflare_workersai.d.ts +9 -3
  23. package/dist/llms/cloudflare_workersai.js +59 -13
  24. package/dist/load/import_constants.cjs +2 -0
  25. package/dist/load/import_constants.js +2 -0
  26. package/dist/prompts/chat.cjs +8 -0
  27. package/dist/prompts/chat.d.ts +5 -0
  28. package/dist/prompts/chat.js +8 -0
  29. package/dist/util/event-source-parse.cjs +20 -1
  30. package/dist/util/event-source-parse.d.ts +2 -0
  31. package/dist/util/event-source-parse.js +18 -0
  32. package/dist/util/iflytek_websocket_stream.cjs +81 -0
  33. package/dist/util/iflytek_websocket_stream.d.ts +27 -0
  34. package/dist/util/iflytek_websocket_stream.js +77 -0
  35. package/package.json +22 -1
@@ -0,0 +1,77 @@
1
+ /**
2
+ * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
3
+ *
4
+ * @see https://web.dev/websocketstream/
5
+ */
6
+ export class BaseWebSocketStream {
7
+ constructor(url, options = {}) {
8
+ Object.defineProperty(this, "url", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: void 0
13
+ });
14
+ Object.defineProperty(this, "connection", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "closed", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ Object.defineProperty(this, "close", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ if (options.signal?.aborted) {
33
+ throw new DOMException("This operation was aborted", "AbortError");
34
+ }
35
+ this.url = url;
36
+ const ws = this.openWebSocket(url, options);
37
+ const closeWithInfo = ({ code, reason } = {}) => ws.close(code, reason);
38
+ this.connection = new Promise((resolve, reject) => {
39
+ ws.onopen = () => {
40
+ resolve({
41
+ readable: new ReadableStream({
42
+ start(controller) {
43
+ ws.onmessage = ({ data }) => controller.enqueue(data);
44
+ ws.onerror = (e) => controller.error(e);
45
+ },
46
+ cancel: closeWithInfo,
47
+ }),
48
+ writable: new WritableStream({
49
+ write(chunk) {
50
+ ws.send(chunk);
51
+ },
52
+ abort() {
53
+ ws.close();
54
+ },
55
+ close: closeWithInfo,
56
+ }),
57
+ protocol: ws.protocol,
58
+ extensions: ws.extensions,
59
+ });
60
+ ws.removeEventListener("error", reject);
61
+ };
62
+ ws.addEventListener("error", reject);
63
+ });
64
+ this.closed = new Promise((resolve, reject) => {
65
+ ws.onclose = ({ code, reason }) => {
66
+ resolve({ code, reason });
67
+ ws.removeEventListener("error", reject);
68
+ };
69
+ ws.addEventListener("error", reject);
70
+ });
71
+ if (options.signal) {
72
+ // eslint-disable-next-line no-param-reassign
73
+ options.signal.onabort = () => ws.close();
74
+ }
75
+ this.close = closeWithInfo;
76
+ }
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.177",
3
+ "version": "0.0.178",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -496,6 +496,12 @@
496
496
  "chat_models/baiduwenxin.cjs",
497
497
  "chat_models/baiduwenxin.js",
498
498
  "chat_models/baiduwenxin.d.ts",
499
+ "chat_models/iflytek_xinghuo.cjs",
500
+ "chat_models/iflytek_xinghuo.js",
501
+ "chat_models/iflytek_xinghuo.d.ts",
502
+ "chat_models/iflytek_xinghuo/web.cjs",
503
+ "chat_models/iflytek_xinghuo/web.js",
504
+ "chat_models/iflytek_xinghuo/web.d.ts",
499
505
  "chat_models/ollama.cjs",
500
506
  "chat_models/ollama.js",
501
507
  "chat_models/ollama.d.ts",
@@ -849,6 +855,7 @@
849
855
  "@types/pg": "^8",
850
856
  "@types/pg-copy-streams": "^1.2.2",
851
857
  "@types/uuid": "^9",
858
+ "@types/ws": "^8",
852
859
  "@typescript-eslint/eslint-plugin": "^5.58.0",
853
860
  "@typescript-eslint/parser": "^5.58.0",
854
861
  "@upstash/redis": "^1.20.6",
@@ -1025,6 +1032,7 @@
1025
1032
  "voy-search": "0.6.2",
1026
1033
  "weaviate-ts-client": "^1.4.0",
1027
1034
  "web-auth-library": "^1.0.3",
1035
+ "ws": "^8.14.2",
1028
1036
  "youtube-transcript": "^1.0.6",
1029
1037
  "youtubei.js": "^5.8.0"
1030
1038
  },
@@ -1311,6 +1319,9 @@
1311
1319
  "web-auth-library": {
1312
1320
  "optional": true
1313
1321
  },
1322
+ "ws": {
1323
+ "optional": true
1324
+ },
1314
1325
  "youtube-transcript": {
1315
1326
  "optional": true
1316
1327
  },
@@ -2170,6 +2181,16 @@
2170
2181
  "import": "./chat_models/baiduwenxin.js",
2171
2182
  "require": "./chat_models/baiduwenxin.cjs"
2172
2183
  },
2184
+ "./chat_models/iflytek_xinghuo": {
2185
+ "types": "./chat_models/iflytek_xinghuo.d.ts",
2186
+ "import": "./chat_models/iflytek_xinghuo.js",
2187
+ "require": "./chat_models/iflytek_xinghuo.cjs"
2188
+ },
2189
+ "./chat_models/iflytek_xinghuo/web": {
2190
+ "types": "./chat_models/iflytek_xinghuo/web.d.ts",
2191
+ "import": "./chat_models/iflytek_xinghuo/web.js",
2192
+ "require": "./chat_models/iflytek_xinghuo/web.cjs"
2193
+ },
2173
2194
  "./chat_models/ollama": {
2174
2195
  "types": "./chat_models/ollama.d.ts",
2175
2196
  "import": "./chat_models/ollama.js",