Skip to content

Commit

Permalink
Merge branch 'master' into DOCS-1062
Browse files Browse the repository at this point in the history
  • Loading branch information
J2-D2-3PO authored Dec 6, 2024
2 parents ee10c73 + 563fe3a commit 13d57ce
Show file tree
Hide file tree
Showing 17 changed files with 261 additions and 92 deletions.
6 changes: 3 additions & 3 deletions tests/integrations/instructor/instructor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_instructor_openai(
assert op_name_from_ref(call.op_name) == "openai.chat.completions.create"
output = call.output
output_arguments = json.loads(
output.choices[0].message.tool_calls[0].function.arguments
output["choices"][0]["message"]["tool_calls"][0]["function"]["arguments"]
)
assert "person_name" in output_arguments
assert "age" in output_arguments
Expand Down Expand Up @@ -112,7 +112,7 @@ async def extract_person(text: str) -> Person:
assert op_name_from_ref(call.op_name) == "openai.chat.completions.create"
output = call.output
output_arguments = json.loads(
output.choices[0].message.tool_calls[0].function.arguments
output["choices"][0]["message"]["tool_calls"][0]["function"]["arguments"]
)
assert "person_name" in output_arguments
assert "age" in output_arguments
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_instructor_iterable(
assert call.started_at < call.ended_at
assert op_name_from_ref(call.op_name) == "openai.chat.completions.create"
output = call.output
output_arguments = json.loads(output.choices[0].message.content)
output_arguments = json.loads(output["choices"][0]["message"]["content"])
assert "tasks" in output_arguments
assert "person_name" in output_arguments["tasks"][0]
assert "age" in output_arguments["tasks"][0]
Expand Down
36 changes: 18 additions & 18 deletions tests/integrations/openai/openai_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def test_openai_quickstart(client: weave.trace.weave_client.WeaveClient) -> None
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["requests"] == 1
assert usage["completion_tokens"] == 28
assert usage["prompt_tokens"] == 11
Expand Down Expand Up @@ -86,10 +86,10 @@ async def test_openai_async_quickstart(
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["requests"] == 1
assert usage["completion_tokens"] == 28
assert usage["prompt_tokens"] == 11
Expand Down Expand Up @@ -315,10 +315,10 @@ def test_openai_function_call(client: weave.trace.weave_client.WeaveClient) -> N
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["total_tokens"] == 117
assert usage["completion_tokens"] == 18
assert usage["prompt_tokens"] == 99
Expand Down Expand Up @@ -401,10 +401,10 @@ async def test_openai_function_call_async(
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["total_tokens"] == 117
assert usage["completion_tokens"] == 18
assert usage["prompt_tokens"] == 99
Expand Down Expand Up @@ -577,10 +577,10 @@ def test_openai_tool_call(client: weave.trace.weave_client.WeaveClient) -> None:
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["total_tokens"] == 117
assert usage["completion_tokens"] == 27
assert usage["prompt_tokens"] == 90
Expand Down Expand Up @@ -664,10 +664,10 @@ async def test_openai_tool_call_async(
assert call.started_at < call.ended_at # type: ignore

output = call.output
assert output.model == "gpt-4o-2024-05-13"
assert output.object == "chat.completion"
assert output["model"] == "gpt-4o-2024-05-13"
assert output["object"] == "chat.completion"

usage = call.summary["usage"][output.model] # type: ignore
usage = call.summary["usage"][output["model"]] # type: ignore
assert usage["total_tokens"] == 117
assert usage["completion_tokens"] == 27
assert usage["prompt_tokens"] == 90
Expand Down
3 changes: 3 additions & 0 deletions weave-js/src/assets/icons/icon-filled-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions weave-js/src/assets/icons/icon-not-visible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions weave-js/src/assets/icons/icon-pin-to-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions weave-js/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {ReactComponent as ImportExpandUncollapse} from '../../assets/icons/icon-
import {ReactComponent as ImportExportShareUpload} from '../../assets/icons/icon-export-share-upload.svg';
import {ReactComponent as ImportFacebookSocial} from '../../assets/icons/icon-facebook-social.svg';
import {ReactComponent as ImportFailed} from '../../assets/icons/icon-failed.svg';
import {ReactComponent as ImportFilledCircle} from '../../assets/icons/icon-filled-circle.svg';
import {ReactComponent as ImportFilterAlt} from '../../assets/icons/icon-filter-alt.svg';
import {ReactComponent as ImportFlashBolt} from '../../assets/icons/icon-flash-bolt.svg';
import {ReactComponent as ImportFolderAlt} from '../../assets/icons/icon-folder-alt.svg';
Expand Down Expand Up @@ -141,6 +142,7 @@ import {ReactComponent as ImportMolecule} from '../../assets/icons/icon-molecule
import {ReactComponent as ImportMusicAudio} from '../../assets/icons/icon-music-audio.svg';
import {ReactComponent as ImportNewSectionAbove} from '../../assets/icons/icon-new-section-above.svg';
import {ReactComponent as ImportNewSectionBelow} from '../../assets/icons/icon-new-section-below.svg';
import {ReactComponent as ImportNotVisible} from '../../assets/icons/icon-not-visible.svg';
import {ReactComponent as ImportNumber} from '../../assets/icons/icon-number.svg';
import {ReactComponent as ImportOpenNewTab} from '../../assets/icons/icon-open-new-tab.svg';
import {ReactComponent as ImportOpenaiLogo} from '../../assets/icons/icon-openai-logo.svg';
Expand All @@ -160,6 +162,7 @@ import {ReactComponent as ImportPaused} from '../../assets/icons/icon-paused.svg
import {ReactComponent as ImportPencilEdit} from '../../assets/icons/icon-pencil-edit.svg';
import {ReactComponent as ImportPhoto} from '../../assets/icons/icon-photo.svg';
import {ReactComponent as ImportPin} from '../../assets/icons/icon-pin.svg';
import {ReactComponent as ImportPinToRight} from '../../assets/icons/icon-pin-to-right.svg';
import {ReactComponent as ImportPlay} from '../../assets/icons/icon-play.svg';
import {ReactComponent as ImportPlotly} from '../../assets/icons/icon-plotly.svg';
import {ReactComponent as ImportPriorityCritical} from '../../assets/icons/icon-priority-critical.svg';
Expand Down Expand Up @@ -497,6 +500,9 @@ export const IconFacebookSocial = (props: SVGIconProps) => (
export const IconFailed = (props: SVGIconProps) => (
<ImportFailed {...updateIconProps(props)} />
);
export const IconFilledCircle = (props: SVGIconProps) => (
<ImportFilledCircle {...updateIconProps(props)} />
);
export const IconFilterAlt = (props: SVGIconProps) => (
<ImportFilterAlt {...updateIconProps(props)} />
);
Expand Down Expand Up @@ -698,6 +704,9 @@ export const IconNewSectionAbove = (props: SVGIconProps) => (
export const IconNewSectionBelow = (props: SVGIconProps) => (
<ImportNewSectionBelow {...updateIconProps(props)} />
);
export const IconNotVisible = (props: SVGIconProps) => (
<ImportNotVisible {...updateIconProps(props)} />
);
export const IconNumber = (props: SVGIconProps) => (
<ImportNumber {...updateIconProps(props)} />
);
Expand Down Expand Up @@ -755,6 +764,9 @@ export const IconPhoto = (props: SVGIconProps) => (
export const IconPin = (props: SVGIconProps) => (
<ImportPin {...updateIconProps(props)} />
);
export const IconPinToRight = (props: SVGIconProps) => (
<ImportPinToRight {...updateIconProps(props)} />
);
export const IconPlay = (props: SVGIconProps) => (
<ImportPlay {...updateIconProps(props)} />
);
Expand Down Expand Up @@ -1134,6 +1146,7 @@ const ICON_NAME_TO_ICON: Record<IconName, ElementType> = {
'export-share-upload': IconExportShareUpload,
'facebook-social': IconFacebookSocial,
failed: IconFailed,
'filled-circle': IconFilledCircle,
'filter-alt': IconFilterAlt,
'flash-bolt': IconFlashBolt,
'folder-alt': IconFolderAlt,
Expand Down Expand Up @@ -1201,6 +1214,7 @@ const ICON_NAME_TO_ICON: Record<IconName, ElementType> = {
'music-audio': IconMusicAudio,
'new-section-above': IconNewSectionAbove,
'new-section-below': IconNewSectionBelow,
'not-visible': IconNotVisible,
number: IconNumber,
'open-new-tab': IconOpenNewTab,
'openai-logo': IconOpenaiLogo,
Expand All @@ -1220,6 +1234,7 @@ const ICON_NAME_TO_ICON: Record<IconName, ElementType> = {
'pencil-edit': IconPencilEdit,
photo: IconPhoto,
pin: IconPin,
'pin-to-right': IconPinToRight,
play: IconPlay,
plotly: IconPlotly,
'priority-critical': IconPriorityCritical,
Expand Down
3 changes: 3 additions & 0 deletions weave-js/src/components/Icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export {
IconExportShareUpload,
IconFacebookSocial,
IconFailed,
IconFilledCircle,
IconFilterAlt,
IconFlashBolt,
IconFolderAlt,
Expand Down Expand Up @@ -141,6 +142,7 @@ export {
IconMusicAudio,
IconNewSectionAbove,
IconNewSectionBelow,
IconNotVisible,
IconNumber,
IconOpenaiLogo,
IconOpenNewTab,
Expand All @@ -160,6 +162,7 @@ export {
IconPencilEdit,
IconPhoto,
IconPin,
IconPinToRight,
IconPlay,
IconPlotly,
IconPriorityCritical,
Expand Down
3 changes: 3 additions & 0 deletions weave-js/src/components/Icon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const IconNames = {
ExportShareUpload: 'export-share-upload',
FacebookSocial: 'facebook-social',
Failed: 'failed',
FilledCircle: 'filled-circle',
FilterAlt: 'filter-alt',
FlashBolt: 'flash-bolt',
FolderAlt: 'folder-alt',
Expand Down Expand Up @@ -140,6 +141,7 @@ export const IconNames = {
MusicAudio: 'music-audio',
NewSectionAbove: 'new-section-above',
NewSectionBelow: 'new-section-below',
NotVisible: 'not-visible',
Number: 'number',
OpenNewTab: 'open-new-tab',
OpenaiLogo: 'openai-logo',
Expand All @@ -159,6 +161,7 @@ export const IconNames = {
PencilEdit: 'pencil-edit',
Photo: 'photo',
Pin: 'pin',
PinToRight: 'pin-to-right',
Play: 'play',
Plotly: 'plotly',
PriorityCritical: 'priority-critical',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Typography} from '@mui/material';
import Box from '@mui/material/Box';
import _ from 'lodash';
import React, {FC, useContext, useMemo} from 'react';
Expand All @@ -10,16 +9,16 @@ import {Button} from '../../../../../Button';
import {useWeaveflowRouteContext, WeaveflowPeekContext} from '../../context';
import {CustomWeaveTypeProjectContext} from '../../typeViews/CustomWeaveTypeDispatcher';
import {CallsTable} from '../CallsPage/CallsTable';
import {KeyValueTable} from '../common/KeyValueTable';
import {CallLink, opNiceName} from '../common/Links';
import {CenteredAnimatedLoader} from '../common/Loader';
import {CallLink} from '../common/Links';
import {useWFHooks} from '../wfReactInterface/context';
import {CallSchema} from '../wfReactInterface/wfDataModelHooksInterface';
import {ButtonOverlay} from './ButtonOverlay';
import {ExceptionDetails, getExceptionInfo} from './Exceptions';
import {ObjectViewerSection} from './ObjectViewerSection';
import {OpVersionText} from './OpVersionText';

const HEADER_HEIGHT_BUFFER = 60;

const Heading = styled.div`
color: ${MOON_800};
font-weight: 600;
Expand Down Expand Up @@ -104,7 +103,7 @@ export const CallDetails: FC<{
columns
);

const {singularChildCalls, multipleChildCallOpRefs} = useMemo(
const {multipleChildCallOpRefs} = useMemo(
() => callGrouping(!childCalls.loading ? childCalls.result ?? [] : []),
[childCalls.loading, childCalls.result]
);
Expand Down Expand Up @@ -133,6 +132,7 @@ export const CallDetails: FC<{
<Box
sx={{
flex: '0 0 auto',
maxHeight: `calc(100% - ${HEADER_HEIGHT_BUFFER}px)`,
p: 2,
}}>
<CustomWeaveTypeProjectContext.Provider
Expand All @@ -143,6 +143,9 @@ export const CallDetails: FC<{
<Box
sx={{
flex: '0 0 auto',
maxHeight: `calc(100% - ${
multipleChildCallOpRefs.length > 0 ? HEADER_HEIGHT_BUFFER : 0
}px)`,
p: 2,
}}>
{'traceback' in excInfo ? (
Expand Down Expand Up @@ -201,7 +204,6 @@ export const CallDetails: FC<{
sx={{
flex: '0 0 auto',
height: '500px',
maxHeight: '95%',
p: 2,
display: 'flex',
flexDirection: 'column',
Expand Down Expand Up @@ -240,33 +242,6 @@ export const CallDetails: FC<{
</Box>
);
})}
{childCalls.loading && <CenteredAnimatedLoader />}
{/* Disabling display of singular children while we decide if we want them here. */}
{false && singularChildCalls.length > 0 && (
<Box
sx={{
flex: '0 0 auto',
}}>
{multipleChildCallOpRefs.length === 0 ? (
<Typography pl={1}>Child calls</Typography>
) : (
<Typography pl={1}>Singular child calls</Typography>
)}
{singularChildCalls.map(c => (
<Box
key={c.callId}
sx={{
flex: '0 0 auto',
p: 2,
}}>
<KeyValueTable
headerTitle={opNiceName(c.spanName)}
data={getDisplayInputsAndOutput(c)}
/>
</Box>
))}
</Box>
)}
</Box>
</Box>
);
Expand Down
Loading

0 comments on commit 13d57ce

Please sign in to comment.