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 and hughcrt committed Jun 6, 2024
1 parent 82d9915 commit a6c2822
Showing 1 changed file with 15 additions and 6 deletions.
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 a6c2822

Please sign in to comment.