diff --git a/apps/web/public/placeholder.png b/apps/web/public/placeholder.png new file mode 100644 index 000000000..8d580daec Binary files /dev/null and b/apps/web/public/placeholder.png differ 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 + + )} +
+
+