Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(prompts): add diff view on new prompt version (#5163)

Hassieb Pakzad3658620540fc
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f1c6094ddb..4fc6e3c266 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -51,7 +51,7 @@ importers:
next-auth:
specifier: ^4.24.11
zod:
specifier: ^3.23.8
version: 3.23.8
@@ -103,7 +103,7 @@ importers:
'@vercel/style-guide':
specifier: ^6.0.0
eslint-config-next:
specifier: ^14.2.15
@@ -213,7 +213,7 @@ importers:
version: 4.17.21
next-auth:
specifier: ^4.24.11
nodemailer:
specifier: ^6.9.15
version: 6.9.15
@@ -569,6 +569,9 @@ importers:
decimal.js:
specifier: ^10.4.3
version: 10.4.3
+ diff:
+ specifier: ^7.0.0
+ version: 7.0.0
dompurify:
specifier: ^3.1.5
version: 3.1.5
@@ -589,7 +592,7 @@ importers:
version: 0.27.4
langchain:
specifier: ^0.3.6
lodash:
specifier: ^4.17.21
version: 4.17.21
@@ -601,7 +604,7 @@ importers:
next-auth:
specifier: ^4.24.11
next-query-params:
specifier: ^5.0.1
@@ -705,7 +708,7 @@ importers:
'@testing-library/jest-dom':
specifier: ^6.4.6
'@testing-library/react':
specifier: ^15.0.7
@@ -715,6 +718,9 @@ importers:
'@types/cors':
specifier: ^2.8.17
version: 2.8.17
+ '@types/diff':
+ specifier: ^7.0.0
+ version: 7.0.0
'@types/dompurify':
specifier: ^3.0.5
version: 3.0.5
@@ -4839,6 +4845,9 @@ packages:
resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-sVpkpbnTJL9CYoDf4U+tHaQLe5HiTaHWY7m9FuYA7oMCHwC9ie0Vh9eIGapyzYrU3+pILlSY2fAc4elfw5m4dg==}
+
resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==}
@@ -6591,6 +6600,10 @@ packages:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
+ resolution: {integrity: sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==}
+ engines: {node: '>=0.3.1'}
+
resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}
engines: {node: '>=8'}
@@ -12307,7 +12320,7 @@ snapshots:
- '@aws-sdk/client-sts'
- aws-crt
- '@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/credential-provider-env': 3.667.0
'@aws-sdk/credential-provider-http': 3.667.0
@@ -12325,16 +12338,15 @@ snapshots:
- '@aws-sdk/client-sso-oidc'
- '@aws-sdk/client-sts'
- aws-crt
- optional: true
dependencies:
'@aws-sdk/credential-provider-env': 3.667.0
'@aws-sdk/credential-provider-http': 3.667.0
- '@aws-sdk/credential-provider-ini': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])
+ '@aws-sdk/credential-provider-ini': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])
'@aws-sdk/credential-provider-process': 3.667.0
- '@aws-sdk/credential-provider-sso': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))
- '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])
+ '@aws-sdk/credential-provider-sso': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))
+ '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])
'@aws-sdk/types': 3.667.0
'@smithy/credential-provider-imds': 3.2.4
'@smithy/property-provider': 3.1.7
@@ -12346,7 +12358,7 @@ snapshots:
- '@aws-sdk/client-sts'
- aws-crt
+ '@aws-sdk/[email protected](@aws-sdk/[email protected])':
dependencies:
'@aws-sdk/credential-provider-env': 3.667.0
'@aws-sdk/credential-provider-http': 3.667.0
@@ -12364,6 +12376,7 @@ snapshots:
- '@aws-sdk/client-sso-oidc'
- '@aws-sdk/client-sts'
- aws-crt
+ optional: true
'@aws-sdk/[email protected]':
dependencies:
@@ -13660,12 +13673,41 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/core': 10.1.0(@types/[email protected])
+ '@inquirer/type': 3.0.1(@types/[email protected])
+ '@types/node': 20.10.5
+ optional: true
+
dependencies:
'@inquirer/core': 10.1.0(@types/[email protected])
'@inquirer/type': 3.0.1(@types/[email protected])
'@types/node': 20.11.29
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/core': 10.1.0(@types/[email protected])
+ '@inquirer/type': 3.0.1(@types/[email protected])
+ '@types/node': 20.14.8
+ optional: true
+
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/figures': 1.0.8
+ '@inquirer/type': 3.0.1(@types/[email protected])
+ ansi-escapes: 4.3.2
+ cli-width: 4.1.0
+ mute-stream: 2.0.0
+ signal-exit: 4.1.0
+ strip-ansi: 6.0.1
+ wrap-ansi: 6.2.0
+ yoctocolors-cjs: 2.1.2
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
dependencies:
'@inquirer/figures': 1.0.8
@@ -13680,12 +13722,37 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/figures': 1.0.8
+ '@inquirer/type': 3.0.1(@types/[email protected])
+ ansi-escapes: 4.3.2
+ cli-width: 4.1.0
+ mute-stream: 2.0.0
+ signal-exit: 4.1.0
+ strip-ansi: 6.0.1
+ wrap-ansi: 6.2.0
+ yoctocolors-cjs: 2.1.2
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
'@inquirer/[email protected]': {}
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@types/node': 20.10.5
+ optional: true
+
dependencies:
'@types/node': 20.11.29
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@types/node': 20.14.8
+ optional: true
+
'@ioredis/[email protected]': {}
'@isaacs/[email protected]':
@@ -13718,42 +13785,6 @@ snapshots:
jest-util: 29.7.0
slash: 3.0.0
- dependencies:
- '@jest/console': 29.7.0
- '@jest/reporters': 29.7.0
- '@jest/test-result': 29.7.0
- '@jest/transform': 29.7.0
- '@jest/types': 29.6.3
- '@types/node': 20.14.8
- ansi-escapes: 4.3.2
- chalk: 4.1.2
- ci-info: 3.9.0
- exit: 0.1.2
- graceful-fs: 4.2.11
- jest-changed-files: 29.7.0
- jest-config: 29.7.0(@types/[email protected])
- jest-haste-map: 29.7.0
- jest-message-util: 29.7.0
- jest-regex-util: 29.6.3
- jest-resolve: 29.7.0
- jest-resolve-dependencies: 29.7.0
- jest-runner: 29.7.0
- jest-runtime: 29.7.0
- jest-snapshot: 29.7.0
- jest-util: 29.7.0
- jest-validate: 29.7.0
- jest-watcher: 29.7.0
- micromatch: 4.0.8
- pretty-format: 29.7.0
- slash: 3.0.0
- strip-ansi: 6.0.1
- transitivePeerDependencies:
- - babel-plugin-macros
- - supports-color
- - ts-node
- optional: true
-
dependencies:
'@jest/console': 29.7.0
@@ -13968,12 +13999,12 @@ snapshots:
- '@aws-sdk/client-sts'
- aws-crt
dependencies:
'@aws-sdk/client-bedrock-agent-runtime': 3.668.0
'@aws-sdk/client-bedrock-runtime': 3.668.0
'@aws-sdk/client-kendra': 3.668.0
- '@aws-sdk/credential-provider-node': 3.675.0
+ '@aws-sdk/credential-provider-node': 3.675.0(@aws-sdk/[email protected])
'@langchain/core': 0.3.18([email protected]([email protected]))
zod: 3.23.8
zod-to-json-schema: 3.23.5([email protected])
@@ -14261,7 +14292,7 @@ snapshots:
dependencies:
'@prisma/client': 5.22.0([email protected])
'@next/[email protected]': {}
@@ -16720,7 +16751,7 @@ snapshots:
lz-string: 1.5.0
pretty-format: 27.5.1
dependencies:
'@adobe/css-tools': 4.4.0
'@babel/runtime': 7.24.7
@@ -16734,7 +16765,7 @@ snapshots:
'@jest/globals': 29.7.0
'@types/jest': 29.5.12
- vitest: 2.1.2(@types/[email protected])
dependencies:
@@ -16875,6 +16906,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
dependencies:
'@types/trusted-types': 2.0.7
@@ -17382,7 +17415,7 @@ snapshots:
'@ungap/[email protected]': {}
dependencies:
'@babel/core': 7.24.3
'@babel/eslint-parser': 7.24.1(@babel/[email protected])([email protected])
@@ -17390,19 +17423,19 @@ snapshots:
'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
'@typescript-eslint/parser': 7.12.0([email protected])([email protected])
eslint-config-prettier: 9.1.0([email protected])
+ eslint-import-resolver-alias: 1.1.2([email protected])
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
eslint-plugin-eslint-comments: 3.2.0([email protected])
eslint-plugin-jsx-a11y: 6.8.0([email protected])
eslint-plugin-react: 7.34.1([email protected])
eslint-plugin-react-hooks: 4.6.0([email protected])
eslint-plugin-testing-library: 6.2.0([email protected])([email protected])
eslint-plugin-tsdoc: 0.2.17
eslint-plugin-unicorn: 51.0.1([email protected])
prettier-plugin-packagejson: 2.4.12([email protected])
optionalDependencies:
'@next/eslint-plugin-next': 14.2.15
@@ -17423,6 +17456,16 @@ snapshots:
chai: 5.1.1
tinyrainbow: 1.2.0
+ dependencies:
+ '@vitest/spy': 2.1.2
+ estree-walker: 3.0.3
+ magic-string: 0.30.11
+ optionalDependencies:
+ vite: 5.2.14(@types/[email protected])([email protected])
+ optional: true
+
dependencies:
'@vitest/spy': 2.1.2
@@ -17432,13 +17475,14 @@ snapshots:
vite: 5.2.14(@types/[email protected])([email protected])
dependencies:
'@vitest/spy': 2.1.2
estree-walker: 3.0.3
magic-string: 0.30.11
optionalDependencies:
- vite: 5.2.14(@types/[email protected])
+ vite: 5.2.14(@types/[email protected])([email protected])
optional: true
'@vitest/[email protected]':
@@ -18477,13 +18521,13 @@ snapshots:
crc-32: 1.2.2
readable-stream: 3.6.2
dependencies:
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
graceful-fs: 4.2.11
- jest-config: 29.7.0(@types/[email protected])
jest-util: 29.7.0
prompts: 2.4.2
transitivePeerDependencies:
@@ -18491,15 +18535,14 @@ snapshots:
- babel-plugin-macros
- supports-color
- ts-node
- optional: true
dependencies:
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
graceful-fs: 4.2.11
jest-util: 29.7.0
prompts: 2.4.2
transitivePeerDependencies:
@@ -18507,6 +18550,7 @@ snapshots:
- babel-plugin-macros
- supports-color
- ts-node
+ optional: true
@@ -18953,6 +18997,8 @@ snapshots:
+
dependencies:
path-type: 4.0.0
@@ -19282,7 +19328,7 @@ snapshots:
dependencies:
eslint: 8.57.0
- eslint-plugin-import: 2.29.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])
eslint-plugin-n: 16.6.2([email protected])
eslint-plugin-promise: 6.4.0([email protected])
@@ -19291,7 +19337,7 @@ snapshots:
eslint: 8.57.0
eslint-plugin-turbo: 1.13.4([email protected])
dependencies:
@@ -19308,7 +19354,7 @@ snapshots:
debug: 4.3.7([email protected])
enhanced-resolve: 5.17.1
eslint: 8.57.0
fast-glob: 3.3.2
get-tsconfig: 4.8.1
@@ -19325,7 +19371,7 @@ snapshots:
debug: 4.3.7([email protected])
enhanced-resolve: 5.17.1
eslint: 8.57.0
fast-glob: 3.3.2
get-tsconfig: 4.8.1
@@ -19337,7 +19383,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
@@ -19348,13 +19394,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 7.12.0([email protected])([email protected])
eslint: 8.57.0
- eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
transitivePeerDependencies:
- supports-color
@@ -19382,34 +19427,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
- hasown: 2.0.2
- is-core-module: 2.15.1
- is-glob: 4.0.3
- minimatch: 3.1.2
- object.fromentries: 2.0.8
- object.groupby: 1.0.3
- object.values: 1.2.0
- semver: 6.3.1
- tsconfig-paths: 3.15.0
- optionalDependencies:
- '@typescript-eslint/parser': 7.12.0([email protected])([email protected])
- transitivePeerDependencies:
- - eslint-import-resolver-typescript
- - eslint-import-resolver-webpack
- - supports-color
-
- dependencies:
- array-includes: 3.1.7
- array.prototype.findlastindex: 1.2.4
- array.prototype.flat: 1.3.2
- array.prototype.flatmap: 1.3.2
- debug: 3.2.7
- doctrine: 2.1.0
- eslint: 8.57.0
- eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -19426,13 +19444,13 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@typescript-eslint/utils': 5.62.0([email protected])([email protected])
eslint: 8.57.0
optionalDependencies:
'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
- jest: 29.7.0
+ jest: 29.7.0(@types/[email protected])([email protected])
transitivePeerDependencies:
- supports-color
- typescript
@@ -19474,12 +19492,12 @@ snapshots:
dependencies:
eslint: 8.57.0
globals: 13.24.0
optionalDependencies:
dependencies:
@@ -19561,13 +19579,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@typescript-eslint/utils': 7.3.1([email protected])([email protected])
eslint: 8.57.0
optionalDependencies:
'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
transitivePeerDependencies:
- supports-color
- typescript
@@ -20785,16 +20803,16 @@ snapshots:
- babel-plugin-macros
- supports-color
dependencies:
- '@jest/core': 29.7.0
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
chalk: 4.1.2
- create-jest: 29.7.0
exit: 0.1.2
import-local: 3.1.0
- jest-config: 29.7.0(@types/[email protected])
jest-util: 29.7.0
jest-validate: 29.7.0
yargs: 17.7.2
@@ -20803,18 +20821,17 @@ snapshots:
- babel-plugin-macros
- supports-color
- ts-node
- optional: true
dependencies:
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
chalk: 4.1.2
+ create-jest: 29.7.0(@types/[email protected])([email protected])
exit: 0.1.2
import-local: 3.1.0
jest-util: 29.7.0
jest-validate: 29.7.0
yargs: 17.7.2
@@ -20823,6 +20840,7 @@ snapshots:
- babel-plugin-macros
- supports-color
- ts-node
+ optional: true
dependencies:
@@ -20855,37 +20873,6 @@ snapshots:
- babel-plugin-macros
- supports-color
- dependencies:
- '@babel/core': 7.24.3
- '@jest/test-sequencer': 29.7.0
- '@jest/types': 29.6.3
- babel-jest: 29.7.0(@babel/[email protected])
- chalk: 4.1.2
- ci-info: 3.9.0
- deepmerge: 4.3.1
- glob: 7.2.3
- graceful-fs: 4.2.11
- jest-circus: 29.7.0([email protected])
- jest-environment-node: 29.7.0
- jest-get-type: 29.6.3
- jest-regex-util: 29.6.3
- jest-resolve: 29.7.0
- jest-runner: 29.7.0
- jest-util: 29.7.0
- jest-validate: 29.7.0
- micromatch: 4.0.8
- parse-json: 5.2.0
- pretty-format: 29.7.0
- slash: 3.0.0
- strip-json-comments: 3.1.1
- optionalDependencies:
- '@types/node': 20.14.8
- transitivePeerDependencies:
- - babel-plugin-macros
- - supports-color
- optional: true
-
dependencies:
'@babel/core': 7.24.3
@@ -21153,30 +21140,30 @@ snapshots:
merge-stream: 2.0.0
supports-color: 8.1.1
dependencies:
- '@jest/core': 29.7.0
'@jest/types': 29.6.3
import-local: 3.1.0
- jest-cli: 29.7.0
transitivePeerDependencies:
- '@types/node'
- babel-plugin-macros
- supports-color
- ts-node
- optional: true
dependencies:
'@jest/types': 29.6.3
import-local: 3.1.0
+ jest-cli: 29.7.0(@types/[email protected])([email protected])
transitivePeerDependencies:
- '@types/node'
- babel-plugin-macros
- supports-color
- ts-node
+ optional: true
@@ -21372,7 +21359,7 @@ snapshots:
- encoding
- openai
dependencies:
'@langchain/core': 0.3.18([email protected]([email protected]))
'@langchain/openai': 0.3.14(@langchain/[email protected]([email protected]([email protected])))
@@ -21389,7 +21376,7 @@ snapshots:
zod-to-json-schema: 3.23.5([email protected])
optionalDependencies:
'@langchain/anthropic': 0.3.8(@langchain/[email protected]([email protected]([email protected])))
- '@langchain/aws': 0.1.2(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/aws': 0.1.2(@aws-sdk/[email protected])(@langchain/[email protected]([email protected]([email protected])))
'@langchain/google-vertexai': 0.1.3(@langchain/[email protected]([email protected]([email protected])))([email protected])
axios: 1.7.7
handlebars: 4.7.8
@@ -22114,6 +22101,32 @@ snapshots:
optionalDependencies:
msgpackr-extract: 3.0.3
+ dependencies:
+ '@bundled-es-modules/cookie': 2.0.1
+ '@bundled-es-modules/statuses': 1.0.1
+ '@bundled-es-modules/tough-cookie': 0.1.6
+ '@inquirer/confirm': 5.0.2(@types/[email protected])
+ '@mswjs/interceptors': 0.37.1
+ '@open-draft/deferred-promise': 2.2.0
+ '@open-draft/until': 2.1.0
+ '@types/cookie': 0.6.0
+ '@types/statuses': 2.0.5
+ chalk: 4.1.2
+ graphql: 16.9.0
+ headers-polyfill: 4.0.3
+ is-node-process: 1.2.0
+ outvariant: 1.4.3
+ path-to-regexp: 6.3.0
+ strict-event-emitter: 0.5.1
+ type-fest: 4.27.0
+ yargs: 17.7.2
+ optionalDependencies:
+ typescript: 5.4.5
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
dependencies:
'@bundled-es-modules/cookie': 2.0.1
@@ -22139,6 +22152,32 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
+ dependencies:
+ '@bundled-es-modules/cookie': 2.0.1
+ '@bundled-es-modules/statuses': 1.0.1
+ '@bundled-es-modules/tough-cookie': 0.1.6
+ '@inquirer/confirm': 5.0.2(@types/[email protected])
+ '@mswjs/interceptors': 0.37.1
+ '@open-draft/deferred-promise': 2.2.0
+ '@open-draft/until': 2.1.0
+ '@types/cookie': 0.6.0
+ '@types/statuses': 2.0.5
+ chalk: 4.1.2
+ graphql: 16.9.0
+ headers-polyfill: 4.0.3
+ is-node-process: 1.2.0
+ outvariant: 1.4.3
+ path-to-regexp: 6.3.0
+ strict-event-emitter: 0.5.1
+ type-fest: 4.27.0
+ yargs: 17.7.2
+ optionalDependencies:
+ typescript: 5.4.5
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
@@ -22167,7 +22206,7 @@ snapshots:
dependencies:
type-fest: 2.19.0
dependencies:
'@babel/runtime': 7.26.0
'@panva/hkdf': 1.1.1
@@ -24541,12 +24580,12 @@ snapshots:
d3-time: 3.1.0
d3-timer: 3.0.1
dependencies:
cac: 6.7.14
debug: 4.3.7([email protected])
pathe: 1.1.2
- vite: 5.2.14(@types/[email protected])
+ vite: 5.2.14(@types/[email protected])([email protected])
transitivePeerDependencies:
- '@types/node'
- less
@@ -24574,7 +24613,24 @@ snapshots:
- supports-color
- terser
+ dependencies:
+ cac: 6.7.14
+ debug: 4.3.7([email protected])
+ pathe: 1.1.2
+ vite: 5.2.14(@types/[email protected])([email protected])
+ transitivePeerDependencies:
+ - '@types/node'
+ - less
+ - lightningcss
+ - sass
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ optional: true
+
dependencies:
esbuild: 0.20.2
postcss: 8.4.49
@@ -24582,6 +24638,7 @@ snapshots:
optionalDependencies:
'@types/node': 20.10.5
fsevents: 2.3.3
+ terser: 5.36.0
optional: true
@@ -24594,10 +24651,21 @@ snapshots:
fsevents: 2.3.3
terser: 5.36.0
+ dependencies:
+ esbuild: 0.20.2
+ postcss: 8.4.49
+ rollup: 4.13.0
+ optionalDependencies:
+ '@types/node': 20.14.8
+ fsevents: 2.3.3
+ terser: 5.36.0
+ optional: true
+
dependencies:
'@vitest/expect': 2.1.2
- '@vitest/mocker': 2.1.2(@vitest/[email protected])([email protected](@types/[email protected]))
'@vitest/pretty-format': 2.1.2
'@vitest/runner': 2.1.2
'@vitest/snapshot': 2.1.2
@@ -24612,11 +24680,12 @@ snapshots:
tinyexec: 0.3.0
tinypool: 1.0.1
tinyrainbow: 1.2.0
- vite: 5.2.14(@types/[email protected])
- vite-node: 2.1.2(@types/[email protected])
+ vite: 5.2.14(@types/[email protected])([email protected])
+ vite-node: 2.1.2(@types/[email protected])([email protected])
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 20.10.5
+ jsdom: 20.0.3
transitivePeerDependencies:
- less
- lightningcss
@@ -24662,6 +24731,41 @@ snapshots:
- supports-color
- terser
+ dependencies:
+ '@vitest/expect': 2.1.2
+ '@vitest/pretty-format': 2.1.2
+ '@vitest/runner': 2.1.2
+ '@vitest/snapshot': 2.1.2
+ '@vitest/spy': 2.1.2
+ '@vitest/utils': 2.1.2
+ chai: 5.1.1
+ debug: 4.3.7([email protected])
+ magic-string: 0.30.11
+ pathe: 1.1.2
+ std-env: 3.7.0
+ tinybench: 2.9.0
+ tinyexec: 0.3.0
+ tinypool: 1.0.1
+ tinyrainbow: 1.2.0
+ vite: 5.2.14(@types/[email protected])([email protected])
+ vite-node: 2.1.2(@types/[email protected])([email protected])
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@types/node': 20.14.8
+ jsdom: 20.0.3
+ transitivePeerDependencies:
+ - less
+ - lightningcss
+ - msw
+ - sass
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ optional: true
+
diff --git a/web/package.json b/web/package.json
index 3802f67bfd..d656328cdf 100644
--- a/web/package.json
+++ b/web/package.json
@@ -109,6 +109,7 @@
"date-fns": "^3.3.1",
"dd-trace": "^5.23.1",
"decimal.js": "^10.4.3",
+ "diff": "^7.0.0",
"dompurify": "^3.1.5",
"fastest-levenshtein": "^1.0.16",
"graphql": "^16.9.0",
@@ -158,6 +159,7 @@
"@testing-library/react": "^15.0.7",
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
+ "@types/diff": "^7.0.0",
"@types/dompurify": "^3.0.5",
"@types/eslint": "^8.56.7",
"@types/jest": "^29.5.12",
diff --git a/web/src/components/DiffViewer.tsx b/web/src/components/DiffViewer.tsx
new file mode 100644
index 0000000000..e6d80c3205
--- /dev/null
+++ b/web/src/components/DiffViewer.tsx
@@ -0,0 +1,183 @@
+import React, { useEffect, useState } from "react";
+import { Card, CardContent } from "@/src/components/ui/card";
+import { cn } from "@/src/utils/tailwind";
+import { diffWordsWithSpace } from "diff";
+
+type DiffLine = {
+ text: string;
+ type: "unchanged" | "removed" | "added" | "empty";
+ parts?: {
+ value: string;
+ type?: "removed" | "added";
+ }[];
+};
+
+type DiffViewerProps = {
+ oldString: string;
+ newString: string;
+ oldLabel?: string;
+ newLabel?: string;
+ className?: string;
+};
+
+const DIFF_COLORS = {
+ added: {
+ text: "bg-green-500/30",
+ line: "bg-green-500/10",
+ },
+ removed: {
+ text: "bg-destructive/60",
+ line: "bg-destructive/10",
+ },
+ empty: "bg-muted",
+} as const;
+
+const DiffViewer: React.FC<DiffViewerProps> = ({
+ oldString,
+ newString,
+ oldLabel = "Original Version",
+ newLabel = "New Version",
+ className,
+}) => {
+ const [diffLines, setDiffLines] = useState<{
+ left: DiffLine[];
+ right: DiffLine[];
+ }>({ left: [], right: [] });
+
+ useEffect(() => {
+ const left: DiffLine[] = [];
+ const right: DiffLine[] = [];
+
+ // Get the complete diff first
+ const changes = diffWordsWithSpace(oldString, newString, {});
+
+ // Group changes by line
+ const oldParts: { value: string; type?: "removed" }[][] = [[]];
+ const newParts: { value: string; type?: "added" }[][] = [[]];
+
+ changes.forEach((part) => {
+ const lines = part.value.split("\n");
+
+ lines.forEach((line, idx) => {
+ if (idx > 0) {
+ if (!part.added) oldParts.push([]);
+ if (!part.removed) newParts.push([]);
+ }
+
+ if (!part.added) {
+ oldParts[oldParts.length - 1].push({
+ value: line,
+ type: part.removed ? "removed" : undefined,
+ });
+ }
+ if (!part.removed) {
+ newParts[newParts.length - 1].push({
+ value: line,
+ type: part.added ? "added" : undefined,
+ });
+ }
+ });
+ });
+
+ // Convert parts to DiffLines
+ const maxLength = Math.max(oldParts.length, newParts.length);
+ for (let i = 0; i < maxLength; i++) {
+ const oldLineParts = oldParts[i] || [];
+ const newLineParts = newParts[i] || [];
+
+ if (oldLineParts.length === 0 && newLineParts.length === 0) {
+ left.push({ text: "", type: "empty" });
+ right.push({ text: "", type: "empty" });
+ continue;
+ }
+
+ const oldText = oldLineParts.map((p) => p.value).join("");
+ const newText = newLineParts.map((p) => p.value).join("");
+
+ if (oldText === newText) {
+ left.push({ text: oldText, type: "unchanged" });
+ right.push({ text: newText, type: "unchanged" });
+ } else {
+ left.push({
+ text: oldText,
+ type: oldText ? "removed" : "empty",
+ parts: oldLineParts.length ? oldLineParts : undefined,
+ });
+ right.push({
+ text: newText,
+ type: newText ? "added" : "empty",
+ parts: newLineParts.length ? newLineParts : undefined,
+ });
+ }
+ }
+
+ setDiffLines({ left, right });
+ }, [oldString, newString]);
+
+ const LineContent: React.FC<{ line: DiffLine }> = ({ line }) => {
+ const typeClasses = {
+ unchanged: "",
+ removed: DIFF_COLORS.removed.line,
+ added: DIFF_COLORS.added.line,
+ empty: DIFF_COLORS.empty,
+ };
+
+ return (
+ <div
+ className={cn(
+ "whitespace-pre px-4 py-1 font-mono text-xs",
+ typeClasses[line.type],
+ )}
+ >
+ {line.parts
+ ? line.parts.map((part, idx) => (
+ <span
+ key={idx}
+ className={part.type ? DIFF_COLORS[part.type].text : undefined}
+ >
+ {part.value}
+ </span>
+ ))
+ : line.text || "\u00A0"}
+ </div>
+ );
+ };
+
+ if (oldString === newString) {
+ return <div className="text-sm text-muted-foreground">No changes</div>;
+ }
+
+ return (
+ <div className={cn("w-full", className)}>
+ <Card>
+ <CardContent className="p-0">
+ <div className="grid grid-cols-2">
+ <div className="border-r">
+ <div className="border-b bg-muted px-4 py-2 text-xs font-semibold">
+ {oldLabel}
+ </div>
+ <div className="overflow-x-auto">
+ {diffLines.left.map((line, idx) => (
+ <LineContent key={`left-${idx}`} line={line} />
+ ))}
+ </div>
+ </div>
+
+ <div>
+ <div className="border-b bg-muted px-4 py-2 text-xs font-semibold">
+ {newLabel}
+ </div>
+ <div className="overflow-x-auto">
+ {diffLines.right.map((line, idx) => (
+ <LineContent key={`right-${idx}`} line={line} />
+ ))}
+ </div>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+ </div>
+ );
+};
+
+export default DiffViewer;
diff --git a/web/src/components/json-editor.tsx b/web/src/components/json-editor.tsx
index 500830c6fe..feabb803ac 100644
--- a/web/src/components/json-editor.tsx
+++ b/web/src/components/json-editor.tsx
@@ -13,10 +13,12 @@ export function JsonEditor({
editable = true,
lineWrapping = true,
className,
+ onBlur,
}: {
defaultValue: string;
onChange?: (value: string) => void;
editable?: boolean;
+ onBlur?: () => void;
lineWrapping?: boolean;
className?: string;
}) {
@@ -45,6 +47,7 @@ export function JsonEditor({
if (onChange) onChange(c);
setLinterEnabled(c !== "");
}}
+ onBlur={onBlur}
className={cn("overflow-hidden rounded-md border text-xs", className)}
editable={editable}
/>
diff --git a/web/src/features/prompts/components/NewPromptForm/ReviewPromptDialog.tsx b/web/src/features/prompts/components/NewPromptForm/ReviewPromptDialog.tsx
new file mode 100644
index 0000000000..5107ac34fc
--- /dev/null
+++ b/web/src/features/prompts/components/NewPromptForm/ReviewPromptDialog.tsx
@@ -0,0 +1,121 @@
+import React from "react";
+import { Button } from "@/src/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/src/components/ui/dialog";
+import { type Prompt } from "@langfuse/shared";
+import { type NewPromptFormSchemaType } from "./validation";
+import DiffViewer from "@/src/components/DiffViewer";
+
+type ReviewPromptDialogProps = {
+ initialPrompt: Prompt;
+ isLoading: boolean;
+ children: React.ReactNode;
+ onConfirm: () => void;
+ getNewPromptValues: () => NewPromptFormSchemaType;
+};
+
+export const ReviewPromptDialog: React.FC<ReviewPromptDialogProps> = (
+ props,
+) => {
+ const { initialPrompt, children, getNewPromptValues, onConfirm, isLoading } =
+ props;
+ const [newPromptValue, setNewPromptValues] =
+ React.useState<NewPromptFormSchemaType | null>(null);
+ const [open, setOpen] = React.useState<boolean>(false);
+
+ React.useEffect(() => {
+ if (open) {
+ setNewPromptValues(getNewPromptValues());
+ }
+ }, [open, setNewPromptValues, getNewPromptValues]);
+
+ const initialPromptContent: string =
+ initialPrompt.type === "text"
+ ? (initialPrompt.prompt as string)
+ : JSON.stringify(initialPrompt.prompt, null, 2);
+
+ const newPromptContent: string =
+ initialPrompt.type === "text"
+ ? (newPromptValue?.textPrompt ?? "")
+ : JSON.stringify(
+ newPromptValue?.chatPrompt.map((m) =>
+ Object.fromEntries(
+ Object.entries(m).filter(([k, _]) => k !== "id"),
+ ),
+ ) ?? "{}",
+ null,
+ 2,
+ );
+
+ const newConfig = JSON.stringify(
+ JSON.parse(newPromptValue?.config ?? "{}"),
+ null,
+ 2,
+ );
+
+ return (
+ <Dialog open={open} onOpenChange={(open) => setOpen(open)}>
+ <DialogTrigger asChild>{children}</DialogTrigger>
+ <DialogContent className="max-w-screen-xl">
+ <DialogHeader>
+ <DialogTitle>Review Prompt Changes</DialogTitle>
+ <DialogDescription className="flex items-center gap-2">
+ <span className="font-medium">{initialPrompt.name}</span>
+ </DialogDescription>
+ </DialogHeader>
+
+ <div className="max-h-[80vh] max-w-screen-xl space-y-6 overflow-y-auto">
+ <div className="space-y-6">
+ <div className="space-y-4">
+ <div>
+ <h3 className="mb-2 text-base font-medium">Content</h3>
+ <DiffViewer
+ oldString={initialPromptContent}
+ newString={newPromptContent}
+ oldLabel={`Previous content (v${initialPrompt.version})`}
+ newLabel="New content (draft)"
+ />
+ </div>
+ <div>
+ <h3 className="mb-2 text-base font-medium">Config</h3>
+ <DiffViewer
+ oldString={JSON.stringify(initialPrompt.config, null, 2)}
+ newString={newConfig ?? "failed"}
+ oldLabel={`Previous config (v${initialPrompt.version})`}
+ newLabel="New config (draft)"
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <DialogFooter className="flex flex-row">
+ <Button
+ type="button"
+ variant="secondary"
+ onClick={() => setOpen(false)}
+ className="min-w-[8rem]"
+ >
+ Cancel
+ </Button>
+ <Button
+ onClick={onConfirm}
+ loading={isLoading}
+ variant={newPromptValue?.isActive ? "destructive" : "default"}
+ className="min-w-[8rem]"
+ >
+ Save new version
+ {newPromptValue?.isActive ? " and promote to production" : ""}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/web/src/features/prompts/components/NewPromptForm/index.tsx b/web/src/features/prompts/components/NewPromptForm/index.tsx
index 25bee2d393..3aae42d83f 100644
--- a/web/src/features/prompts/components/NewPromptForm/index.tsx
+++ b/web/src/features/prompts/components/NewPromptForm/index.tsx
@@ -33,6 +33,7 @@ import {
getIsCharOrUnderscore,
} from "@langfuse/shared";
import { PromptChatMessages } from "./PromptChatMessages";
+import { ReviewPromptDialog } from "./ReviewPromptDialog";
import {
NewPromptFormSchema,
type NewPromptFormSchemaType,
@@ -94,6 +95,7 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
const form = useForm<NewPromptFormSchemaType>({
resolver: zodResolver(NewPromptFormSchema),
+ mode: "onTouched",
defaultValues,
});
@@ -356,6 +358,7 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
<JsonEditor
defaultValue={field.value}
onChange={field.onChange}
+ onBlur={field.onBlur}
editable
/>
<FormDescription>
@@ -392,16 +395,44 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
</FormItem>
)}
/>
- <Button
- type="submit"
- loading={createPromptMutation.isLoading}
- className="w-full"
- disabled={Boolean(
- !initialPrompt && form.formState.errors.name?.message,
- )} // Disable button if prompt name already exists. Check is dynamic and not part of zod schema
- >
- {!initialPrompt ? "Create prompt" : "Save prompt version"}
- </Button>
+ {initialPrompt ? (
+ <div className="flex flex-col gap-2">
+ <ReviewPromptDialog
+ initialPrompt={initialPrompt}
+ getNewPromptValues={form.getValues}
+ isLoading={createPromptMutation.isLoading}
+ onConfirm={form.handleSubmit(onSubmit)}
+ >
+ <Button
+ disabled={!form.formState.isValid}
+ variant="secondary"
+ className="w-full"
+ >
+ Review changes
+ </Button>
+ </ReviewPromptDialog>
+
+ <Button
+ type="submit"
+ loading={createPromptMutation.isLoading}
+ className="w-full"
+ disabled={!form.formState.isValid}
+ >
+ Save new prompt version
+ </Button>
+ </div>
+ ) : (
+ <Button
+ type="submit"
+ loading={createPromptMutation.isLoading}
+ className="w-full"
+ disabled={Boolean(
+ !initialPrompt && form.formState.errors.name?.message,
+ )} // Disable button if prompt name already exists. Check is dynamic and not part of zod schema
+ >
+ Create prompt
+ </Button>
+ )}
</form>
{formError && (
<p className="text-red text-center">
diff --git a/web/src/features/prompts/components/PromptVersionDiffDialog.tsx b/web/src/features/prompts/components/PromptVersionDiffDialog.tsx
new file mode 100644
index 0000000000..435864a129
--- /dev/null
+++ b/web/src/features/prompts/components/PromptVersionDiffDialog.tsx
@@ -0,0 +1,112 @@
+import React from "react";
+import { Button } from "@/src/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/src/components/ui/dialog";
+import { type Prompt } from "@langfuse/shared";
+import DiffViewer from "@/src/components/DiffViewer";
+import { FileDiffIcon } from "lucide-react";
+
+type PromptVersionDiffDialogProps = {
+ leftPrompt: Prompt;
+ rightPrompt: Prompt;
+ onClose: () => void;
+};
+
+export const PromptVersionDiffDialog: React.FC<PromptVersionDiffDialogProps> = (
+ props,
+) => {
+ const { leftPrompt, rightPrompt, onClose } = props;
+ const [open, setOpen] = React.useState<boolean>(false);
+
+ return (
+ <Dialog
+ open={open}
+ onOpenChange={(open) => {
+ setOpen(open);
+ if (!open) onClose();
+ }}
+ >
+ <DialogTrigger asChild>
+ <Button
+ variant="outline"
+ type="button"
+ size="icon"
+ className="h-7 w-7 px-0"
+ onClick={(event) => {
+ event.stopPropagation();
+ }}
+ title="Compare with selected prompt"
+ >
+ <FileDiffIcon className="h-4 w-4" />
+ </Button>
+ </DialogTrigger>
+
+ <DialogContent
+ className="max-w-screen-xl"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <DialogHeader>
+ <DialogTitle>
+ Changes v{leftPrompt.version} → v{rightPrompt.version}
+ </DialogTitle>
+
+ <DialogDescription className="flex items-center gap-2">
+ <span className="font-medium">Prompt {leftPrompt.name}</span>
+ </DialogDescription>
+ </DialogHeader>
+
+ <div className="max-h-[80vh] max-w-screen-xl space-y-6 overflow-y-auto">
+ <div className="space-y-6">
+ <div className="space-y-4">
+ <div>
+ <h3 className="mb-2 text-base font-medium">Content</h3>
+ <DiffViewer
+ oldString={
+ leftPrompt.type === "chat"
+ ? JSON.stringify(leftPrompt.prompt, null, 2)
+ : (leftPrompt.prompt as string)
+ }
+ newString={
+ rightPrompt.type === "chat"
+ ? JSON.stringify(rightPrompt.prompt, null, 2)
+ : (rightPrompt.prompt as string)
+ }
+ oldLabel={`v${leftPrompt.version}`}
+ newLabel={`v${rightPrompt.version}`}
+ />
+ </div>
+ <div>
+ <h3 className="mb-2 text-base font-medium">Config</h3>
+ <DiffViewer
+ oldString={JSON.stringify(leftPrompt.config, null, 2)}
+ newString={JSON.stringify(rightPrompt.config, null, 2)}
+ oldLabel={`v${leftPrompt.version}`}
+ newLabel={`v${rightPrompt.version}`}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <DialogFooter className="flex flex-row">
+ <Button
+ onClick={() => {
+ setOpen(false);
+ onClose();
+ }}
+ className="w-full"
+ >
+ Close
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/web/src/features/prompts/components/prompt-history.tsx b/web/src/features/prompts/components/prompt-history.tsx
index 07ddb880d9..a95fc7f5ef 100644
--- a/web/src/features/prompts/components/prompt-history.tsx
+++ b/web/src/features/prompts/components/prompt-history.tsx
@@ -5,10 +5,12 @@ import { PRODUCTION_LABEL } from "@/src/features/prompts/constants";
import { type RouterOutputs } from "@/src/utils/api";
import { type NextRouter, useRouter } from "next/router";
import { useState } from "react";
+import { PromptVersionDiffDialog } from "./PromptVersionDiffDialog";
const PromptHistoryTraceNode = (props: {
index: number;
prompt: RouterOutputs["prompts"]["allVersions"]["promptVersions"][number];
+ currentPrompt?: RouterOutputs["prompts"]["allVersions"]["promptVersions"][number];
currentPromptVersion: number | undefined;
setCurrentPromptVersion: (version: number | undefined) => void;
router: NextRouter;
@@ -72,6 +74,14 @@ const PromptHistoryTraceNode = (props: {
</div>
{(isHovered || props.currentPromptVersion === prompt.version) && (
<div className="flex flex-row justify-end space-x-1">
+ {props.currentPrompt &&
+ props.currentPromptVersion !== prompt.version ? (
+ <PromptVersionDiffDialog
+ leftPrompt={prompt}
+ rightPrompt={props.currentPrompt}
+ onClose={() => setIsHovered(false)}
+ />
+ ) : null}
<SetPromptVersionLabels
prompt={prompt}
isOpen={isLabelPopoverOpen}
@@ -100,6 +110,10 @@ export const PromptHistoryNode = (props: {
}) => {
const router = useRouter();
const projectId = router.query.projectId as string;
+ const currentPrompt = props.prompts.find(
+ (p) => p.version === props.currentPromptVersion,
+ );
+
return (
<div className="w-full flex-1">
{props.prompts.map((prompt, index) => (
@@ -107,6 +121,7 @@ export const PromptHistoryNode = (props: {
key={prompt.id}
index={index}
prompt={prompt}
+ currentPrompt={currentPrompt}
currentPromptVersion={props.currentPromptVersion}
setCurrentPromptVersion={props.setCurrentPromptVersion}
router={router}