-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into griffin/feedback-replace-ts
- Loading branch information
Showing
17 changed files
with
601 additions
and
24 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
95 changes: 95 additions & 0 deletions
95
...s/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundPage.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,95 @@ | ||
import {Box} from '@mui/material'; | ||
import {WeaveLoader} from '@wandb/weave/common/components/WeaveLoader'; | ||
import React, {useEffect, useMemo, useState} from 'react'; | ||
|
||
import {SimplePageLayout} from '../common/SimplePageLayout'; | ||
import {useWFHooks} from '../wfReactInterface/context'; | ||
import {DEFAULT_SYSTEM_MESSAGE, usePlaygroundState} from './usePlaygroundState'; | ||
|
||
export type PlaygroundPageProps = { | ||
entity: string; | ||
project: string; | ||
callId: string; | ||
}; | ||
|
||
export const PlaygroundPage = (props: PlaygroundPageProps) => { | ||
return ( | ||
<SimplePageLayout | ||
title={'Playground (dev)'} | ||
hideTabsIfSingle | ||
tabs={[ | ||
{ | ||
label: 'main', | ||
content: <PlaygroundPageInner {...props} />, | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export const PlaygroundPageInner = (props: PlaygroundPageProps) => { | ||
const { | ||
setPlaygroundStateFromTraceCall, | ||
playgroundStates, | ||
setPlaygroundStateField, | ||
} = usePlaygroundState(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [settingsTab, setSettingsTab] = useState<number | null>(null); | ||
|
||
const {useCall} = useWFHooks(); | ||
const call = useCall( | ||
useMemo(() => { | ||
return props.callId | ||
? { | ||
entity: props.entity, | ||
project: props.project, | ||
callId: props.callId, | ||
} | ||
: null; | ||
}, [props.entity, props.project, props.callId]) | ||
); | ||
|
||
useEffect(() => { | ||
if (!call.loading && call.result) { | ||
if (call.result.traceCall?.inputs) { | ||
setPlaygroundStateFromTraceCall(call.result.traceCall); | ||
} | ||
} else if ( | ||
playgroundStates.length === 1 && | ||
!playgroundStates[0].traceCall.project_id | ||
) { | ||
setPlaygroundStateField(0, 'traceCall', { | ||
inputs: { | ||
messages: [DEFAULT_SYSTEM_MESSAGE], | ||
}, | ||
project_id: `${props.entity}/${props.project}`, | ||
}); | ||
} | ||
// Only set the call the first time the page loads, and we get the call | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [props.callId]); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
height: '100%', | ||
width: '100%', | ||
}}> | ||
{call.loading ? ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
height: '100%', | ||
width: '100%', | ||
}}> | ||
<WeaveLoader /> | ||
</Box> | ||
) : ( | ||
<div>Playground</div> | ||
)} | ||
{settingsTab !== null && <div>Settings</div>} | ||
</Box> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/index.ts
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 @@ | ||
export * from './PlaygroundPage'; |
Oops, something went wrong.