From 4599fc401ab901c365feec959a1e570506185888 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 11 Dec 2024 17:03:13 +0100 Subject: [PATCH] Docs and images in playground params --- apps/web/public/placeholder.png | Bin 0 -> 5842 bytes apps/web/src/actions/documents/upload.ts | 4 +- apps/web/src/actions/files/convert.ts | 22 ++ apps/web/src/actions/files/upload.ts | 22 ++ .../DocumentEditor/Editor/Playground/Chat.tsx | 6 +- .../DatasetParams/InputsMapper.tsx | 21 +- .../DocumentParams/DatasetParams/index.tsx | 16 +- .../DocumentParams/HistoryLogParams/index.tsx | 71 +++- .../Playground/DocumentParams/Input/index.tsx | 303 ++++++++++++++++-- .../DocumentParams/ManualParams/index.tsx | 14 +- .../Playground/DocumentParams/index.tsx | 41 +-- .../Editor/Playground/Preview.tsx | 2 +- .../Editor/Playground/index.tsx | 8 +- .../DocumentEditor/Editor/index.tsx | 33 +- .../EvaluationResultInfo/Messages.tsx | 8 +- .../DocumentLogs/DocumentLogInfo/Messages.tsx | 2 +- .../DocumentLogs/DocumentLogInfo/Metadata.tsx | 48 ++- .../src/components/EditorHeader/index.test.ts | 78 ----- .../web/src/components/EditorHeader/index.tsx | 58 +--- .../src/hooks/useDocumentParameters/index.ts | 27 +- .../recalculateInputs/index.test.ts | 196 ++++++++++- .../recalculateInputs/index.ts | 61 ++-- apps/web/src/hooks/useMetadata.ts | 4 +- apps/web/src/lib/promptMetadata.test.ts | 139 ++++++++ apps/web/src/lib/promptMetadata.ts | 49 +++ apps/web/src/stores/files.ts | 94 ++++++ docs/assets/parameters_document.png | Bin 0 -> 18096 bytes docs/assets/parameters_image.png | Bin 0 -> 17855 bytes docs/assets/parameters_text.png | Bin 0 -> 14984 bytes docs/assets/parameters_types.png | Bin 0 -> 63828 bytes docs/guides/prompt-manager/configuration.mdx | 9 + docs/guides/prompt-manager/playground.mdx | 52 ++- package.json | 4 +- packages/core/package.json | 4 +- packages/core/src/constants.ts | 8 + packages/core/src/helpers.ts | 9 +- packages/core/src/lib/disk.ts | 76 +++-- .../core/src/services/files/convert.test.ts | 71 ++++ .../files/{transform.ts => convert.ts} | 8 +- packages/core/src/services/files/index.ts | 3 +- .../core/src/services/files/transform.test.ts | 57 ---- .../core/src/services/files/upload.test.ts | 105 ++++++ packages/core/src/services/files/upload.ts | 52 +++ .../{transform => files/documents}/file.bin | Bin .../{transform => files/documents}/file.csv | 0 .../{transform => files/documents}/file.docx | Bin .../{transform => files/documents}/file.md | 0 .../{transform => files/documents}/file.odp | Bin .../{transform => files/documents}/file.ods | Bin .../{transform => files/documents}/file.odt | Bin .../{transform => files/documents}/file.pdf | Bin .../{transform => files/documents}/file.pptx | Bin .../documents}/file.promptl | 0 .../{transform => files/documents}/file.tsv | 0 .../{transform => files/documents}/file.txt | 0 .../{transform => files/documents}/file.xlsx | Bin .../src/tests/fixtures/files/images/file.gif | Bin 0 -> 3122 bytes .../src/tests/fixtures/files/images/file.jpeg | Bin 0 -> 634 bytes .../src/tests/fixtures/files/images/file.jpg | Bin 0 -> 634 bytes .../src/tests/fixtures/files/images/file.png | Bin 0 -> 142 bytes .../src/tests/fixtures/files/images/file.webp | Bin 0 -> 38 bytes packages/web-ui/package.json | 4 +- .../web-ui/src/ds/atoms/Dropzone/index.tsx | 18 +- .../src/ds/atoms/DropzoneInput/index.tsx | 80 +++-- packages/web-ui/src/ds/atoms/Icons/index.tsx | 8 + packages/web-ui/src/ds/atoms/Image/index.tsx | 27 ++ .../src/ds/atoms/Select/Primitives/index.tsx | 3 + packages/web-ui/src/ds/atoms/Select/index.tsx | 25 +- .../web-ui/src/ds/atoms/Tooltip/index.tsx | 5 +- packages/web-ui/src/ds/atoms/index.ts | 61 ++-- .../src/ds/molecules/Chat/Message/index.tsx | 225 +++++++++---- .../ds/molecules/Chat/MessageList/index.tsx | 2 +- .../web-ui/src/providers/CommitProvider.tsx | 2 +- pnpm-lock.yaml | 22 +- 74 files changed, 1755 insertions(+), 512 deletions(-) create mode 100644 apps/web/public/placeholder.png create mode 100644 apps/web/src/actions/files/convert.ts create mode 100644 apps/web/src/actions/files/upload.ts delete mode 100644 apps/web/src/components/EditorHeader/index.test.ts create mode 100644 apps/web/src/lib/promptMetadata.test.ts create mode 100644 apps/web/src/lib/promptMetadata.ts create mode 100644 apps/web/src/stores/files.ts create mode 100644 docs/assets/parameters_document.png create mode 100644 docs/assets/parameters_image.png create mode 100644 docs/assets/parameters_text.png create mode 100644 docs/assets/parameters_types.png create mode 100644 packages/core/src/services/files/convert.test.ts rename packages/core/src/services/files/{transform.ts => convert.ts} (94%) delete mode 100644 packages/core/src/services/files/transform.test.ts create mode 100644 packages/core/src/services/files/upload.test.ts create mode 100644 packages/core/src/services/files/upload.ts rename packages/core/src/tests/fixtures/{transform => files/documents}/file.bin (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.csv (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.docx (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.md (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.odp (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.ods (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.odt (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.pdf (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.pptx (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.promptl (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.tsv (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.txt (100%) rename packages/core/src/tests/fixtures/{transform => files/documents}/file.xlsx (100%) create mode 100644 packages/core/src/tests/fixtures/files/images/file.gif create mode 100644 packages/core/src/tests/fixtures/files/images/file.jpeg create mode 100644 packages/core/src/tests/fixtures/files/images/file.jpg create mode 100644 packages/core/src/tests/fixtures/files/images/file.png create mode 100644 packages/core/src/tests/fixtures/files/images/file.webp create mode 100644 packages/web-ui/src/ds/atoms/Image/index.tsx diff --git a/apps/web/public/placeholder.png b/apps/web/public/placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..8d580daecc4e9368983bed214425fe20b584880f GIT binary patch literal 5842 zcmbt&M^w{|6RjdhQHmfz>4X|cKuTzWl!Ov`mmew$1PE1>UR9(c9fEWzp@tSZ0r`{; zp$b7t1XOxeL=Z$C|IJ&!bKWdw?wz?a=geX@6Ki6m!^ptNaOu(|MwBkn?9wIbx=WX+ zim9$#WV|T6<`?0zx0#OSrJ7OhjSF(!#K1ypb8~Zle}8dtv8JZxF7?dhrAr_m6jH+? zU~YR>+LcS=R@8DvorZfxWR^(AGj^Xi>fcYzR-z|Db1gK>SSovRWj?e%hZf$9NBmUL zIer@oe|`00^8c&7>>5j>_iT~BY(ypo-+5IWnI>#=UYX!>jbr@O@6ekN|CTl3>E`JyHQQp^voTYG$OYs2^YzD>pTyB zoA_ffo1&)c6Ra==*oB+WY(%<2LR&pwte=JaTdx;=^|JE$?j^s(5iA9mXm>-qS#&DOYbQ^6uKfyiep zI-$(;6gWD2M}+vv6W7&ofn-5>i)dz+eMv8A-Don<8kaN~=vDtazWMt!WQO|W+@BVak{mmBXn?mx?)w0WSbU6+z!mjD3Tmm^+;R9 zp>wh8H5O9c6p0qdM0mh&mxSne2)g|>|C>&J+ zqeg(Hfiof1YTt7;;=VbtL?UEoG1Kg}E7uc@ZWwd|0n=ksi}6YybHSIn2t4aw=I<~P zjIxkjb+D$p9LLw(f%*Qj`?Y#%{~VL)D#V?r*&W~e+a9Mjs>(mLp~SLOSqPaP0f)A- zk0Id!yx9uX|Kis<+TOK8daIpp)5mS+C{%wayoNGbU%mJIUzAM5PC-Hrxf|u9L!J;3 zidr9dKv<`y{5c(Ob@4qliP2^aEPw*K6)gRIhHiCVnQ-r7p;iPC<<8pK^H3%(`Dy`Y zLWCYWLy4n82@c8T-(PB2bvn$zfJ~M(5D6dl6cbEGHhS2cW!iVRbJIm~SKyqLo~IgY z=EzqUTJOB}oGw^!Fa-4k;rtDA$dFX9g+seBS_y<6;nR%EEH!kKx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-DOv03-^QrvEC(_?wljVh*@A9CaB5Fw!5!lA>)5 z)0N@OfO8&iLDNAmwVE0)=ecjHUT*@Ii`y#XUd~eH*rIV|flh_RyoWE=bb4e|xo7Ff ztm?OUpkUr!RN%L^7r(4rr&aJzOERrr4B`dO+s?vb%&H-HUfgM0=XM7dD9h2$n24%e zX~$dW$G%zo!gwaIt5abWypbTKtY2-q7)@xH5>ClRRNdlUO{Hn-rRM8+T5RDSL~IC= z{_x;bNv}6|WDUQ3i0#K_O&^_#vAanjCV=6x1;(AFNo!vWyEi%2xV@gsR!afZTeP?f zg%`eE^0*84twlT_0SC?w;mrSXRBC2F}{Q1TH ztOmoBIv%aL0p*ZCxv-D+;e4qva;RIpwjB1&{L{5og)v+>`x*)5;VODZryZS?O~h8( zY|L>D2`@Hw(L|CR_Vgjoh?#|AP|94qw&&Y%vd4bu04L6V=b3{7^h?nX6q2rb)x}|S z($@)|Mpr2ORdR+{2pL`KZZVA*XLaGT^2SboJ;O_xUg!$!GySdhPV2IljxMB!B+806 z7LF*JrGB9c*2Ji~eNE0w$3B(VD?2#HR9dTiaZC>JqhHx39HrM!9+ zg^>Snmov}%!Zy^ij=DOYw7p7EEv}A##=m=06 xh*MAf<0qSU4Ro;a3$On1fB)tGFMA0)r&^^uTfQ9F-}1jfC@mvojpmc^{{u1;191QV literal 0 HcmV?d00001 diff --git a/apps/web/src/actions/documents/upload.ts b/apps/web/src/actions/documents/upload.ts index 19b807d99..60fffa75c 100644 --- a/apps/web/src/actions/documents/upload.ts +++ b/apps/web/src/actions/documents/upload.ts @@ -6,7 +6,7 @@ import { createNewDocument, defaultDocumentContent, } from '@latitude-data/core/services/documents/create' -import { transformFile } from '@latitude-data/core/services/files/transform' +import { convertFile } from '@latitude-data/core/services/files/convert' import { z } from 'zod' import { withProject } from '../procedures' @@ -28,7 +28,7 @@ export const uploadDocumentAction = withProject .getCommitByUuid({ uuid: input.commitUuid, projectId: ctx.project.id }) .then((r) => r.unwrap()) - const content = await transformFile(input.file).then((r) => r.unwrap()) + const content = await convertFile(input.file).then((r) => r.unwrap()) const { metadata } = await defaultDocumentContent({ workspace: ctx.workspace, }) diff --git a/apps/web/src/actions/files/convert.ts b/apps/web/src/actions/files/convert.ts new file mode 100644 index 000000000..e5bd5355b --- /dev/null +++ b/apps/web/src/actions/files/convert.ts @@ -0,0 +1,22 @@ +'use server' + +import { MAX_SIZE, MAX_UPLOAD_SIZE_IN_MB } from '@latitude-data/core/browser' +import { convertFile } from '@latitude-data/core/services/files/convert' +import { z } from 'zod' + +import { authProcedure } from '../procedures' + +export const convertFileAction = authProcedure + .createServerAction() + .input( + z.object({ + file: z.instanceof(File).refine(async (file) => { + return file?.size <= MAX_UPLOAD_SIZE_IN_MB + }, `Your file must be less than ${MAX_SIZE}MB in size. You can split it into smaller files and upload them separately.`), + }), + ) + .handler(async ({ input }) => { + const result = await convertFile(input.file) + + return result.unwrap() + }) diff --git a/apps/web/src/actions/files/upload.ts b/apps/web/src/actions/files/upload.ts new file mode 100644 index 000000000..c7078c42c --- /dev/null +++ b/apps/web/src/actions/files/upload.ts @@ -0,0 +1,22 @@ +'use server' + +import { MAX_SIZE, MAX_UPLOAD_SIZE_IN_MB } from '@latitude-data/core/browser' +import { uploadFile } from '@latitude-data/core/services/files/upload' +import { z } from 'zod' + +import { authProcedure } from '../procedures' + +export const uploadFileAction = authProcedure + .createServerAction() + .input( + z.object({ + file: z.instanceof(File).refine(async (file) => { + return file?.size <= MAX_UPLOAD_SIZE_IN_MB + }, `Your file must be less than ${MAX_SIZE}MB in size. You can split it into smaller files and upload them separately.`), + }), + ) + .handler(async ({ input, ctx }) => { + const result = await uploadFile(input.file, ctx.workspace) + + return result.unwrap() + }) diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx index fc6940e94..c58dd4055 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx @@ -13,10 +13,12 @@ import { type DocumentVersion, } from '@latitude-data/core/browser' import { + AnimatedDots, ChatTextArea, cn, ErrorMessage, Icon, + LineSeparator, Message, MessageList, Text, @@ -24,8 +26,6 @@ import { useAutoScroll, useCurrentCommit, useCurrentProject, - AnimatedDots, - LineSeparator, } from '@latitude-data/web-ui' import { LanguageModelUsage } from 'ai' import { readStreamableValue } from 'ai/rsc' @@ -245,7 +245,7 @@ export default function Chat({ > {(conversation?.messages.length ?? 0) >= chainLength && ( diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/InputsMapper.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/InputsMapper.tsx index 0c1f93e48..a71ec77fb 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/InputsMapper.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/InputsMapper.tsx @@ -1,3 +1,8 @@ +import { + DatasetSource, + PlaygroundInput, + useDocumentParameters, +} from '$/hooks/useDocumentParameters' import { Dataset, DocumentVersion } from '@latitude-data/core/browser' import { Badge, @@ -7,12 +12,8 @@ import { Select, Text, Tooltip, + type ICommitContextType, } from '@latitude-data/web-ui' -import { - DatasetSource, - PlaygroundInput, - useDocumentParameters, -} from '$/hooks/useDocumentParameters' import { UseSelectDataset, type DatasetPreview } from './useSelectDataset' @@ -31,7 +32,7 @@ function getTooltipValue(input: PlaygroundInput<'dataset'>) { export function InputMapper({ document, - commitVersionUuid, + commit, mappedInputs, headersOptions, isLoading, @@ -39,7 +40,7 @@ export function InputMapper({ selectedDataset, }: { document: DocumentVersion - commitVersionUuid: string + commit: ICommitContextType['commit'] mappedInputs: DatasetSource['mappedInputs'] headersOptions: DatasetPreview['headersOptions'] onSelectHeader: UseSelectDataset['onSelectHeader'] @@ -51,7 +52,7 @@ export function InputMapper({ dataset: { inputs, copyToManual }, } = useDocumentParameters({ documentVersionUuid: document.documentUuid, - commitVersionUuid, + commitVersionUuid: commit.uuid, }) return ( @@ -68,7 +69,7 @@ export function InputMapper({ className='grid col-span-2 grid-cols-subgrid gap-3 w-full items-start' key={idx} > -
+
{{{param}}} @@ -121,7 +122,7 @@ export function InputMapper({
) : ( - No inputs. Use {{ input_name }} to insert. + No inputs. Use {{input_name}} to insert. )}
diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/index.tsx index 050f9a287..ff58369e4 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/DocumentParams/DatasetParams/index.tsx @@ -1,6 +1,12 @@ -import { DocumentVersion } from '@latitude-data/core/browser' -import { Button, cn, Icon, Select } from '@latitude-data/web-ui' import { ROUTES } from '$/services/routes' +import { DocumentVersion } from '@latitude-data/core/browser' +import { + Button, + cn, + Icon, + Select, + type ICommitContextType, +} from '@latitude-data/web-ui' import Link from 'next/link' import { ParametersPaginationNav } from '../PaginationNav' @@ -22,11 +28,11 @@ function BlankSlate() { export function DatasetParams({ data, - commitVersionUuid, + commit, document, }: { document: DocumentVersion - commitVersionUuid: string + commit: ICommitContextType['commit'] data: UseSelectDataset }) { const selectedId = data.selectedDataset?.id @@ -61,7 +67,7 @@ export function DatasetParams({
- + +
+ {Object.keys(inputs).length > 0 ? ( +
+ {Object.entries(inputs).map(([param, input], idx) => { + const includedInPrompt = + input.metadata.includeInPrompt ?? true + return ( +
+
+ + {{{param}}} + + {!includedInPrompt && ( + }> + This variable is not included in the current prompt + + )} +
+
+