From 261a1b9f453049b7aa94988d7e913aaad0590c7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 11:26:34 -0400 Subject: [PATCH 1/3] build(deps): bump next from 13.5.6 to 14.1.1 in /src/interfaces/coral_web (#129) build(deps): bump next in /src/interfaces/coral_web Bumps [next](https://github.com/vercel/next.js) from 13.5.6 to 14.1.1. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/compare/v13.5.6...v14.1.1) --- updated-dependencies: - dependency-name: next dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/interfaces/coral_web/package-lock.json | 113 +++++++++------------ src/interfaces/coral_web/package.json | 2 +- src/interfaces/coral_web/pnpm-lock.yaml | 84 +++++++-------- 3 files changed, 85 insertions(+), 114 deletions(-) diff --git a/src/interfaces/coral_web/package-lock.json b/src/interfaces/coral_web/package-lock.json index 00921f21..52383f89 100644 --- a/src/interfaces/coral_web/package-lock.json +++ b/src/interfaces/coral_web/package-lock.json @@ -34,7 +34,7 @@ "lodash": "^4.17.21", "match-sorter": "^6.3.1", "mdast-util-to-string": "^4.0.0", - "next": "^13.4.9", + "next": "^14.1.1", "node-html-parser": "^6.1.4", "openapi-typescript-codegen": "^0.27.0", "parse-domain": "^8.0.1", @@ -922,9 +922,9 @@ "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==" }, "node_modules/@next/env": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.6.tgz", - "integrity": "sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==" + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.1.1.tgz", + "integrity": "sha512-7CnQyD5G8shHxQIIg3c7/pSeYFeMhsNbpU/bmvH7ZnDql7mNRgg8O2JZrhrc/soFnfBnKP4/xXNiiSIPn2w8gA==" }, "node_modules/@next/eslint-plugin-next": { "version": "13.5.6", @@ -936,9 +936,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.6.tgz", - "integrity": "sha512-5nvXMzKtZfvcu4BhtV0KH1oGv4XEW+B+jOfmBdpFI3C7FrB/MfujRpWYSBBO64+qbW8pkZiSyQv9eiwnn5VIQA==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.1.tgz", + "integrity": "sha512-yDjSFKQKTIjyT7cFv+DqQfW5jsD+tVxXTckSe1KIouKk75t1qZmj/mV3wzdmFb0XHVGtyRjDMulfVG8uCKemOQ==", "cpu": [ "arm64" ], @@ -951,9 +951,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.6.tgz", - "integrity": "sha512-6cgBfxg98oOCSr4BckWjLLgiVwlL3vlLj8hXg2b+nDgm4bC/qVXXLfpLB9FHdoDu4057hzywbxKvmYGmi7yUzA==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.1.tgz", + "integrity": "sha512-KCQmBL0CmFmN8D64FHIZVD9I4ugQsDBBEJKiblXGgwn7wBCSe8N4Dx47sdzl4JAg39IkSN5NNrr8AniXLMb3aw==", "cpu": [ "x64" ], @@ -966,9 +966,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.6.tgz", - "integrity": "sha512-txagBbj1e1w47YQjcKgSU4rRVQ7uF29YpnlHV5xuVUsgCUf2FmyfJ3CPjZUvpIeXCJAoMCFAoGnbtX86BK7+sg==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.1.tgz", + "integrity": "sha512-YDQfbWyW0JMKhJf/T4eyFr4b3tceTorQ5w2n7I0mNVTFOvu6CGEzfwT3RSAQGTi/FFMTFcuspPec/7dFHuP7Eg==", "cpu": [ "arm64" ], @@ -981,9 +981,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.6.tgz", - "integrity": "sha512-cGd+H8amifT86ZldVJtAKDxUqeFyLWW+v2NlBULnLAdWsiuuN8TuhVBt8ZNpCqcAuoruoSWynvMWixTFcroq+Q==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.1.tgz", + "integrity": "sha512-fiuN/OG6sNGRN/bRFxRvV5LyzLB8gaL8cbDH5o3mEiVwfcMzyE5T//ilMmaTrnA8HLMS6hoz4cHOu6Qcp9vxgQ==", "cpu": [ "arm64" ], @@ -996,9 +996,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.6.tgz", - "integrity": "sha512-Mc2b4xiIWKXIhBy2NBTwOxGD3nHLmq4keFk+d4/WL5fMsB8XdJRdtUlL87SqVCTSaf1BRuQQf1HvXZcy+rq3Nw==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.1.tgz", + "integrity": "sha512-rv6AAdEXoezjbdfp3ouMuVqeLjE1Bin0AuE6qxE6V9g3Giz5/R3xpocHoAi7CufRR+lnkuUjRBn05SYJ83oKNQ==", "cpu": [ "x64" ], @@ -1011,9 +1011,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.6.tgz", - "integrity": "sha512-CFHvP9Qz98NruJiUnCe61O6GveKKHpJLloXbDSWRhqhkJdZD2zU5hG+gtVJR//tyW897izuHpM6Gtf6+sNgJPQ==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.1.tgz", + "integrity": "sha512-YAZLGsaNeChSrpz/G7MxO3TIBLaMN8QWMr3X8bt6rCvKovwU7GqQlDu99WdvF33kI8ZahvcdbFsy4jAFzFX7og==", "cpu": [ "x64" ], @@ -1026,9 +1026,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.6.tgz", - "integrity": "sha512-aFv1ejfkbS7PUa1qVPwzDHjQWQtknzAZWGTKYIAaS4NMtBlk3VyA6AYn593pqNanlicewqyl2jUhQAaFV/qXsg==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.1.tgz", + "integrity": "sha512-1L4mUYPBMvVDMZg1inUYyPvFSduot0g73hgfD9CODgbr4xiTYe0VOMTZzaRqYJYBA9mana0x4eaAaypmWo1r5A==", "cpu": [ "arm64" ], @@ -1041,9 +1041,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.6.tgz", - "integrity": "sha512-XqqpHgEIlBHvzwG8sp/JXMFkLAfGLqkbVsyN+/Ih1mR8INb6YCc2x/Mbwi6hsAgUnqQztz8cvEbHJUbSl7RHDg==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.1.tgz", + "integrity": "sha512-jvIE9tsuj9vpbbXlR5YxrghRfMuG0Qm/nZ/1KDHc+y6FpnZ/apsgh+G6t15vefU0zp3WSpTMIdXRUsNl/7RSuw==", "cpu": [ "ia32" ], @@ -1056,9 +1056,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz", - "integrity": "sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.1.tgz", + "integrity": "sha512-S6K6EHDU5+1KrBDLko7/c1MNy/Ya73pIAmvKeFwsF4RmBFJSO7/7YeD4FnZ4iBdzE69PpQ4sOMU9ORKeNuxe8A==", "cpu": [ "x64" ], @@ -5523,11 +5523,6 @@ "node": ">=10.13.0" } }, - "node_modules/glob-to-regexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" - }, "node_modules/glob/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -7861,34 +7856,34 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "node_modules/next": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/next/-/next-13.5.6.tgz", - "integrity": "sha512-Y2wTcTbO4WwEsVb4A8VSnOsG1I9ok+h74q0ZdxkwM3EODqrs4pasq7O0iUxbcS9VtWMicG7f3+HAj0r1+NtKSw==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/next/-/next-14.1.1.tgz", + "integrity": "sha512-McrGJqlGSHeaz2yTRPkEucxQKe5Zq7uPwyeHNmJaZNY4wx9E9QdxmTp310agFRoMuIYgQrCrT3petg13fSVOww==", "dependencies": { - "@next/env": "13.5.6", + "@next/env": "14.1.1", "@swc/helpers": "0.5.2", "busboy": "1.6.0", - "caniuse-lite": "^1.0.30001406", + "caniuse-lite": "^1.0.30001579", + "graceful-fs": "^4.2.11", "postcss": "8.4.31", - "styled-jsx": "5.1.1", - "watchpack": "2.4.0" + "styled-jsx": "5.1.1" }, "bin": { "next": "dist/bin/next" }, "engines": { - "node": ">=16.14.0" + "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.5.6", - "@next/swc-darwin-x64": "13.5.6", - "@next/swc-linux-arm64-gnu": "13.5.6", - "@next/swc-linux-arm64-musl": "13.5.6", - "@next/swc-linux-x64-gnu": "13.5.6", - "@next/swc-linux-x64-musl": "13.5.6", - "@next/swc-win32-arm64-msvc": "13.5.6", - "@next/swc-win32-ia32-msvc": "13.5.6", - "@next/swc-win32-x64-msvc": "13.5.6" + "@next/swc-darwin-arm64": "14.1.1", + "@next/swc-darwin-x64": "14.1.1", + "@next/swc-linux-arm64-gnu": "14.1.1", + "@next/swc-linux-arm64-musl": "14.1.1", + "@next/swc-linux-x64-gnu": "14.1.1", + "@next/swc-linux-x64-musl": "14.1.1", + "@next/swc-win32-arm64-msvc": "14.1.1", + "@next/swc-win32-ia32-msvc": "14.1.1", + "@next/swc-win32-x64-msvc": "14.1.1" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -10470,18 +10465,6 @@ "loose-envify": "^1.0.0" } }, - "node_modules/watchpack": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", - "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", - "dependencies": { - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.1.2" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/web-namespaces": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", diff --git a/src/interfaces/coral_web/package.json b/src/interfaces/coral_web/package.json index 950374ef..5f896900 100644 --- a/src/interfaces/coral_web/package.json +++ b/src/interfaces/coral_web/package.json @@ -40,7 +40,7 @@ "lodash": "^4.17.21", "match-sorter": "^6.3.1", "mdast-util-to-string": "^4.0.0", - "next": "^13.4.9", + "next": "^14.1.1", "node-html-parser": "^6.1.4", "openapi-typescript-codegen": "^0.27.0", "parse-domain": "^8.0.1", diff --git a/src/interfaces/coral_web/pnpm-lock.yaml b/src/interfaces/coral_web/pnpm-lock.yaml index 0df82fcc..a8dcb3e3 100644 --- a/src/interfaces/coral_web/pnpm-lock.yaml +++ b/src/interfaces/coral_web/pnpm-lock.yaml @@ -84,8 +84,8 @@ dependencies: specifier: ^4.0.0 version: 4.0.0 next: - specifier: ^13.4.9 - version: 13.5.6(@babel/core@7.24.3)(react-dom@18.2.0)(react@18.2.0) + specifier: ^14.1.1 + version: 14.1.1(@babel/core@7.24.3)(react-dom@18.2.0)(react@18.2.0) node-html-parser: specifier: ^6.1.4 version: 6.1.12 @@ -766,8 +766,8 @@ packages: resolution: {integrity: sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==} dev: false - /@next/env@13.5.6: - resolution: {integrity: sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==} + /@next/env@14.1.1: + resolution: {integrity: sha512-7CnQyD5G8shHxQIIg3c7/pSeYFeMhsNbpU/bmvH7ZnDql7mNRgg8O2JZrhrc/soFnfBnKP4/xXNiiSIPn2w8gA==} dev: false /@next/eslint-plugin-next@13.5.6: @@ -776,8 +776,8 @@ packages: glob: 7.1.7 dev: true - /@next/swc-darwin-arm64@13.5.6: - resolution: {integrity: sha512-5nvXMzKtZfvcu4BhtV0KH1oGv4XEW+B+jOfmBdpFI3C7FrB/MfujRpWYSBBO64+qbW8pkZiSyQv9eiwnn5VIQA==} + /@next/swc-darwin-arm64@14.1.1: + resolution: {integrity: sha512-yDjSFKQKTIjyT7cFv+DqQfW5jsD+tVxXTckSe1KIouKk75t1qZmj/mV3wzdmFb0XHVGtyRjDMulfVG8uCKemOQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -785,8 +785,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64@13.5.6: - resolution: {integrity: sha512-6cgBfxg98oOCSr4BckWjLLgiVwlL3vlLj8hXg2b+nDgm4bC/qVXXLfpLB9FHdoDu4057hzywbxKvmYGmi7yUzA==} + /@next/swc-darwin-x64@14.1.1: + resolution: {integrity: sha512-KCQmBL0CmFmN8D64FHIZVD9I4ugQsDBBEJKiblXGgwn7wBCSe8N4Dx47sdzl4JAg39IkSN5NNrr8AniXLMb3aw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -794,8 +794,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu@13.5.6: - resolution: {integrity: sha512-txagBbj1e1w47YQjcKgSU4rRVQ7uF29YpnlHV5xuVUsgCUf2FmyfJ3CPjZUvpIeXCJAoMCFAoGnbtX86BK7+sg==} + /@next/swc-linux-arm64-gnu@14.1.1: + resolution: {integrity: sha512-YDQfbWyW0JMKhJf/T4eyFr4b3tceTorQ5w2n7I0mNVTFOvu6CGEzfwT3RSAQGTi/FFMTFcuspPec/7dFHuP7Eg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -803,8 +803,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl@13.5.6: - resolution: {integrity: sha512-cGd+H8amifT86ZldVJtAKDxUqeFyLWW+v2NlBULnLAdWsiuuN8TuhVBt8ZNpCqcAuoruoSWynvMWixTFcroq+Q==} + /@next/swc-linux-arm64-musl@14.1.1: + resolution: {integrity: sha512-fiuN/OG6sNGRN/bRFxRvV5LyzLB8gaL8cbDH5o3mEiVwfcMzyE5T//ilMmaTrnA8HLMS6hoz4cHOu6Qcp9vxgQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -812,8 +812,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu@13.5.6: - resolution: {integrity: sha512-Mc2b4xiIWKXIhBy2NBTwOxGD3nHLmq4keFk+d4/WL5fMsB8XdJRdtUlL87SqVCTSaf1BRuQQf1HvXZcy+rq3Nw==} + /@next/swc-linux-x64-gnu@14.1.1: + resolution: {integrity: sha512-rv6AAdEXoezjbdfp3ouMuVqeLjE1Bin0AuE6qxE6V9g3Giz5/R3xpocHoAi7CufRR+lnkuUjRBn05SYJ83oKNQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -821,8 +821,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl@13.5.6: - resolution: {integrity: sha512-CFHvP9Qz98NruJiUnCe61O6GveKKHpJLloXbDSWRhqhkJdZD2zU5hG+gtVJR//tyW897izuHpM6Gtf6+sNgJPQ==} + /@next/swc-linux-x64-musl@14.1.1: + resolution: {integrity: sha512-YAZLGsaNeChSrpz/G7MxO3TIBLaMN8QWMr3X8bt6rCvKovwU7GqQlDu99WdvF33kI8ZahvcdbFsy4jAFzFX7og==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -830,8 +830,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc@13.5.6: - resolution: {integrity: sha512-aFv1ejfkbS7PUa1qVPwzDHjQWQtknzAZWGTKYIAaS4NMtBlk3VyA6AYn593pqNanlicewqyl2jUhQAaFV/qXsg==} + /@next/swc-win32-arm64-msvc@14.1.1: + resolution: {integrity: sha512-1L4mUYPBMvVDMZg1inUYyPvFSduot0g73hgfD9CODgbr4xiTYe0VOMTZzaRqYJYBA9mana0x4eaAaypmWo1r5A==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -839,8 +839,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc@13.5.6: - resolution: {integrity: sha512-XqqpHgEIlBHvzwG8sp/JXMFkLAfGLqkbVsyN+/Ih1mR8INb6YCc2x/Mbwi6hsAgUnqQztz8cvEbHJUbSl7RHDg==} + /@next/swc-win32-ia32-msvc@14.1.1: + resolution: {integrity: sha512-jvIE9tsuj9vpbbXlR5YxrghRfMuG0Qm/nZ/1KDHc+y6FpnZ/apsgh+G6t15vefU0zp3WSpTMIdXRUsNl/7RSuw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -848,8 +848,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc@13.5.6: - resolution: {integrity: sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==} + /@next/swc-win32-x64-msvc@14.1.1: + resolution: {integrity: sha512-S6K6EHDU5+1KrBDLko7/c1MNy/Ya73pIAmvKeFwsF4RmBFJSO7/7YeD4FnZ4iBdzE69PpQ4sOMU9ORKeNuxe8A==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -3875,10 +3875,6 @@ packages: dependencies: is-glob: 4.0.3 - /glob-to-regexp@0.4.1: - resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - dev: false - /glob@10.3.10: resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==} engines: {node: '>=16 || 14 >=14.17'} @@ -5205,9 +5201,9 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: false - /next@13.5.6(@babel/core@7.24.3)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-Y2wTcTbO4WwEsVb4A8VSnOsG1I9ok+h74q0ZdxkwM3EODqrs4pasq7O0iUxbcS9VtWMicG7f3+HAj0r1+NtKSw==} - engines: {node: '>=16.14.0'} + /next@14.1.1(@babel/core@7.24.3)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-McrGJqlGSHeaz2yTRPkEucxQKe5Zq7uPwyeHNmJaZNY4wx9E9QdxmTp310agFRoMuIYgQrCrT3petg13fSVOww==} + engines: {node: '>=18.17.0'} hasBin: true peerDependencies: '@opentelemetry/api': ^1.1.0 @@ -5220,25 +5216,25 @@ packages: sass: optional: true dependencies: - '@next/env': 13.5.6 + '@next/env': 14.1.1 '@swc/helpers': 0.5.2 busboy: 1.6.0 caniuse-lite: 1.0.30001600 + graceful-fs: 4.2.11 postcss: 8.4.31 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) styled-jsx: 5.1.1(@babel/core@7.24.3)(react@18.2.0) - watchpack: 2.4.0 optionalDependencies: - '@next/swc-darwin-arm64': 13.5.6 - '@next/swc-darwin-x64': 13.5.6 - '@next/swc-linux-arm64-gnu': 13.5.6 - '@next/swc-linux-arm64-musl': 13.5.6 - '@next/swc-linux-x64-gnu': 13.5.6 - '@next/swc-linux-x64-musl': 13.5.6 - '@next/swc-win32-arm64-msvc': 13.5.6 - '@next/swc-win32-ia32-msvc': 13.5.6 - '@next/swc-win32-x64-msvc': 13.5.6 + '@next/swc-darwin-arm64': 14.1.1 + '@next/swc-darwin-x64': 14.1.1 + '@next/swc-linux-arm64-gnu': 14.1.1 + '@next/swc-linux-arm64-musl': 14.1.1 + '@next/swc-linux-x64-gnu': 14.1.1 + '@next/swc-linux-x64-musl': 14.1.1 + '@next/swc-win32-arm64-msvc': 14.1.1 + '@next/swc-win32-ia32-msvc': 14.1.1 + '@next/swc-win32-x64-msvc': 14.1.1 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -6702,14 +6698,6 @@ packages: loose-envify: 1.4.0 dev: false - /watchpack@2.4.0: - resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} - engines: {node: '>=10.13.0'} - dependencies: - glob-to-regexp: 0.4.1 - graceful-fs: 4.2.11 - dev: false - /web-namespaces@2.0.1: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} dev: false From 1918a1e0211b56d12cd38ed8a5076dd15e546994 Mon Sep 17 00:00:00 2001 From: misspia-cohere <140425731+misspia-cohere@users.noreply.github.com> Date: Tue, 21 May 2024 22:28:00 +0200 Subject: [PATCH 2/3] coral_web: Show both tool description and error message when available (#143) show both tool description and error message if available --- .../coral_web/src/components/Configuration/Tools.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/interfaces/coral_web/src/components/Configuration/Tools.tsx b/src/interfaces/coral_web/src/components/Configuration/Tools.tsx index 6a0a017b..a58ab6b6 100644 --- a/src/interfaces/coral_web/src/components/Configuration/Tools.tsx +++ b/src/interfaces/coral_web/src/components/Configuration/Tools.tsx @@ -119,7 +119,16 @@ const ToolSection = () => { disabled={disabled} /> {(description || error_message) && ( - + + {description && {description}} + {error_message && ( + Error: {error_message} + )} + + } + /> )} ); From 658332d2e9fb493b1979aa3b684b518fcc3d7fce Mon Sep 17 00:00:00 2001 From: Jessica Wu Date: Wed, 22 May 2024 21:35:55 -0400 Subject: [PATCH 3/3] coral-web: fix citations for python interpreter (#120) --- src/interfaces/coral_web/.env.development | 2 +- .../src/cohere-client/generated/index.ts | 5 +- ...file_v1_conversations_upload_file_post.ts} | 2 +- ...ions__conversation_id__upload_file_post.ts | 7 - .../generated/models/CreateUser.ts | 2 + .../generated/models/Document.ts | 2 + .../models/{MessageType.ts => Login.ts} | 7 +- .../cohere-client/generated/models/Message.ts | 2 - .../generated/models/UpdateUser.ts | 4 +- .../generated/services/DefaultService.ts | 206 +++++++++------ .../components/Citations/CitationDocument.tsx | 250 +----------------- .../Citations/CitationDocumentHeader.tsx | 160 +++++++++++ .../Citations/CitationDocumentSnippet.tsx | 193 ++++++++++++++ .../Shared/DocumentIcon/DocumentIcon.tsx | 16 +- .../src/components/Shared/Text/Text.tsx | 1 + src/interfaces/coral_web/src/hooks/chat.ts | 85 ++++-- .../coral_web/src/pages/c/[id]/index.tsx | 56 ++-- .../src/stores/slices/citationsSlice.ts | 2 +- .../coral_web/src/themes/cohereTheme.js | 1 + src/interfaces/coral_web/src/utils/tools.ts | 78 ++++++ 20 files changed, 697 insertions(+), 384 deletions(-) rename src/interfaces/coral_web/src/cohere-client/generated/models/{Body_upload_file_conversations_upload_file_post.ts => Body_upload_file_v1_conversations_upload_file_post.ts} (72%) delete mode 100644 src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post.ts rename src/interfaces/coral_web/src/cohere-client/generated/models/{MessageType.ts => Login.ts} (62%) create mode 100644 src/interfaces/coral_web/src/components/Citations/CitationDocumentHeader.tsx create mode 100644 src/interfaces/coral_web/src/components/Citations/CitationDocumentSnippet.tsx create mode 100644 src/interfaces/coral_web/src/utils/tools.ts diff --git a/src/interfaces/coral_web/.env.development b/src/interfaces/coral_web/.env.development index 8fd6964e..82b9fcf7 100644 --- a/src/interfaces/coral_web/.env.development +++ b/src/interfaces/coral_web/.env.development @@ -1,3 +1,3 @@ # Client -NEXT_PUBLIC_API_HOSTNAME=http://backend:8000 +NEXT_PUBLIC_API_HOSTNAME=http://localhost:8000 NEXT_PUBLIC_HAS_CUSTOM_LOGO=false \ No newline at end of file diff --git a/src/interfaces/coral_web/src/cohere-client/generated/index.ts b/src/interfaces/coral_web/src/cohere-client/generated/index.ts index e9f8ced6..9b3dffed 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/index.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/index.ts @@ -7,8 +7,7 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; -export type { Body_upload_file_conversations_upload_file_post } from './models/Body_upload_file_conversations_upload_file_post'; -export type { Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post } from './models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post'; +export type { Body_upload_file_v1_conversations_upload_file_post } from './models/Body_upload_file_v1_conversations_upload_file_post'; export { Category } from './models/Category'; export type { ChatMessage } from './models/ChatMessage'; export type { ChatResponseEvent } from './models/ChatResponseEvent'; @@ -28,10 +27,10 @@ export type { File } from './models/File'; export type { HTTPValidationError } from './models/HTTPValidationError'; export type { LangchainChatRequest } from './models/LangchainChatRequest'; export type { ListFile } from './models/ListFile'; +export type { Login } from './models/Login'; export type { ManagedTool } from './models/ManagedTool'; export type { Message } from './models/Message'; export { MessageAgent } from './models/MessageAgent'; -export { MessageType } from './models/MessageType'; export type { NonStreamedChatResponse } from './models/NonStreamedChatResponse'; export type { SearchQuery } from './models/SearchQuery'; export type { StreamCitationGeneration } from './models/StreamCitationGeneration'; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_conversations_upload_file_post.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_v1_conversations_upload_file_post.ts similarity index 72% rename from src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_conversations_upload_file_post.ts rename to src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_v1_conversations_upload_file_post.ts index 5a542571..ad8b4be8 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_conversations_upload_file_post.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_v1_conversations_upload_file_post.ts @@ -2,7 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type Body_upload_file_conversations_upload_file_post = { +export type Body_upload_file_v1_conversations_upload_file_post = { conversation_id?: string; file: Blob; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post.ts deleted file mode 100644 index ecf13785..00000000 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post = { - file: Blob; -}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/CreateUser.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/CreateUser.ts index 74a594d0..fec103ad 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/CreateUser.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/CreateUser.ts @@ -3,6 +3,8 @@ /* tslint:disable */ /* eslint-disable */ export type CreateUser = { + password?: string | null; + hashed_password?: Blob | null; fullname: string; email?: string | null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Document.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Document.ts index 6649bd8f..0f2b0d31 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/Document.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Document.ts @@ -7,4 +7,6 @@ export type Document = { document_id: string; title: string | null; url: string | null; + fields: Record | null; + tool_name: string | null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/MessageType.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts similarity index 62% rename from src/interfaces/coral_web/src/cohere-client/generated/models/MessageType.ts rename to src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts index d57f158e..7153dc68 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/MessageType.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Login.ts @@ -2,6 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export enum MessageType { - TEXT = 'TEXT', -} +export type Login = { + strategy: string; + payload: Record; +}; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/Message.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/Message.ts index 96d38af5..06ab28de 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/Message.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/Message.ts @@ -9,10 +9,8 @@ import type { Citation } from './Citation'; import type { Document } from './Document'; import type { File } from './File'; import type { MessageAgent } from './MessageAgent'; -import type { MessageType } from './MessageType'; export type Message = { - type?: MessageType; text: string; id: string; created_at: string; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateUser.ts b/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateUser.ts index 2dc7bd75..23a38361 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateUser.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/models/UpdateUser.ts @@ -3,6 +3,8 @@ /* tslint:disable */ /* eslint-disable */ export type UpdateUser = { - fullname: string; + password?: string | null; + hashed_password?: Blob | null; + fullname?: string | null; email?: string | null; }; diff --git a/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts b/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts index 75ac769d..4122383b 100644 --- a/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts +++ b/src/interfaces/coral_web/src/cohere-client/generated/services/DefaultService.ts @@ -8,8 +8,7 @@ import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; -import type { Body_upload_file_conversations_upload_file_post } from '../models/Body_upload_file_conversations_upload_file_post'; -import type { Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post } from '../models/Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post'; +import type { Body_upload_file_v1_conversations_upload_file_post } from '../models/Body_upload_file_v1_conversations_upload_file_post'; import type { ChatResponseEvent } from '../models/ChatResponseEvent'; import type { CohereChatRequest } from '../models/CohereChatRequest'; import type { Conversation } from '../models/Conversation'; @@ -22,6 +21,7 @@ import type { Deployment } from '../models/Deployment'; import type { File } from '../models/File'; import type { LangchainChatRequest } from '../models/LangchainChatRequest'; import type { ListFile } from '../models/ListFile'; +import type { Login } from '../models/Login'; import type { ManagedTool } from '../models/ManagedTool'; import type { NonStreamedChatResponse } from '../models/NonStreamedChatResponse'; import type { UpdateConversation } from '../models/UpdateConversation'; @@ -32,6 +32,85 @@ import type { UploadFile } from '../models/UploadFile'; import type { User } from '../models/User'; export class DefaultService { + /** + * Get Session + * Retrievers the current session user. + * + * Args: + * request (Request): current Request object. + * + * Returns: + * session: current user session ({} if no active session) + * + * Raises: + * 401 HTTPException if no user found in session. + * @returns any Successful Response + * @throws ApiError + */ + public static getSessionSessionGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/session', + }); + } + /** + * Login + * Logs user in, verifying their credentials and either setting the user session, + * or redirecting to /auth endpoint. + * + * Args:er + * request (Request): current Request object. + * login (Login): Login payload. + * session (DBSessionDep): Database session. + * + * Returns: + * dict: On success. + * + * Raises: + * HTTPException: If the strategy or payload are invalid, or if the login fails. + * @returns any Successful Response + * @throws ApiError + */ + public static loginLoginPost({ requestBody }: { requestBody: Login }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/login', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * Auth + * @returns any Successful Response + * @throws ApiError + */ + public static authAuthPost(): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/auth', + }); + } + /** + * Logout + * Logs out the current user session. + * + * Args: + * request (Request): current Request object. + * + * Returns: + * dict: On success. + * @returns any Successful Response + * @throws ApiError + */ + public static logoutLogoutGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/logout', + }); + } /** * Chat Stream * Stream chat endpoint to handle user messages and return chatbot responses. @@ -46,14 +125,14 @@ export class DefaultService { * @returns ChatResponseEvent Successful Response * @throws ApiError */ - public static chatStreamChatStreamPost({ + public static chatStreamV1ChatStreamPost({ requestBody, }: { requestBody: CohereChatRequest; }): CancelablePromise> { return __request(OpenAPI, { method: 'POST', - url: '/chat-stream', + url: '/v1/chat-stream', body: requestBody, mediaType: 'application/json', errors: { @@ -75,14 +154,14 @@ export class DefaultService { * @returns NonStreamedChatResponse Successful Response * @throws ApiError */ - public static chatChatPost({ + public static chatV1ChatPost({ requestBody, }: { requestBody: CohereChatRequest; }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/chat', + url: '/v1/chat', body: requestBody, mediaType: 'application/json', errors: { @@ -95,14 +174,14 @@ export class DefaultService { * @returns any Successful Response * @throws ApiError */ - public static langchainChatStreamLangchainChatPost({ + public static langchainChatStreamV1LangchainChatPost({ requestBody, }: { requestBody: LangchainChatRequest; }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/langchain-chat', + url: '/v1/langchain-chat', body: requestBody, mediaType: 'application/json', errors: { @@ -123,14 +202,14 @@ export class DefaultService { * @returns User Successful Response * @throws ApiError */ - public static createUserUsersPost({ + public static createUserV1UsersPost({ requestBody, }: { requestBody: CreateUser; }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/users/', + url: '/v1/users/', body: requestBody, mediaType: 'application/json', errors: { @@ -152,7 +231,7 @@ export class DefaultService { * @returns User Successful Response * @throws ApiError */ - public static listUsersUsersGet({ + public static listUsersV1UsersGet({ offset, limit = 100, }: { @@ -161,7 +240,7 @@ export class DefaultService { }): CancelablePromise> { return __request(OpenAPI, { method: 'GET', - url: '/users/', + url: '/v1/users/', query: { offset: offset, limit: limit, @@ -187,10 +266,10 @@ export class DefaultService { * @returns User Successful Response * @throws ApiError */ - public static getUserUsersUserIdGet({ userId }: { userId: string }): CancelablePromise { + public static getUserV1UsersUserIdGet({ userId }: { userId: string }): CancelablePromise { return __request(OpenAPI, { method: 'GET', - url: '/users/{user_id}', + url: '/v1/users/{user_id}', path: { user_id: userId, }, @@ -216,7 +295,7 @@ export class DefaultService { * @returns User Successful Response * @throws ApiError */ - public static updateUserUsersUserIdPut({ + public static updateUserV1UsersUserIdPut({ userId, requestBody, }: { @@ -225,7 +304,7 @@ export class DefaultService { }): CancelablePromise { return __request(OpenAPI, { method: 'PUT', - url: '/users/{user_id}', + url: '/v1/users/{user_id}', path: { user_id: userId, }, @@ -253,14 +332,14 @@ export class DefaultService { * @returns DeleteUser Successful Response * @throws ApiError */ - public static deleteUserUsersUserIdDelete({ + public static deleteUserV1UsersUserIdDelete({ userId, }: { userId: string; }): CancelablePromise { return __request(OpenAPI, { method: 'DELETE', - url: '/users/{user_id}', + url: '/v1/users/{user_id}', path: { user_id: userId, }, @@ -287,14 +366,14 @@ export class DefaultService { * @returns Conversation Successful Response * @throws ApiError */ - public static getConversationConversationsConversationIdGet({ + public static getConversationV1ConversationsConversationIdGet({ conversationId, }: { conversationId: string; }): CancelablePromise { return __request(OpenAPI, { method: 'GET', - url: '/conversations/{conversation_id}', + url: '/v1/conversations/{conversation_id}', path: { conversation_id: conversationId, }, @@ -321,7 +400,7 @@ export class DefaultService { * @returns Conversation Successful Response * @throws ApiError */ - public static updateConversationConversationsConversationIdPut({ + public static updateConversationV1ConversationsConversationIdPut({ conversationId, requestBody, }: { @@ -330,7 +409,7 @@ export class DefaultService { }): CancelablePromise { return __request(OpenAPI, { method: 'PUT', - url: '/conversations/{conversation_id}', + url: '/v1/conversations/{conversation_id}', path: { conversation_id: conversationId, }, @@ -358,14 +437,14 @@ export class DefaultService { * @returns DeleteConversation Successful Response * @throws ApiError */ - public static deleteConversationConversationsConversationIdDelete({ + public static deleteConversationV1ConversationsConversationIdDelete({ conversationId, }: { conversationId: string; }): CancelablePromise { return __request(OpenAPI, { method: 'DELETE', - url: '/conversations/{conversation_id}', + url: '/v1/conversations/{conversation_id}', path: { conversation_id: conversationId, }, @@ -389,7 +468,7 @@ export class DefaultService { * @returns ConversationWithoutMessages Successful Response * @throws ApiError */ - public static listConversationsConversationsGet({ + public static listConversationsV1ConversationsGet({ offset, limit = 100, }: { @@ -398,7 +477,7 @@ export class DefaultService { }): CancelablePromise> { return __request(OpenAPI, { method: 'GET', - url: '/conversations/', + url: '/v1/conversations', query: { offset: offset, limit: limit, @@ -408,47 +487,6 @@ export class DefaultService { }, }); } - /** - * Upload File With Conversation - * (TO BE DEPRECATED) - * - * - * Uploads a file to a conversation. - * - * Args: - * conversation_id (str): Conversation ID. - * session (DBSessionDep): Database session. - * file (FastAPIUploadFile): File to be uploaded. - * - * Returns: - * UploadFile: Uploaded file. - * - * Raises: - * HTTPException: If the conversation with the given ID is not found. Status code 404. - * HTTPException: If the file wasn't uploaded correctly. Status code 500. - * @returns UploadFile Successful Response - * @throws ApiError - */ - public static uploadFileWithConversationConversationsConversationIdUploadFilePost({ - conversationId, - formData, - }: { - conversationId: string; - formData: Body_upload_file_with_conversation_conversations__conversation_id__upload_file_post; - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/conversations/{conversation_id}/upload_file', - path: { - conversation_id: conversationId, - }, - formData: formData, - mediaType: 'multipart/form-data', - errors: { - 422: `Validation Error`, - }, - }); - } /** * Upload File * Uploads and creates a File object. @@ -468,14 +506,14 @@ export class DefaultService { * @returns UploadFile Successful Response * @throws ApiError */ - public static uploadFileConversationsUploadFilePost({ + public static uploadFileV1ConversationsUploadFilePost({ formData, }: { - formData: Body_upload_file_conversations_upload_file_post; + formData: Body_upload_file_v1_conversations_upload_file_post; }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/conversations/upload_file', + url: '/v1/conversations/upload_file', formData: formData, mediaType: 'multipart/form-data', errors: { @@ -499,14 +537,14 @@ export class DefaultService { * @returns ListFile Successful Response * @throws ApiError */ - public static listFilesConversationsConversationIdFilesGet({ + public static listFilesV1ConversationsConversationIdFilesGet({ conversationId, }: { conversationId: string; }): CancelablePromise> { return __request(OpenAPI, { method: 'GET', - url: '/conversations/{conversation_id}/files', + url: '/v1/conversations/{conversation_id}/files', path: { conversation_id: conversationId, }, @@ -533,7 +571,7 @@ export class DefaultService { * @returns File Successful Response * @throws ApiError */ - public static updateFileConversationsConversationIdFilesFileIdPut({ + public static updateFileV1ConversationsConversationIdFilesFileIdPut({ conversationId, fileId, requestBody, @@ -544,7 +582,7 @@ export class DefaultService { }): CancelablePromise { return __request(OpenAPI, { method: 'PUT', - url: '/conversations/{conversation_id}/files/{file_id}', + url: '/v1/conversations/{conversation_id}/files/{file_id}', path: { conversation_id: conversationId, file_id: fileId, @@ -573,7 +611,7 @@ export class DefaultService { * @returns DeleteFile Successful Response * @throws ApiError */ - public static deleteFileConversationsConversationIdFilesFileIdDelete({ + public static deleteFileV1ConversationsConversationIdFilesFileIdDelete({ conversationId, fileId, }: { @@ -582,7 +620,7 @@ export class DefaultService { }): CancelablePromise { return __request(OpenAPI, { method: 'DELETE', - url: '/conversations/{conversation_id}/files/{file_id}', + url: '/v1/conversations/{conversation_id}/files/{file_id}', path: { conversation_id: conversationId, file_id: fileId, @@ -601,10 +639,10 @@ export class DefaultService { * @returns ManagedTool Successful Response * @throws ApiError */ - public static listToolsToolsGet(): CancelablePromise> { + public static listToolsV1ToolsGet(): CancelablePromise> { return __request(OpenAPI, { method: 'GET', - url: '/tools/', + url: '/v1/tools', }); } /** @@ -616,14 +654,14 @@ export class DefaultService { * @returns Deployment Successful Response * @throws ApiError */ - public static listDeploymentsDeploymentsGet({ + public static listDeploymentsV1DeploymentsGet({ all = false, }: { all?: boolean; }): CancelablePromise> { return __request(OpenAPI, { method: 'GET', - url: '/deployments/', + url: '/v1/deployments', query: { all: all, }, @@ -641,7 +679,7 @@ export class DefaultService { * @returns any Successful Response * @throws ApiError */ - public static setEnvVarsDeploymentsNameSetEnvVarsPost({ + public static setEnvVarsV1DeploymentsNameSetEnvVarsPost({ name, requestBody, }: { @@ -650,7 +688,7 @@ export class DefaultService { }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/deployments/{name}/set_env_vars', + url: '/v1/deployments/{name}/set_env_vars', path: { name: name, }, @@ -670,10 +708,10 @@ export class DefaultService { * @returns any Successful Response * @throws ApiError */ - public static listExperimentalFeaturesExperimentalFeaturesGet(): CancelablePromise { + public static listExperimentalFeaturesV1ExperimentalFeaturesGet(): CancelablePromise { return __request(OpenAPI, { method: 'GET', - url: '/experimental_features/', + url: '/v1/experimental_features/', }); } /** diff --git a/src/interfaces/coral_web/src/components/Citations/CitationDocument.tsx b/src/interfaces/coral_web/src/components/Citations/CitationDocument.tsx index 743b6029..dd380476 100644 --- a/src/interfaces/coral_web/src/components/Citations/CitationDocument.tsx +++ b/src/interfaces/coral_web/src/components/Citations/CitationDocument.tsx @@ -1,12 +1,9 @@ -import { Fragment, useContext, useState } from 'react'; +import { useState } from 'react'; -import { DEFAULT_CHAT_TOOL, Document } from '@/cohere-client'; -import IconButton from '@/components/IconButton'; -import { DocumentIcon, Text } from '@/components/Shared'; -import { Icon } from '@/components/Shared/Icon'; -import { ModalContext } from '@/context/ModalContext'; -import { useCitationsStore } from '@/stores'; -import { cn, getSafeUrl, getWebDomain } from '@/utils'; +import { Document } from '@/cohere-client'; +import { CitationDocumentHeader } from '@/components/Citations/CitationDocumentHeader'; +import { CitationDocumentSnippet } from '@/components/Citations/CitationDocumentSnippet'; +import { cn } from '@/utils'; type Props = { document: Document; @@ -14,72 +11,12 @@ type Props = { isExpandable?: boolean; }; -const getToolName = (toolId?: string) => { - // NOTE(jessica): if there is no toolId this means that this citation came from a time when we - // only supported the web-search connector, thus it is a safe default to fall back on. - if (!toolId || toolId === DEFAULT_CHAT_TOOL) { - return 'from the web'; - } - return `from ${toolId}`; -}; - -/** - * Segments the snippet by the text before the found keyword and the in-context keyword itself to - * allow for styling of the in-context keyword. - * - * E.g. if the snippet is "This is a snippet. Snippets are great." and the keyword is "snippet", - * the result will be: - * [ - * {beforeKeyword: "This is a ", snippetKeyword: "snippet"}, - * {beforeKeyword: ". ", snippetKeyword: "Snippet"}, - * {beforeKeyword: "s are great."} - * ] - */ -const getSnippetSegments = ( - snippet: string, - keyword: string -): { - beforeKeyword: string; - snippetKeyword?: string; -}[] => { - const originalSnippet = snippet; - - const normalizedSnippet = originalSnippet.toLowerCase(); - const normalizedKeyword = keyword.toLowerCase(); - - if (normalizedSnippet.includes(normalizedKeyword)) { - const sections = normalizedSnippet.split(normalizedKeyword); - let currentIndex = 0; - const sectionsAndKeyword = sections.reduce<{ beforeKeyword: string; snippetKeyword: string }[]>( - (acc, section) => { - const newIndices = [ - ...acc, - { - beforeKeyword: originalSnippet.slice(currentIndex, currentIndex + section.length), - snippetKeyword: originalSnippet.slice( - currentIndex + section.length, - currentIndex + section.length + keyword.length - ), - }, - ]; - currentIndex += section.length + keyword.length; - return newIndices; - }, - [] - ); - - return sectionsAndKeyword; - } else { - return [{ beforeKeyword: originalSnippet }]; - } -}; - /** * This component renders the document metadata of a citation, with the option of showing an expandable snippet. */ -export const CitationDocument: React.FC = ({ document, isExpandable = false, keyword }) => { +export const CitationDocument: React.FC = (props) => { + const { document, isExpandable = false } = props; const [isExpanded, setIsExpanded] = useState(true); - const { open } = useContext(ModalContext); if (!document) return null; @@ -87,61 +24,16 @@ export const CitationDocument: React.FC = ({ document, isExpandable = fal setIsExpanded((prev) => !prev); }; - const getSnippet = (beforeKeywordCharLimit?: number, lineLimitClass?: string) => { - if (!document.text) return null; - - const snippetSections = getSnippetSegments(document.text, keyword); - - return ( - - {snippetSections.map(({ beforeKeyword, snippetKeyword }, i) => { - return ( - - {i === 0 && - beforeKeywordCharLimit !== undefined && - beforeKeyword.length > beforeKeywordCharLimit && - snippetKeyword - ? `...${beforeKeyword.slice(-1 * beforeKeywordCharLimit)}` - : beforeKeyword} - {snippetKeyword ? {snippetKeyword} : null} - - ); - })} - - ); - }; - - const openFullSnippetModal = () => { - open({ - title: '', - content: ( -
- - {getSnippet()} -
- ), - kind: 'coral', - }); - }; - return (
- = ({ document, isExpandable = fal /> {isExpanded && isExpandable && ( -
- {getSnippet(30, 'line-clamp-3')} - -
- )} -
- ); -}; - -type CitationInfoProps = { - isExpandable: boolean; - isExpanded: boolean; - isSelected: boolean; - url: string; - title: string; - onToggleSnippet: VoidFunction; - documentId?: string; -}; - -/** - * Displays the document metadata of a citation. This includes the - * icon, title, and url. - */ -const CitationInfo: React.FC = ({ - documentId, - isExpandable, - isSelected, - isExpanded, - url, - title, - onToggleSnippet, -}) => { - const { - citations: { searchResults }, - } = useCitationsStore(); - - const hasUrl = url !== ''; - const safeUrl = hasUrl ? getSafeUrl(url) : undefined; - - return ( - diff --git a/src/interfaces/coral_web/src/components/Citations/CitationDocumentHeader.tsx b/src/interfaces/coral_web/src/components/Citations/CitationDocumentHeader.tsx new file mode 100644 index 00000000..4db5f3cf --- /dev/null +++ b/src/interfaces/coral_web/src/components/Citations/CitationDocumentHeader.tsx @@ -0,0 +1,160 @@ +import IconButton from '@/components/IconButton'; +import { DocumentIcon, Icon, IconName, Text } from '@/components/Shared'; +import { TOOL_FALLBACK_ICON, TOOL_ID_TO_DISPLAY_INFO, TOOL_INTERNET_SEARCH_ID } from '@/constants'; +import { cn, getSafeUrl, getWebDomain } from '@/utils'; + +const getWebSourceName = (toolId?: string) => { + if (!toolId) { + return ''; + } else if (toolId === TOOL_INTERNET_SEARCH_ID) { + return 'from the web'; + } + return `from ${toolId}`; +}; + +type Props = { + isExpandable: boolean; + isExpanded: boolean; + isSelected: boolean; + url: string; + title: string | undefined; + onToggleSnippet: VoidFunction; + toolId?: string; +}; + +/** + * @description Renders the document metadata of a citation. This includes the + * icon, title, and url. + * + * If the citation has a web url, we prioritize showing the domain name and favicon. + * This includes any connectors or the internet search tool. + * If the citation is a file or tool, we show the file or tool name and icon. + */ +export const CitationDocumentHeader: React.FC = ({ + toolId, + isExpandable, + isSelected, + isExpanded, + url, + title, + onToggleSnippet, +}) => { + // If the citation has a url we always show the favicon, domain name, and link. + // This is the case for most connectors or the internet search tool. + const hasUrl = url !== ''; + const safeUrl = hasUrl ? getSafeUrl(url) : undefined; + + const isFile = !toolId && !hasUrl && title; + const isTool = !!toolId && !hasUrl && !!TOOL_ID_TO_DISPLAY_INFO[toolId]; + const toolDisplayInfo = toolId ? TOOL_ID_TO_DISPLAY_INFO[toolId] : undefined; + // The title field is provided for web search documents and files, but not for tools. + const displayTitle = (title || toolDisplayInfo?.name) ?? toolId; + const icon: IconName | undefined = hasUrl + ? undefined + : isFile + ? 'file' + : isTool + ? toolDisplayInfo?.icon ?? TOOL_FALLBACK_ICON + : undefined; + + return ( + + ); +}; diff --git a/src/interfaces/coral_web/src/components/Citations/CitationDocumentSnippet.tsx b/src/interfaces/coral_web/src/components/Citations/CitationDocumentSnippet.tsx new file mode 100644 index 00000000..39492237 --- /dev/null +++ b/src/interfaces/coral_web/src/components/Citations/CitationDocumentSnippet.tsx @@ -0,0 +1,193 @@ +import { Fragment, useContext, useMemo } from 'react'; + +import { Document } from '@/cohere-client'; +import { CitationDocumentHeader } from '@/components/Citations/CitationDocumentHeader'; +import { B64Image } from '@/components/MarkdownImage'; +import { Markdown, Text } from '@/components/Shared'; +import { TOOL_PYTHON_INTERPRETER_ID } from '@/constants'; +import { ModalContext } from '@/context/ModalContext'; +import { cn } from '@/utils'; +import { PythonInterpreterOutputFile, parsePythonInterpreterToolFields } from '@/utils/tools'; + +type Props = { + document: Document; + keyword: string; + isExpandable?: boolean; +}; + +/** + * @descroption Segments the snippet by the text before the found keyword and the in-context + * keyword itself to allow for styling of the in-context keyword. + * + * E.g. if the snippet is "This is a snippet. Snippets are great." and the keyword is "snippet", + * the result will be: + * [ + * {beforeKeyword: "This is a ", snippetKeyword: "snippet"}, + * {beforeKeyword: ". ", snippetKeyword: "Snippet"}, + * {beforeKeyword: "s are great."} + * ] + */ + +const getSnippetSegments = (snippet: string | undefined, keyword: string) => { + if (!snippet) return null; + const normalizedSnippet = snippet.toLowerCase(); + const normalizedKeyword = keyword.toLowerCase(); + + if (!!normalizedKeyword && normalizedSnippet.includes(normalizedKeyword)) { + const sections = normalizedSnippet.split(normalizedKeyword); + let currentIndex = 0; + + const sectionsAndKeyword = sections.reduce<{ beforeKeyword: string; snippetKeyword: string }[]>( + (acc, section) => { + const newIndices = [ + ...acc, + { + beforeKeyword: snippet.slice(currentIndex, currentIndex + section.length), + snippetKeyword: snippet.slice( + currentIndex + section.length, + currentIndex + section.length + keyword.length + ), + }, + ]; + currentIndex += section.length + keyword.length; + return newIndices; + }, + [] + ); + + return sectionsAndKeyword; + } else { + return [{ beforeKeyword: snippet, snippetKeyword: undefined }]; + } +}; + +/** + * @description Renders the body of the citation document. It will either render + * the snippet provided or the fields provided by the tool. + */ +export const CitationDocumentSnippet: React.FC< + Props & { toolId?: string; onToggle: VoidFunction } +> = ({ toolId, document, keyword, onToggle }) => { + const { open } = useContext(ModalContext); + + const openFullSnippetModal = () => { + open({ + title: '', + content: ( +
+ + +
+ ), + kind: 'coral', + }); + }; + + if (toolId === TOOL_PYTHON_INTERPRETER_ID && document.fields) { + const { + success, + stdErr = '', + stdOut = '', + codeRuntime, + outputFile, + error, + } = parsePythonInterpreterToolFields(document); + + return ( +
+ {success !== undefined && (stdErr.length > 0 || stdOut.length > 0) && ( + + )} + {success !== undefined && !success && error && ( + + )} + {codeRuntime && } + {outputFile && } +
+ ); + } + + return ( +
+ + + +
+ ); +}; + +const Snippet: React.FC<{ + keyword: string; + snippet: string | undefined; + beforeKeywordCharLimit?: number; + lineLimitClass?: string; +}> = ({ snippet, keyword, beforeKeywordCharLimit, lineLimitClass }) => { + const snippetSections = useMemo(() => getSnippetSegments(snippet, keyword), [snippet, keyword]); + if (!snippetSections) return null; + + return ( + + {snippetSections.map(({ beforeKeyword, snippetKeyword }, i) => { + return ( + + {i === 0 && + beforeKeywordCharLimit !== undefined && + beforeKeyword.length > beforeKeywordCharLimit && + snippetKeyword + ? `...${beforeKeyword.slice(-1 * beforeKeywordCharLimit)}` + : beforeKeyword} + {snippetKeyword ? {snippetKeyword} : null} + + ); + })} + + ); +}; + +const ConsoleOutput: React.FC<{ type: string; message: string }> = ({ type, message }) => { + return ( + <> + + {type} + + + + ); +}; + +const CodeExecutionTime: React.FC<{ runtime: string }> = ({ runtime }) => { + return ( + + Execution time: {runtime}ms + + ); +}; + +const OutputFiles: React.FC<{ outputFile: PythonInterpreterOutputFile }> = ({ outputFile }) => { + return ( +
+ +
+ ); +}; diff --git a/src/interfaces/coral_web/src/components/Shared/DocumentIcon/DocumentIcon.tsx b/src/interfaces/coral_web/src/components/Shared/DocumentIcon/DocumentIcon.tsx index 24ff16c2..9cad8c28 100644 --- a/src/interfaces/coral_web/src/components/Shared/DocumentIcon/DocumentIcon.tsx +++ b/src/interfaces/coral_web/src/components/Shared/DocumentIcon/DocumentIcon.tsx @@ -1,11 +1,12 @@ import Image from 'next/image'; import { useEffect, useState } from 'react'; -import { Icon, IconProps } from '@/components/Shared'; +import { Icon, IconName, IconProps } from '@/components/Shared'; import { cn } from '@/utils'; type Props = { url: string; + icon?: IconName; className?: string; iconKind?: IconProps['kind']; }; @@ -32,9 +33,14 @@ const getPrimaryDomain = (url: string) => { }; /** - * Renders the favicon with a background for a given url or a relevant fallback. + * Renders the favicon for a given url or the given icon with a background. */ -export const DocumentIcon: React.FC = ({ url, className = '', iconKind = 'outline' }) => { +export const DocumentIcon: React.FC = ({ + icon, + url, + className = '', + iconKind = 'outline', +}) => { const [error, setError] = useState(null); const domain = getPrimaryDomain(url); @@ -44,7 +50,9 @@ export const DocumentIcon: React.FC = ({ url, className = '', iconKind = return (
- {domain === '' ? ( + {icon ? ( + + ) : domain === '' ? ( ) : error ? ( diff --git a/src/interfaces/coral_web/src/components/Shared/Text/Text.tsx b/src/interfaces/coral_web/src/components/Shared/Text/Text.tsx index 66e4af1e..395e45e8 100644 --- a/src/interfaces/coral_web/src/components/Shared/Text/Text.tsx +++ b/src/interfaces/coral_web/src/components/Shared/Text/Text.tsx @@ -29,6 +29,7 @@ export const STYLE_LEVEL_TO_CLASSES = { label: 'text-label uppercase font-code', caption: 'text-caption font-code', code: 'text-code font-code', + 'code-sm': 'text-code-sm font-code', }; const getStyleLevelClasses = (level: StyleAs | AsElement) => { diff --git a/src/interfaces/coral_web/src/hooks/chat.ts b/src/interfaces/coral_web/src/hooks/chat.ts index 146c5d72..31a402ab 100644 --- a/src/interfaces/coral_web/src/hooks/chat.ts +++ b/src/interfaces/coral_web/src/hooks/chat.ts @@ -42,6 +42,7 @@ import { isGroundingOn, replaceTextWithCitations, } from '@/utils'; +import { parsePythonInterpreterToolFields } from '@/utils/tools'; const USER_ERROR_MESSAGE = 'Something went wrong. This has been reported. '; const ABORT_REASON_USER = 'USER_ABORTED'; @@ -77,7 +78,12 @@ export const useChat = (config?: { onSend?: (msg: string) => void }) => { setConversation, setPendingMessage, } = useConversationStore(); - const { addSearchResults, addCitation, saveOutputFiles } = useCitationsStore(); + const { + citations: { outputFiles: savedOutputFiles }, + addSearchResults, + addCitation, + saveOutputFiles, + } = useCitationsStore(); const { files: { composerFiles }, clearComposerFiles, @@ -115,15 +121,50 @@ export const useChat = (config?: { onSend?: (msg: string) => void }) => { } }; - const mapOutputFiles = (outputFiles: { filename: string; b64_data: string }[] | undefined) => { + const mapDocuments = (documents: Document[]) => { + return documents.reduce<{ documentsMap: IdToDocument; outputFilesMap: OutputFiles }>( + ({ documentsMap, outputFilesMap }, doc) => { + const docId = doc?.document_id ?? ''; + const toolName = (doc?.tool_name ?? '').toLowerCase(); + const newOutputFilesMapEntry: OutputFiles = {}; + + if (toolName === TOOL_PYTHON_INTERPRETER_ID) { + const { outputFile } = parsePythonInterpreterToolFields(doc); + + if (outputFile) { + newOutputFilesMapEntry[outputFile.filename] = { + name: outputFile.filename, + data: outputFile.b64_data, + documentId: docId, + }; + } + } + return { + documentsMap: { ...documentsMap, [docId]: doc }, + outputFilesMap: { ...outputFilesMap, ...newOutputFilesMapEntry }, + }; + }, + { documentsMap: {}, outputFilesMap: {} } + ); + }; + + const mapOutputFiles = (outputFiles: { output_file: string; text: string }[] | undefined) => { return outputFiles?.reduce((outputFilesMap, outputFile) => { - return { - ...outputFilesMap, - [outputFile.filename]: { - name: outputFile.filename, - data: outputFile.b64_data, - }, - }; + try { + const outputFileObj: { filename: string; b64_data: string } = JSON.parse( + outputFile.output_file + ); + return { + ...outputFilesMap, + [outputFileObj.filename]: { + name: outputFileObj.filename, + data: outputFileObj.b64_data, + }, + }; + } catch (e) { + console.error('Could not parse output_file', e); + } + return outputFilesMap; }, {}); }; @@ -196,10 +237,10 @@ export const useChat = (config?: { onSend?: (msg: string) => void }) => { const data = eventData.data as StreamSearchResults; const documents = data?.documents ?? []; - documentsMap = documents.reduce( - (idToDoc, doc) => ({ ...idToDoc, [doc.document_id ?? '']: doc }), - {} - ); + const { documentsMap: newDocumentsMap, outputFilesMap: newOutputFilesMap } = + mapDocuments(documents); + documentsMap = { ...documentsMap, ...newDocumentsMap }; + outputFiles = { ...outputFiles, ...newOutputFilesMap }; break; } @@ -219,10 +260,12 @@ export const useChat = (config?: { onSend?: (msg: string) => void }) => { break; } + // This event only occurs when we're using experimental langchain multihop. case StreamEvent.TOOL_RESULT: { const data = eventData.data as StreamToolResult; - if (data.tool_name === TOOL_PYTHON_INTERPRETER_ID) { - outputFiles = { ...mapOutputFiles(data.result.output_files) }; + if (data.tool_name.toLowerCase() === TOOL_PYTHON_INTERPRETER_ID) { + const resultsWithOutputFile = data.result.filter((r: any) => r.output_file); + outputFiles = { ...mapOutputFiles(resultsWithOutputFile) }; saveOutputFiles(outputFiles); } @@ -281,15 +324,13 @@ export const useChat = (config?: { onSend?: (msg: string) => void }) => { // When we use documents for RAG, we don't get the documents split up by snippet // and their new ids until the final response. In the future, we will potentially // get the snippets in the citation-generation event and we can inject them there. - documentsMap = { - ...documentsMap, - ...(data?.documents ?? []).reduce( - (idToDoc, doc) => ({ ...idToDoc, [doc?.document_id ?? '']: doc }), - {} - ), - }; + const { documentsMap: newDocumentsMap, outputFilesMap: newOutputFilesMap } = + mapDocuments(data.documents ?? []); + documentsMap = { ...documentsMap, ...newDocumentsMap }; + outputFiles = { ...outputFiles, ...newOutputFilesMap }; saveCitations(generationId, citations, documentsMap); + saveOutputFiles({ ...savedOutputFiles, ...outputFiles }); const finalText = isRAGOn ? replaceTextWithCitations( diff --git a/src/interfaces/coral_web/src/pages/c/[id]/index.tsx b/src/interfaces/coral_web/src/pages/c/[id]/index.tsx index b44a0289..0bf51081 100644 --- a/src/interfaces/coral_web/src/pages/c/[id]/index.tsx +++ b/src/interfaces/coral_web/src/pages/c/[id]/index.tsx @@ -9,13 +9,16 @@ import { ConversationError } from '@/components/ConversationError'; import ConversationListPanel from '@/components/ConversationList/ConversationListPanel'; import { Layout, LayoutSection } from '@/components/Layout'; import { Spinner } from '@/components/Shared'; +import { TOOL_PYTHON_INTERPRETER_ID } from '@/constants'; import { BannerContext } from '@/context/BannerContext'; import { useConversation } from '@/hooks/conversation'; import { useListDeployments } from '@/hooks/deployments'; import { useExperimentalFeatures } from '@/hooks/experimentalFeatures'; import { appSSR } from '@/pages/_app'; import { useCitationsStore, useConversationStore, useParamsStore } from '@/stores'; +import { OutputFiles } from '@/stores/slices/citationsSlice'; import { createStartEndKey, mapHistoryToMessages } from '@/utils'; +import { parsePythonInterpreterToolFields } from '@/utils/tools'; type Props = { reactQueryState: DehydratedState; @@ -28,7 +31,7 @@ const ConversationPage: NextPage = () => { setParams, } = useParamsStore(); const { setConversation } = useConversationStore(); - const { addCitation, resetCitations } = useCitationsStore(); + const { addCitation, resetCitations, saveOutputFiles } = useCitationsStore(); const { data: experimentalFeatures } = useExperimentalFeatures(); const isLangchainModeOn = !!experimentalFeatures?.USE_EXPERIMENTAL_LANGCHAIN; const { setMessage } = useContext(BannerContext); @@ -45,6 +48,17 @@ const ConversationPage: NextPage = () => { } = useConversation({ conversationId: urlConversationId }); const { data: availableDeployments } = useListDeployments(); + useEffect(() => { + if (!deployment && availableDeployments && availableDeployments?.length > 0) { + setParams({ deployment: availableDeployments[0].name }); + } + }, [deployment]); + + useEffect(() => { + if (!isLangchainModeOn) return; + setMessage('You are using an experimental langchain multihop flow. There will be bugs.'); + }, [isLangchainModeOn]); + useEffect(() => { resetCitations(); @@ -60,34 +74,38 @@ const ConversationPage: NextPage = () => { conversation?.messages?.sort((a, b) => a.position - b.position) ); setConversation({ name: conversation.title, messages }); - }, [conversation?.id, setConversation]); - - useEffect(() => { - if (!deployment && availableDeployments && availableDeployments?.length > 0) { - setParams({ deployment: availableDeployments[0].name }); - } - }, [deployment]); - useEffect(() => { let documentsMap: { [documentId: string]: Document } = {}; + let outputFilesMap: OutputFiles = {}; + (conversation?.messages ?? []).forEach((message) => { - documentsMap = - message.documents?.reduce<{ [documentId: string]: Document }>( - (idToDoc, doc) => ({ ...idToDoc, [doc.document_id ?? '']: doc }), - {} - ) ?? {}; + message.documents?.forEach((doc) => { + const docId = doc.document_id ?? ''; + documentsMap[docId] = doc; + + const toolName = (doc.tool_name ?? '').toLowerCase(); + + if (toolName === TOOL_PYTHON_INTERPRETER_ID) { + const { outputFile } = parsePythonInterpreterToolFields(doc); + + if (outputFile) { + outputFilesMap[outputFile.filename] = { + name: outputFile.filename, + data: outputFile.b64_data, + documentId: docId, + }; + } + } + }); message.citations?.forEach((citation) => { const startEndKey = createStartEndKey(citation.start ?? 0, citation.end ?? 0); const documents = citation.document_ids?.map((id) => documentsMap[id]) ?? []; addCitation(message.generation_id ?? '', startEndKey, documents); }); }); - }, [conversation]); - useEffect(() => { - if (!isLangchainModeOn) return; - setMessage('You are using an experimental langchain multihop flow. There will be bugs.'); - }, [isLangchainModeOn]); + saveOutputFiles(outputFilesMap); + }, [conversation?.id, setConversation]); return ( diff --git a/src/interfaces/coral_web/src/stores/slices/citationsSlice.ts b/src/interfaces/coral_web/src/stores/slices/citationsSlice.ts index 44c09486..e151563b 100644 --- a/src/interfaces/coral_web/src/stores/slices/citationsSlice.ts +++ b/src/interfaces/coral_web/src/stores/slices/citationsSlice.ts @@ -32,7 +32,7 @@ interface SearchResults { [documentId: string]: Record; } -export type OutputFiles = { [name: string]: { name: string; data: string } }; +export type OutputFiles = { [name: string]: { name: string; data: string; documentId?: string } }; type State = { citationReferences: CitationReferences; diff --git a/src/interfaces/coral_web/src/themes/cohereTheme.js b/src/interfaces/coral_web/src/themes/cohereTheme.js index 7027e4e0..2281cc73 100644 --- a/src/interfaces/coral_web/src/themes/cohereTheme.js +++ b/src/interfaces/coral_web/src/themes/cohereTheme.js @@ -110,6 +110,7 @@ module.exports = { p: ['0.875rem', { letterSpacing: '0.0025em', lineHeight: '150%' }], // 14px - Paragraph 'p-lg': ['1rem', { letterSpacing: '0em', lineHeight: '150%' }], // 16px - Large Paragraph code: ['1rem', { letterSpacing: '0.03em', lineHeight: '136%' }], // 16px - Code + 'code-sm': ['0.75rem', { letterSpacing: '0.03em', lineHeight: '136%' }], // 12px - Small Code // Headings logo: ['1.5rem', { letterSpacing: '0em', lineHeight: '100%' }], // 24px - Logo Application 'h5-m': ['1.125rem', { letterSpacing: '0em', lineHeight: '136%' }], // 18px - Mobile Heading 5 diff --git a/src/interfaces/coral_web/src/utils/tools.ts b/src/interfaces/coral_web/src/utils/tools.ts new file mode 100644 index 00000000..7358a104 --- /dev/null +++ b/src/interfaces/coral_web/src/utils/tools.ts @@ -0,0 +1,78 @@ +import { Document } from '@/cohere-client'; + +type PythonInterpreterFieldsBase = { + snippet?: string; // citation snippet, will either be the stdout, stderr, or the file name +}; + +type PythonInterpreterImageFields = { + /** + * String representation of a json object with the following fields: + * - filename: string + * - b64_data: string + */ + output_file?: string; +}; + +type PythonInterpreterCodeFields = { + code_runtime?: string; + success?: string; // "True" or "False" + std_out?: string; + std_err?: string; + /** + * String representation of a json object with the following fields: + * - type: string (e.g. "ZeroDivisionError") + * - message: string (usually a stack trace) + */ + error?: string; +}; + +type PythonInterpreterFields = PythonInterpreterFieldsBase & + PythonInterpreterImageFields & + PythonInterpreterCodeFields; + +export type PythonInterpreterOutputFile = { filename: string; b64_data: string }; +export type PythonInterpreterCodeError = { type: string; message: string }; + +export const parsePythonInterpreterToolFields = (document: Document) => { + if (!document.fields) { + return { + snippet: undefined, + success: undefined, + codeRuntime: undefined, + stdErr: undefined, + stdOut: undefined, + error: undefined, + outputFile: undefined, + }; + } + + const fields = document.fields as PythonInterpreterFields; + let outputFile: PythonInterpreterOutputFile | undefined; + let error: PythonInterpreterCodeError | undefined; + + if (fields.output_file) { + try { + outputFile = JSON.parse(fields.output_file); + } catch (e) { + console.error('Could not parse output_file', e); + } + } + + if (fields.error) { + try { + error = JSON.parse(fields.error); + } catch (e) { + console.error('Could not parse error', e); + } + } + + return { + snippet: fields.snippet, + success: fields.success ? fields.success.toLowerCase() === 'true' : undefined, + codeRuntime: fields.code_runtime, + stdErr: fields.std_err, + stdOut: fields.std_out, + error, + outputFile, + }; +};