Skip to content

Commit

Permalink
Open in playground copy tools & output (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt authored May 24, 2024
1 parent b974325 commit fc332dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion packages/frontend/components/blocks/RunInputOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export default function RunInputOutput({
? true
: org?.plan === "team" || org?.plan === "custom"

console.log(run)
return (
<ErrorBoundary>
<Stack>
Expand Down
21 changes: 15 additions & 6 deletions packages/frontend/pages/prompts/[[...id]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,17 @@ function Playground() {
const run = await fetcher.get(`/runs/${clone}?projectId=${project?.id}`)

if (run?.input) {
setTemplateVersion({
// ...templateVersion,
content: run.input,
extra: { ...run.params, model: run.name },
})

setTemplate({ mode: "openai" })

setOutput(run.output)
setTemplateVersion({ ...templateVersion, content: run.input })

setTemplate({ mode: "openai", extra: run.params })
setOutputTokens(run.tokens?.completion)
}

setLoading(false)
Expand Down Expand Up @@ -375,11 +382,13 @@ function Playground() {
setStreaming(false)
}

// reset output when the template or template version changes
// reset output when the template or template version changes, but not if cloned
useEffect(() => {
setOutput(null)
setError(null)
setOutputTokens(0)
if (!router.query.clone) {
setOutput(null)
setError(null)
setOutputTokens(0)
}
}, [
template?.id,
templateVersion?.id,
Expand Down

0 comments on commit fc332dc

Please sign in to comment.