🚀 feat: Assistants Streaming (#2159)

* chore: bump openai to 4.29.0 and npm audit fix

* chore: remove unnecessary stream field from ContentData

* feat: new enum and types for AssistantStreamEvent

* refactor(AssistantService): remove stream field and add conversationId to text ContentData
> - return `finalMessage` and `text` on run completion
> - move `processMessages` to services/Threads to avoid circular dependencies with new stream handling
> - refactor(processMessages/retrieveAndProcessFile): add new `client` field to differentiate new RunClient type

* WIP: new assistants stream handling

* chore: stores messages to StreamRunManager

* chore: add additional typedefs

* fix: pass req and openai to StreamRunManager

* fix(AssistantService): pass openai as client to `retrieveAndProcessFile`

* WIP: streaming tool i/o, handle in_progress and completed run steps

* feat(assistants): process required actions with streaming enabled

* chore: condense early return check for useSSE useEffect

* chore: remove unnecessary comments and only handle completed tool calls when not function

* feat: add TTL for assistants run abort cacheKey

* feat: abort stream runs

* fix(assistants): render streaming cursor

* fix(assistants): hide edit icon as functionality is not supported

* fix(textArea): handle pasting edge cases; first, when onChange events wouldn't fire; second, when textarea wouldn't resize

* chore: memoize Conversations

* chore(useTextarea): reverse args order

* fix: load default capabilities when an azure is configured to support assistants, but `assistants` endpoint is not configured

* fix(AssistantSelect): update form assistant model on assistant form select

* fix(actions): handle azure strict validation for function names to fix crud for actions

* chore: remove content data debug log as it fires in rapid succession

* feat: improve UX for assistant errors mid-request

* feat: add tool call localizations and replace any domain separators from azure action names

* refactor(chat): error out tool calls without outputs during handleError

* fix(ToolService): handle domain separators allowing Azure use of actions

* refactor(StreamRunManager): types and throw Error if tool submission fails
This commit is contained in:
Danny Avila 2024-03-21 22:42:25 -04:00 committed by GitHub
parent ed64c76053
commit f427ad792a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 1503 additions and 330 deletions

134
package-lock.json generated
View file

@ -80,7 +80,7 @@
"multer": "^1.4.5-lts.1",
"nodejs-gpt": "^1.37.4",
"nodemailer": "^6.9.4",
"openai": "^4.28.4",
"openai": "^4.29.0",
"openai-chat-tokens": "^0.2.8",
"openid-client": "^5.4.2",
"passport": "^0.6.0",
@ -115,9 +115,9 @@
}
},
"api/node_modules/openai": {
"version": "4.28.4",
"resolved": "https://registry.npmjs.org/openai/-/openai-4.28.4.tgz",
"integrity": "sha512-RNIwx4MT/F0zyizGcwS+bXKLzJ8QE9IOyigDG/ttnwB220d58bYjYFp0qjvGwEFBO6+pvFVIDABZPGDl46RFsg==",
"version": "4.29.0",
"resolved": "https://registry.npmjs.org/openai/-/openai-4.29.0.tgz",
"integrity": "sha512-ic6C681bSow1XQdKhADthM/OOKqNL05M1gCFLx1mRqLJ+yH49v6qnvaWQ76kwqI/IieCuVTXfRfTk3sz4cB45w==",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
@ -4895,9 +4895,9 @@
"integrity": "sha512-iRP+QKI2+oz3UAh4nPEq14CsEjrjD6a5+fuypjScisAh9kXKFvdJOZJDwk7kikLvWVLGEs9+kIUS4LPQV7VZVw=="
},
"node_modules/@firebase/app": {
"version": "0.9.27",
"resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.9.27.tgz",
"integrity": "sha512-p2Dvl1ge4kRsyK5+wWcmdAIE9MSwZ0pDKAYB51LZgZuz6wciUZk4E1yAEdkfQlRxuHehn+Ol9WP5Qk2XQZiHGg==",
"version": "0.9.29",
"resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.9.29.tgz",
"integrity": "sha512-HbKTjfmILklasIu/ij6zKnFf3SgLYXkBDVN7leJfVGmohl+zA7Ig+eXM1ZkT1pyBJ8FTYR+mlOJer/lNEnUCtw==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/logger": "0.4.0",
@ -4947,11 +4947,11 @@
"integrity": "sha512-uwSUj32Mlubybw7tedRzR24RP8M8JUVR3NPiMk3/Z4bCmgEKTlQBwMXrehDAZ2wF+TsBq0SN1c6ema71U/JPyQ=="
},
"node_modules/@firebase/app-compat": {
"version": "0.2.27",
"resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.27.tgz",
"integrity": "sha512-SYlqocfUDKPHR6MSFC8hree0BTiWFu5o8wbf6zFlYXyG41w7TcHp4wJi4H/EL5V6cM4kxwruXTJtqXX/fRAZtw==",
"version": "0.2.29",
"resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.29.tgz",
"integrity": "sha512-NqUdegXJfwphx9i/2bOE2CTZ55TC9bbDg+iwkxVShsPBJhD3CzQJkFhoDz4ccfbJaKZGsqjY3fisgX5kbDROnA==",
"dependencies": {
"@firebase/app": "0.9.27",
"@firebase/app": "0.9.29",
"@firebase/component": "0.6.5",
"@firebase/logger": "0.4.0",
"@firebase/util": "1.9.4",
@ -4964,15 +4964,15 @@
"integrity": "sha512-AeweANOIo0Mb8GiYm3xhTEBVCmPwTYAu9Hcd2qSkLuga/6+j9b1Jskl5bpiSQWy9eJ/j5pavxj6eYogmnuzm+Q=="
},
"node_modules/@firebase/auth": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-1.6.0.tgz",
"integrity": "sha512-Qhl35eJTV6BwvuueTPCY6x8kUlYyzALtjp/Ws0X3fw3AnjVVfuVb7oQ3Xh5VPVfMFhaIuUAd1KXwcAuIklkSDw==",
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-1.6.2.tgz",
"integrity": "sha512-BFo/Nj1AAbKLbFiUyXCcnT/bSqMJicFOgdTAKzlXvCul7+eUE29vWmzd1g59O3iKAxvv3+fbQYjQVJpNTTHIyw==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/logger": "0.4.0",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0",
"undici": "5.26.5"
"undici": "5.28.3"
},
"peerDependencies": {
"@firebase/app": "0.x",
@ -4985,16 +4985,16 @@
}
},
"node_modules/@firebase/auth-compat": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.5.2.tgz",
"integrity": "sha512-pRgje5BPCNR1vXyvGOVXwOHtv88A2WooXfklI8sV7/jWi03ExFqNfpJT26GUo/oD39NoKJ3Kt6rD5gVvdV7lMw==",
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.5.4.tgz",
"integrity": "sha512-EtRVW9s0YsuJv3GnOGDoLUW3Pp9f3HcqWA2WK92E30Qa0FEVRwCSRLVQwn9td+SLVY3AP9gi/auC1q3osd4yCg==",
"dependencies": {
"@firebase/auth": "1.6.0",
"@firebase/auth": "1.6.2",
"@firebase/auth-types": "0.12.0",
"@firebase/component": "0.6.5",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0",
"undici": "5.26.5"
"undici": "5.28.3"
},
"peerDependencies": {
"@firebase/app-compat": "0.x"
@ -5060,9 +5060,9 @@
}
},
"node_modules/@firebase/firestore": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.4.2.tgz",
"integrity": "sha512-YaX6ypa/RzU6OkxzUQlpSxwhOIWdTraCNz7sMsbaSEjjl/pj/QvX6TqjkdWGzuBYh2S6rz7ErhDO0g39oZZw/g==",
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.5.0.tgz",
"integrity": "sha512-rXS6v4HbsN6vZQlq2fLW1ZHb+J5SnS+8Zqb/McbKFIrGYjPUZo5CyO75mkgtlR1tCYAwCebaqoEWb6JHgZv/ww==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/logger": "0.4.0",
@ -5071,7 +5071,7 @@
"@grpc/grpc-js": "~1.9.0",
"@grpc/proto-loader": "^0.7.8",
"tslib": "^2.1.0",
"undici": "5.26.5"
"undici": "5.28.3"
},
"engines": {
"node": ">=10.10.0"
@ -5081,12 +5081,12 @@
}
},
"node_modules/@firebase/firestore-compat": {
"version": "0.3.25",
"resolved": "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.3.25.tgz",
"integrity": "sha512-+xI7WmsgZCBhMn/+uhDKcg+lsOUJ9FJyt5PGTzkFPbCsozWfeQZ7eVnfPh0rMkUOf0yIQ924RIe04gwvEIbcoQ==",
"version": "0.3.27",
"resolved": "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.3.27.tgz",
"integrity": "sha512-gY2q0fCDJvPg/IurZQbBM7MIVjxA1/LsvfgFOubUTrex5KTY9qm4/2V2R79eAs8Q+b4B8soDtlEjk6L8BW1Crw==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/firestore": "4.4.2",
"@firebase/firestore": "4.5.0",
"@firebase/firestore-types": "3.0.0",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0"
@ -5105,9 +5105,9 @@
}
},
"node_modules/@firebase/functions": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.11.1.tgz",
"integrity": "sha512-3uUa1hB79Gmy6E1gHTfzoHeZolBeHc/I/n3+lOCDe6BOos9AHmzRjKygcFE/7VA2FJjitCE0K+OHI6+OuoY8fQ==",
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.11.2.tgz",
"integrity": "sha512-2NULTYOZbu0rXczwfYdqQH0w1FmmYrKjTy1YPQSHLCAkMBdfewoKmVm4Lyo2vRn0H9ZndciLY7NszKDFt9MKCQ==",
"dependencies": {
"@firebase/app-check-interop-types": "0.3.0",
"@firebase/auth-interop-types": "0.2.1",
@ -5115,19 +5115,19 @@
"@firebase/messaging-interop-types": "0.2.0",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0",
"undici": "5.26.5"
"undici": "5.28.3"
},
"peerDependencies": {
"@firebase/app": "0.x"
}
},
"node_modules/@firebase/functions-compat": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.7.tgz",
"integrity": "sha512-uXe6Kmku5lNogp3OpPBcOJbSvnaCOn+YxS3zlXKNU6Q/NLwcvO3RY1zwYyctCos2RemEw3KEQ7YdzcECXjHWLw==",
"version": "0.3.8",
"resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.8.tgz",
"integrity": "sha512-VDHSw6UOu8RxfgAY/q8e+Jn+9Fh60Fc28yck0yfMsi2e0BiWgonIMWkFspFGGLgOJebTHl+hc+9v91rhzU6xlg==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/functions": "0.11.1",
"@firebase/functions": "0.11.2",
"@firebase/functions-types": "0.6.0",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0"
@ -5294,26 +5294,26 @@
"integrity": "sha512-RtEH4vdcbXZuZWRZbIRmQVBNsE7VDQpet2qFvq6vwKLBIQRQR5Kh58M4ok3A3US8Sr3rubYnaGqZSurCwI8uMA=="
},
"node_modules/@firebase/storage": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.12.1.tgz",
"integrity": "sha512-KJ5NV7FUh54TeTlEjdkTTX60ciCKOp9EqlbLnpdcXUYRJg0Z4810TXbilPc1z7fTIG4iPjtdi95bGE9n4dBX8A==",
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.12.2.tgz",
"integrity": "sha512-MzanOBcxDx9oOwDaDPMuiYxd6CxcN1xZm+os5uNE3C1itbRKLhM9rzpODDKWzcbnHHFtXk3Q3lsK/d3Xa1WYYw==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0",
"undici": "5.26.5"
"undici": "5.28.3"
},
"peerDependencies": {
"@firebase/app": "0.x"
}
},
"node_modules/@firebase/storage-compat": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.3.4.tgz",
"integrity": "sha512-Y0m5e2gS/wB9Ioth2X/Sgz76vcxvqgQrCmfa9qwhss/N31kxY2Gks6Frv0nrE18AjVfcSmcfDitqUwxcMOTRSg==",
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.3.5.tgz",
"integrity": "sha512-5dJXfY5NxCF5NAk4dLvJqC+m6cgcf0Fr29nrMHwhwI34pBheQq2PdRZqALsqZCES9dnHTuFNlqGQDpLr+Ph4rw==",
"dependencies": {
"@firebase/component": "0.6.5",
"@firebase/storage": "0.12.1",
"@firebase/storage": "0.12.2",
"@firebase/storage-types": "0.8.0",
"@firebase/util": "1.9.4",
"tslib": "^2.1.0"
@ -14378,25 +14378,25 @@
}
},
"node_modules/firebase": {
"version": "10.8.0",
"resolved": "https://registry.npmjs.org/firebase/-/firebase-10.8.0.tgz",
"integrity": "sha512-UJpC24vw8JFuHEOQyArBGKTUd7+kohLISCzHyn0M/prP0KOTx2io1eyLliEid330QqnWI7FOlPxoU97qecCSfQ==",
"version": "10.9.0",
"resolved": "https://registry.npmjs.org/firebase/-/firebase-10.9.0.tgz",
"integrity": "sha512-R8rDU3mg2dq0uPOoZ5Nc3BeZTbXxBPJS8HcZLtnV0f5/YrmpNsHngzmMHRVB+91T+ViJGVL/42dV23gS9w9ccw==",
"dependencies": {
"@firebase/analytics": "0.10.1",
"@firebase/analytics-compat": "0.2.7",
"@firebase/app": "0.9.27",
"@firebase/app": "0.9.29",
"@firebase/app-check": "0.8.2",
"@firebase/app-check-compat": "0.3.9",
"@firebase/app-compat": "0.2.27",
"@firebase/app-compat": "0.2.29",
"@firebase/app-types": "0.9.0",
"@firebase/auth": "1.6.0",
"@firebase/auth-compat": "0.5.2",
"@firebase/auth": "1.6.2",
"@firebase/auth-compat": "0.5.4",
"@firebase/database": "1.0.3",
"@firebase/database-compat": "1.0.3",
"@firebase/firestore": "4.4.2",
"@firebase/firestore-compat": "0.3.25",
"@firebase/functions": "0.11.1",
"@firebase/functions-compat": "0.3.7",
"@firebase/firestore": "4.5.0",
"@firebase/firestore-compat": "0.3.27",
"@firebase/functions": "0.11.2",
"@firebase/functions-compat": "0.3.8",
"@firebase/installations": "0.6.5",
"@firebase/installations-compat": "0.2.5",
"@firebase/messaging": "0.12.6",
@ -14405,8 +14405,8 @@
"@firebase/performance-compat": "0.2.5",
"@firebase/remote-config": "0.4.5",
"@firebase/remote-config-compat": "0.2.5",
"@firebase/storage": "0.12.1",
"@firebase/storage-compat": "0.3.4",
"@firebase/storage": "0.12.2",
"@firebase/storage-compat": "0.3.5",
"@firebase/util": "1.9.4"
}
},
@ -14456,9 +14456,9 @@
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
},
"node_modules/follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
@ -17671,9 +17671,9 @@
}
},
"node_modules/jose": {
"version": "4.15.4",
"resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz",
"integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==",
"version": "4.15.5",
"resolved": "https://registry.npmjs.org/jose/-/jose-4.15.5.tgz",
"integrity": "sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==",
"funding": {
"url": "https://github.com/sponsors/panva"
}
@ -26476,9 +26476,9 @@
"dev": true
},
"node_modules/undici": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.26.5.tgz",
"integrity": "sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw==",
"version": "5.28.3",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz",
"integrity": "sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
@ -27994,7 +27994,7 @@
},
"packages/data-provider": {
"name": "librechat-data-provider",
"version": "0.4.7",
"version": "0.4.8",
"license": "ISC",
"dependencies": {
"@types/js-yaml": "^4.0.9",