Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
neoxelox committed Dec 12, 2024
1 parent ab7901d commit 2e07d74
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Select,
Text,
Tooltip,
type ICommitContextType,
} from '@latitude-data/web-ui'

import { UseSelectDataset, type DatasetPreview } from './useSelectDataset'
Expand All @@ -33,15 +34,15 @@ function getTooltipValue(input: PlaygroundInput<'dataset'>) {

export function InputMapper({
document,
commitVersionUuid,
commit,
mappedInputs,
headersOptions,
isLoading,
onSelectHeader,
selectedDataset,
}: {
document: DocumentVersion
commitVersionUuid: string
commit: ICommitContextType['commit']
mappedInputs: DatasetSource['mappedInputs']
headersOptions: DatasetPreview['headersOptions']
onSelectHeader: UseSelectDataset['onSelectHeader']
Expand All @@ -53,7 +54,7 @@ export function InputMapper({
dataset: { inputs, copyToManual },
} = useDocumentParameters({
documentVersionUuid: document.documentUuid,
commitVersionUuid,
commitVersionUuid: commit.uuid,
})
return (
<ClientOnly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ROUTES } from '$/services/routes'
import { DocumentVersion } from '@latitude-data/core/browser'
import { Button, cn, Icon, Select } from '@latitude-data/web-ui'
import {
Button,
cn,
Icon,
Select,
type ICommitContextType,
} from '@latitude-data/web-ui'
import Link from 'next/link'

import { ParametersPaginationNav } from '../PaginationNav'
Expand All @@ -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
Expand Down Expand Up @@ -63,7 +69,7 @@ export function DatasetParams({
<div className={cn({ 'opacity-50': data.isLoading })}>
<InputMapper
document={document}
commitVersionUuid={commitVersionUuid}
commit={commit}
isLoading={data.isLoading}
mappedInputs={data.selectedRow.mappedInputs}
headersOptions={data.datasetPreview.headersOptions}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { useDocumentParameters } from '$/hooks/useDocumentParameters'
import { useGenerateDocumentLogDetailUrl } from '$/hooks/useGenerateDocumentLogDetailUrl'
import { DocumentLog, DocumentVersion } from '@latitude-data/core/browser'
import { Badge, cn, Icon, Skeleton, Text } from '@latitude-data/web-ui'
import {
Badge,
cn,
Icon,
Skeleton,
Text,
type ICommitContextType,
} from '@latitude-data/web-ui'
import { format } from 'date-fns'
import Link from 'next/link'

Expand Down Expand Up @@ -37,18 +44,18 @@ function usePaginatedDocumentLogUrl({

export function HistoryLogParams({
data,
commitVersionUuid,
commit,
document,
}: {
document: DocumentVersion
commitVersionUuid: string
commit: ICommitContextType['commit']
data: UseLogHistoryParams
}) {
const {
history: { inputs, setInput },
} = useDocumentParameters({
documentVersionUuid: document.documentUuid,
commitVersionUuid,
commitVersionUuid: commit.uuid,
})
const urlData = usePaginatedDocumentLogUrl({
selectedLog: data.selectedLog,
Expand Down Expand Up @@ -103,7 +110,12 @@ export function HistoryLogParams({
)}
</div>
<div className={cn({ 'opacity-50': data.isLoading })}>
<InputParams source='history' inputs={inputs} setInput={setInput} />
<InputParams
source='history'
inputs={inputs}
setInput={setInput}
commit={commit}
/>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ import {
Text,
TextArea,
Tooltip,
type ICommitContextType,
} from '@latitude-data/web-ui'

export function InputParams({
source,
inputs,
setInput,
commit,
prompt,
setPrompt,
disabled = false,
}: {
source: InputSource
inputs: Inputs<InputSource>
setInput: (param: string, value: PlaygroundInput<InputSource>) => void
commit: ICommitContextType['commit']
prompt?: string
setPrompt?: (prompt: string) => void
disabled?: boolean
Expand All @@ -59,7 +62,7 @@ export function InputParams({
setInput={setInput}
prompt={prompt}
setPrompt={setPrompt}
disabled={disabled}
disabled={commit.mergedAt !== null || disabled}
/>
)}
<Badge variant={includedInPrompt ? 'accent' : 'muted'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import { InputParams } from '../Input'

export function ManualParams({
document,
commitVersionUuid,
commit,
prompt,
setPrompt,
}: Props) {
const {
manual: { inputs, setInput },
} = useDocumentParameters({
documentVersionUuid: document.documentUuid,
commitVersionUuid,
commitVersionUuid: commit.uuid,
})
return (
<InputParams
source='manual'
inputs={inputs}
setInput={setInput}
commit={commit}
prompt={prompt}
setPrompt={setPrompt}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CollapsibleBox,
OnExpandFn,
TabSelector,
type ICommitContextType,
type TabSelectorOption,
} from '@latitude-data/web-ui'

Expand All @@ -33,7 +34,7 @@ const TABS: TabSelectorOption<InputSource>[] = [

export type Props = {
document: DocumentVersion
commitVersionUuid: string
commit: ICommitContextType['commit']
prompt: string
setPrompt: (prompt: string) => void
onExpand?: OnExpandFn
Expand All @@ -45,15 +46,15 @@ type ContentProps = Props & {

function ParamsTabs({
document,
commitVersionUuid,
commit,
prompt,
setPrompt,
datasetInfo,
historyInfo,
}: ContentProps) {
const { source, setSource } = useDocumentParameters({
documentVersionUuid: document.documentUuid,
commitVersionUuid,
commitVersionUuid: commit.uuid,
})

return (
Expand All @@ -67,23 +68,19 @@ function ParamsTabs({
{source === INPUT_SOURCE.manual && (
<ManualParams
document={document}
commitVersionUuid={commitVersionUuid}
commit={commit}
prompt={prompt}
setPrompt={setPrompt}
/>
)}
{source === INPUT_SOURCE.dataset && (
<DatasetParams
data={datasetInfo}
document={document}
commitVersionUuid={commitVersionUuid}
/>
<DatasetParams data={datasetInfo} document={document} commit={commit} />
)}
{source === INPUT_SOURCE.history && (
<HistoryLogParams
data={historyInfo}
document={document}
commitVersionUuid={commitVersionUuid}
commit={commit}
/>
)}
</div>
Expand All @@ -92,14 +89,14 @@ function ParamsTabs({

function CollapsedContentHeader({
document,
commitVersionUuid,
commit,
datasetInfo,
historyInfo,
}: ContentProps) {
const src = INPUT_SOURCE
const { source } = useDocumentParameters({
documentVersionUuid: document.documentUuid,
commitVersionUuid,
commitVersionUuid: commit.uuid,
})

if (source === src.manual) return null
Expand Down Expand Up @@ -138,11 +135,11 @@ function CollapsedContentHeader({
export function DocumentParams({ onExpand, ...props }: Props) {
const datasetInfo = useSelectDataset({
document: props.document,
commitVersionUuid: props.commitVersionUuid,
commitVersionUuid: props.commit.uuid,
})
const historyInfo = useLogHistoryParams({
document: props.document,
commitVersionUuid: props.commitVersionUuid,
commitVersionUuid: props.commit.uuid,
})

const contentProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function Playground({
dragDisabled={!expanded}
firstPane={
<DocumentParams
commitVersionUuid={commit.uuid}
commit={commit}
document={document}
prompt={prompt}
setPrompt={setPrompt}
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/prompt-manager/playground.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ When parameters are present in your prompt, they will automatically appear in th

### Parameter Types

Parameters can have different types, which will affect how they are populated and interpolated into the messages at runtime. You can either change the parameter types in the configuration section of the prompt, or in the playground.
Parameters can have different types. On the playground, and in shared prompts, this will affect how they are populated and interpolated into the messages. You can either change the parameter types in the configuration section of the prompt, or in the playground.

![Parameter Types](/assets/parameters_types.png)

Expand Down
2 changes: 1 addition & 1 deletion packages/web-ui/src/providers/CommitProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ const useCurrentCommit = () => {
return context
}

export { CommitProvider, useCurrentCommit }
export { CommitProvider, useCurrentCommit, type ICommitContextType }

0 comments on commit 2e07d74

Please sign in to comment.