-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modal to import logs while testing the evaluation in the editor
- Loading branch information
Showing
47 changed files
with
814 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use server' | ||
|
||
import { ProviderLogsRepository } from '@latitude-data/core/repositories' | ||
import { z } from 'zod' | ||
|
||
import { authProcedure } from '../procedures' | ||
|
||
export const getProviderLogsAction = authProcedure | ||
.createServerAction() | ||
.input( | ||
z.object({ | ||
documentUuid: z.string().optional(), | ||
documentLogUuid: z.string().optional(), | ||
}), | ||
) | ||
.handler(async ({ input, ctx }) => { | ||
const { documentUuid, documentLogUuid } = input | ||
const scope = new ProviderLogsRepository(ctx.workspace.id) | ||
|
||
let result | ||
if (documentLogUuid) { | ||
result = await scope | ||
.findByDocumentLogUuid(documentLogUuid, { limit: 1000 }) | ||
.then((r) => r.unwrap()) | ||
} else if (documentUuid) { | ||
result = await scope | ||
.findByDocumentUuid(documentUuid) | ||
.then((r) => r.unwrap()) | ||
} else { | ||
result = await scope.findAll({ limit: 1000 }).then((r) => r.unwrap()) | ||
} | ||
|
||
return result | ||
}) |
17 changes: 0 additions & 17 deletions
17
apps/web/src/actions/providerLogs/getProviderLogsForDocumentLogAction.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
.../[evaluationUuid]/editor/_components/EvaluationEditor/Editor/Playground/Preview/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { useEffect, useRef, useState } from 'react' | ||
|
||
import { | ||
Chain, | ||
Conversation, | ||
ConversationMetadata, | ||
} from '@latitude-data/compiler' | ||
import { | ||
Button, | ||
ErrorMessage, | ||
Message, | ||
Text, | ||
Tooltip, | ||
useAutoScroll, | ||
} from '@latitude-data/web-ui' | ||
|
||
export default function Preview({ | ||
metadata, | ||
parameters, | ||
runPrompt, | ||
}: { | ||
metadata: ConversationMetadata | undefined | ||
parameters: Record<string, unknown> | ||
runPrompt: () => void | ||
}) { | ||
const [conversation, setConversation] = useState<Conversation | undefined>( | ||
undefined, | ||
) | ||
const [completed, setCompleted] = useState(true) | ||
const [error, setError] = useState<Error | undefined>(undefined) | ||
const containerRef = useRef<HTMLDivElement>(null) | ||
useAutoScroll(containerRef, { startAtBottom: true }) | ||
|
||
useEffect(() => { | ||
if (!metadata) return | ||
if (metadata.errors.length > 0) return | ||
|
||
const chain = new Chain({ | ||
prompt: metadata.resolvedPrompt, | ||
parameters, | ||
}) | ||
|
||
chain | ||
.step() | ||
.then(({ conversation, completed }) => { | ||
setError(undefined) | ||
setConversation(conversation) | ||
setCompleted(completed) | ||
}) | ||
.catch((error) => { | ||
setConversation(undefined) | ||
setCompleted(true) | ||
setError(error) | ||
}) | ||
}, [metadata, parameters]) | ||
|
||
return ( | ||
<div | ||
ref={containerRef} | ||
className='flex flex-col gap-3 h-full overflow-y-auto' | ||
> | ||
<Text.H6M>Preview</Text.H6M> | ||
{(conversation?.messages ?? []) | ||
.filter((message) => message.role === 'assistant') | ||
.map((message, index) => ( | ||
<Message key={index} role={message.role} content={message.content} /> | ||
))} | ||
{error !== undefined && <ErrorMessage error={error} />} | ||
{!completed && ( | ||
<div className='w-full py-1 px-4 bg-secondary rounded-lg'> | ||
<Text.H6 color='foregroundMuted'> | ||
Showing the first step. Other steps will show after running. | ||
</Text.H6> | ||
</div> | ||
)} | ||
|
||
<div className='flex flex-row w-full items-center justify-center'> | ||
{error || (metadata?.errors.length ?? 0) > 0 ? ( | ||
<Tooltip | ||
side='bottom' | ||
trigger={ | ||
<Button fancy disabled> | ||
Run prompt | ||
</Button> | ||
} | ||
> | ||
There are errors in your prompt. Please fix them before running. | ||
</Tooltip> | ||
) : ( | ||
<Button fancy onClick={runPrompt}> | ||
Run prompt | ||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.