Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weave): playground #2854

Draft
wants to merge 94 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
bdc34ae
Adds weave_call_id, and option to not track
jwlee64 Oct 31, 2024
1b67b83
Merge branch 'master' into josiah/completions
jwlee64 Oct 31, 2024
9ffdb8f
init
jwlee64 Nov 4, 2024
b44f69d
Merge branch 'josiah/completions' into josiah/playground-full
jwlee64 Nov 4, 2024
0b7ba7a
add weave-call-id
jwlee64 Nov 4, 2024
4ea5917
Merge branch 'josiah/completions' into josiah/playground-full
jwlee64 Nov 4, 2024
e32fdab
merge master
jwlee64 Nov 6, 2024
d661fc5
clean up state, hide image, make fetching the call after completion r…
jwlee64 Nov 6, 2024
0f0814c
delete both, function warning, toggle
jwlee64 Nov 7, 2024
35920bd
fix types
jwlee64 Nov 7, 2024
31be98e
small typos
jwlee64 Nov 7, 2024
8374394
Merge branch 'master' into josiah/playground-full
jwlee64 Nov 7, 2024
4dc94e4
try types
jwlee64 Nov 7, 2024
1270b6d
filter out undefined
jwlee64 Nov 7, 2024
226e99d
basic cta
jwlee64 Nov 7, 2024
53a134b
Merge branch 'master' into josiah/playground-full
jwlee64 Nov 7, 2024
8c91069
fix merge master
jwlee64 Nov 7, 2024
6f2802b
delete dupe files
jwlee64 Nov 7, 2024
a4bb915
remove route
jwlee64 Nov 7, 2024
58a31e6
make cta better
jwlee64 Nov 7, 2024
2042909
spacing audit
jwlee64 Nov 7, 2024
347c34b
swap llm dropdown for react-select
jwlee64 Nov 7, 2024
556990a
add settings drawer with simple toggle
jwlee64 Nov 7, 2024
2ef3e32
lint
jwlee64 Nov 8, 2024
8bf79ce
add top bar
jwlee64 Nov 8, 2024
5781faf
cleanup
jwlee64 Nov 8, 2024
8ee0a08
merge master
jwlee64 Nov 8, 2024
93f8e03
merge master
jwlee64 Nov 8, 2024
cb3dd50
merge master
jwlee64 Nov 8, 2024
c6c6736
small fixes
jwlee64 Nov 12, 2024
4af2cac
function editor
jwlee64 Nov 12, 2024
76ace12
stop sequence editor
jwlee64 Nov 12, 2024
c8a772f
response editor
jwlee64 Nov 12, 2024
755dacf
lint
jwlee64 Nov 12, 2024
8a58e0b
name check
jwlee64 Nov 12, 2024
678d524
spacing
jwlee64 Nov 12, 2024
002ae6f
Merge branch 'function-editor' into response-editor
jwlee64 Nov 12, 2024
f88e302
change to react select
jwlee64 Nov 12, 2024
1e6d85f
merge stuff
jwlee64 Nov 12, 2024
f5aef46
merge branches
jwlee64 Nov 12, 2024
2f5cbdb
chat style
jwlee64 Nov 12, 2024
7e1366a
remove space
jwlee64 Nov 12, 2024
de7ab1e
merge
jwlee64 Nov 12, 2024
1ceb825
merge
jwlee64 Nov 12, 2024
268cbd2
fix import
jwlee64 Nov 12, 2024
d05949c
merge master
jwlee64 Nov 12, 2024
b2b7e6b
Merge branch 'master' into josiah/playground-chatview-improvements
jwlee64 Nov 12, 2024
b16ecd8
Merge branch 'josiah/playground-chatview-improvements' into josiah/pl…
jwlee64 Nov 12, 2024
e4d3f25
delete
jwlee64 Nov 12, 2024
306103d
Merge branch 'josiah/playground-chatview-improvements' into josiah/pl…
jwlee64 Nov 12, 2024
288881c
add
jwlee64 Nov 12, 2024
f2e30bf
merge master
jwlee64 Nov 13, 2024
9be4421
master
jwlee64 Nov 13, 2024
987b334
Merge branch 'master' into josiah/playground-chatview-improvements
jwlee64 Nov 13, 2024
c7d071e
Merge branch 'josiah/playground-chatview-improvements' into josiah/pl…
jwlee64 Nov 13, 2024
32d6477
add playground context
jwlee64 Nov 13, 2024
3d865d8
clean up
jwlee64 Nov 13, 2024
1672f8b
types
jwlee64 Nov 13, 2024
af25c8d
clean
jwlee64 Nov 14, 2024
01523c9
Merge branch 'josiah/playground-full' of github.com:wandb/weave into …
jwlee64 Nov 14, 2024
5e77633
make context nullable, remove all the optionals
jwlee64 Nov 14, 2024
76a16ab
merge master
jwlee64 Nov 14, 2024
5a599fc
merge context
jwlee64 Nov 14, 2024
907e486
Merge branch 'master' into josiah/playground-chatview-improvements
jwlee64 Nov 14, 2024
30b96b5
Merge branch 'josiah/playground-chatview-improvements' into josiah/pl…
jwlee64 Nov 14, 2024
5842b32
update callchat sign
jwlee64 Nov 14, 2024
c0d08a3
add call chat to playground and add functions interacting with chat m…
jwlee64 Nov 14, 2024
ee0fa5b
merge master
jwlee64 Nov 14, 2024
a9ab0b2
Merge branch 'master' into josiah/playground-context
jwlee64 Nov 14, 2024
a551da5
Merge branch 'josiah/playground-context' into josiah/add-call-chat
jwlee64 Nov 14, 2024
126fd9a
lint
jwlee64 Nov 14, 2024
eb81643
Merge branch 'josiah/add-call-chat' of github.com:wandb/weave into jo…
jwlee64 Nov 14, 2024
18c06be
move chat completion functions to separate file
jwlee64 Nov 15, 2024
fa90f97
remove callchat edits, move provider into playgroundchat
jwlee64 Nov 15, 2024
da66865
remove callchat edits
jwlee64 Nov 15, 2024
a28fe53
d
jwlee64 Nov 15, 2024
8af3579
merge master
jwlee64 Nov 18, 2024
511c0a0
merge master
jwlee64 Nov 18, 2024
ffa642d
fix some types
jwlee64 Nov 18, 2024
aac9170
lint
jwlee64 Nov 18, 2024
ee59898
lint
jwlee64 Nov 18, 2024
2ca1851
wire up completions
jwlee64 Nov 18, 2024
54f6381
Merge branch 'josiah/wire-up-completions' into josiah/playground-full
jwlee64 Nov 18, 2024
b8184b2
fix completions
jwlee64 Nov 18, 2024
ed82059
Merge branch 'josiah/playground-full' of github.com:wandb/weave into …
jwlee64 Nov 18, 2024
9b67a82
fix top bar styles
jwlee64 Nov 18, 2024
3b826ec
fix styles
jwlee64 Nov 18, 2024
a6b9327
Merge branch 'josiah/wire-up-completions' into josiah/playground-full
jwlee64 Nov 18, 2024
6ea9aa4
type
jwlee64 Nov 18, 2024
c16891c
Merge branch 'josiah/playground-full' of github.com:wandb/weave into …
jwlee64 Nov 18, 2024
028f6d2
pull out buttons
jwlee64 Nov 18, 2024
bcba14c
message panel buttons
jwlee64 Nov 18, 2024
947c153
Merge branch 'josiah/message-panel-button-editor' into josiah/playgro…
jwlee64 Nov 18, 2024
7178a0f
Merge branch 'master' into josiah/playground-full
jwlee64 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions weave-js/src/components/FancyPage/useProjectSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ export const useProjectSidebar = (
isShown: isWeaveOnly,
iconName: IconNames.CubeContainer,
},
{
type: 'button' as const,
name: 'Playground',
slug: 'weave/playground',
isShown: isWeaveOnly,
iconName: IconNames.CubeContainer,
},
{
type: 'menuPlaceholder' as const,
// name: 'More',
Expand All @@ -224,6 +231,7 @@ export const useProjectSidebar = (
// 'weave/scorers', // Hiding until we want to release
'weave/operations',
'weave/objects',
'weave/playground',
],
},
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Box from '@mui/material/Box';
import {useViewerInfo} from '@wandb/weave/common/hooks/useViewerInfo';
import {Loading} from '@wandb/weave/components/Loading';
import {urlPrefixed} from '@wandb/weave/config';
import {useViewTraceEvent} from '@wandb/weave/integrations/analytics/useViewEvents';
import React, {FC, useCallback, useContext, useEffect, useState} from 'react';
import {useHistory} from 'react-router-dom';
Expand Down Expand Up @@ -75,6 +76,14 @@ const useCallTabs = (call: CallSchema) => {
const codeURI = call.opVersionRef;
const {entity, project, callId} = call;
const weaveRef = makeRefCall(entity, project, callId);

const handleOpenInPlayground = () => {
window.open(
urlPrefixed(`/${entity}/${project}/weave/playground/${callId}`),
'_blank'
);
};

return [
// Disabling Evaluation tab until it's better for single evaluation
...(false && isEvaluateOp(call.spanName)
Expand All @@ -101,11 +110,20 @@ const useCallTabs = (call: CallSchema) => {
{
label: 'Chat',
content: (
<ScrollableTabContent>
<Tailwind>
<CallChat call={call.traceCall!} />
</Tailwind>
</ScrollableTabContent>
<>
<Button
variant="secondary"
startIcon="sandbox-playground"
className="m-16 mb-8"
onClick={handleOpenInPlayground}>
Open chat in playground
</Button>
<ScrollableTabContent>
<Tailwind>
<CallChat call={call.traceCall!} />
</Tailwind>
</ScrollableTabContent>
</>
),
},
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {Callout} from '@wandb/weave/components/Callout';
import {Icon, IconName} from '@wandb/weave/components/Icon';
import {Tailwind} from '@wandb/weave/components/Tailwind';
import React from 'react';

import {usePlaygroundContext} from '../PlaygroundPage/PlaygroundContext';

const DEFAULT_EMPTY_STATE_MESSAGE = 'How can I help you today?';
const DEFAULT_MESSAGES: Array<{message: string; icon: IconName}> = [
{
message:
'Explain the difference between concurrency and parallelism with code examples.',
icon: 'settings',
},
{
message:
'What are the best practices for optimizing SQL queries in a large database?',
icon: 'miller-columns',
},
{
message: 'Generate a regular expression to validate an email address.',
icon: 'email-envelope',
},
{
message:
'Create a REST API using Node.js and Express that handles user authentication.',
icon: 'lock-closed',
},
];
export const ChatEmptyStateCallout = () => {
const {sendMessage} = usePlaygroundContext();
return (
<Tailwind>
<div className="flex justify-center">
<div className="mt-32 flex flex-col items-center gap-8 rounded-lg bg-moon-100 p-32">
<Callout color="magenta" icon="buzz-bot10" size="large" />
<p className="text-gray-500 mb-8 text-2xl font-semibold">
{DEFAULT_EMPTY_STATE_MESSAGE}
</p>
{DEFAULT_MESSAGES.map(message => (
<div
key={message.message}
onClick={() => sendMessage?.('user', message.message)}
className="flex min-w-[600px] max-w-[700px] cursor-pointer items-center gap-4 rounded-full border border-moon-300 bg-white p-2">
<div className="flex items-center justify-center rounded-full bg-moon-100 p-6">
<Icon name={message.icon} />
</div>
<p className="text-gray-500 flex w-full justify-center">
{message.message}
</p>
</div>
))}
</div>
</div>
</Tailwind>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, {useEffect, useMemo, useRef} from 'react';

import {useDeepMemo} from '../../../../../../hookUtils';
import {usePlaygroundContext} from '../PlaygroundPage/PlaygroundContext';
import {DEFAULT_SYSTEM_MESSAGE_CONTENT} from '../PlaygroundPage/usePlaygroundState';
import {ChatEmptyStateCallout} from './ChatEmptyStateCallout';

Check warning on line 6 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChatView.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'ChatEmptyStateCallout' is defined but never used
import {ChoicesView} from './ChoicesView';
import {MessageList} from './MessageList';
import {Chat} from './types';
Expand All @@ -25,6 +28,14 @@
}
}, [chatResult]);

const {isPlayground} = usePlaygroundContext();

const showEmptyStateCallout =

Check warning on line 33 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/ChatView.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'showEmptyStateCallout' is assigned a value but never used
isPlayground &&
chat.request?.messages.length === 1 &&
chat.request.messages[0].content === DEFAULT_SYSTEM_MESSAGE_CONTENT &&
(chatResult?.choices.length === 0 || chatResult?.choices === undefined);

return (
<div className="flex flex-col pb-32">
<span className="mb-[-16px] text-sm font-semibold text-moon-800">
Expand All @@ -47,6 +58,7 @@
</div>
</>
)}
{/* {showEmptyStateCallout && <ChatEmptyStateCallout />} */}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ const processToolCallMessages = (messages: Messages): Messages => {
i++;
}

// If the number of tool messages doesn't match the number of tool calls,
// log a warning.
if (toolMessages.length !== message.tool_calls.length) {
// console.warn('Tool call count mismatch');
}

const toolCallsWithResponses: ToolCall[] = message.tool_calls.map(
toolCall => ({
...toolCall,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React from 'react';

Check warning on line 1 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ChatView/PlaygroundMessagePanellButtons.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

Run autofix to sort these imports!
import classNames from 'classnames';
import {Button} from '@wandb/weave/components/Button';

import {usePlaygroundContext} from '../PlaygroundPage/PlaygroundContext';

type PlaygroundMessagePanelButtonsProps = {
index: number;
isChoice: boolean;
isTool: boolean;
hasContent: boolean;
isNested: boolean;
contentRef: React.RefObject<HTMLDivElement>;
setEditorHeight: (height: number | null) => void;
responseIndexes?: number[];
};

export const PlaygroundMessagePanelButtons: React.FC<
PlaygroundMessagePanelButtonsProps
> = ({
index,
isChoice,
isTool,
hasContent,
isNested,
contentRef,
setEditorHeight,
responseIndexes,
}) => {
const {deleteMessage, deleteChoice, retry} = usePlaygroundContext();

return (
<div
className={classNames(
'absolute right-0 flex w-full items-center justify-end pt-20',
isNested ? 'bottom-0' : 'bottom-[-32px]'
)}>
<div className="z-10 flex gap-4 rounded-lg border border-moon-250 bg-white p-4">
<Button
variant="quiet"
size="small"
startIcon="randomize-reset-reload"
onClick={() => retry?.(index, isChoice)}
tooltip={
!hasContent
? 'We currently do not support retrying functions'
: 'Retry'
}
disabled={!hasContent}>
Retry
</Button>
<Button
variant="quiet"
size="small"
startIcon="pencil-edit"
onClick={() => {
setEditorHeight(
contentRef?.current?.clientHeight
? // Accounts for padding and save buttons
contentRef.current.clientHeight - 56
: null
);
}}
tooltip={
!hasContent
? 'We currently do not support editing functions'
: 'Edit'
}
disabled={!hasContent}>
Edit
</Button>
<Button
variant="quiet"
size="small"
startIcon="delete"
onClick={() => {
if (isChoice) {
deleteChoice?.(index);
} else {
deleteMessage?.(index, responseIndexes);
}
}}
tooltip={
isTool ? 'Tool responses cannot be deleted' : 'Delete message'
}
disabled={isTool}>
Delete
</Button>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
setChatText
);

const {handleRetry, handleSend} = useChatCompletionFunctions(

Check warning on line 51 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'handleRetry' is already defined

Check warning on line 51 in weave-js/src/components/PagePanelComponents/Home/Browse3/pages/PlaygroundPage/PlaygroundChat/PlaygroundChat.tsx

View workflow job for this annotation

GitHub Actions / WeaveJS Lint and Compile

'handleSend' is already defined
setPlaygroundStates,
setIsLoading,
chatText,
playgroundStates,
entity,
project,
setChatText
);

const {deleteMessage, editMessage, deleteChoice, editChoice, addMessage} =
useChatFunctions(setPlaygroundStateField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ export const PlaygroundSettings: React.FC<PlaygroundSettingsProps> = ({
label="Presence penalty"
value={playgroundState.presencePenalty}
/>

{/* TODO: Add this back in, N times to run is not supported for all models */}
{/* Shawn said to run multiple requests if its not supported */}
{/* <PlaygroundSlider
min={1}
max={100}
step={1}
setValue={value =>
setPlaygroundStateField(idx, 'nTimes', value)
}
label="n times to run"
value={playgroundState.nTimes}
/> */}

<Box
sx={{
width: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,66 @@ export const LLM_MAX_TOKENS = {
'o1-mini': {max_tokens: 65536, supports_function_calling: true},
'o1-preview-2024-09-12': {max_tokens: 32768, supports_function_calling: true},
'o1-preview': {max_tokens: 32768, supports_function_calling: true},

// These were all in our model_providers.json (but dont work)
// Leaving them here for now, just in case someone asks why they arent in the list.
// This seems like a dupe of claude-3-5-sonnet-20241022.
// 'anthropic/claude-3-5-sonnet-20241022': 8192,

// 422 Unprocessable Entity
// 'claude-2.1': 8191,
// 'claude-2': 8191,
// 'claude-instant-1.2': 8191,
// 'claude-instant-1': 8191,

// error litellm.BadRequestError: OpenAIException - Error code: 400 - {'error': {'message': "[{'type': 'string_type', 'loc': ('body', 'stop', 'str'), 'msg': 'Input should be a valid string', 'input': []}, {'type': 'too_short', 'loc': ('body', 'stop', 'list[str]'), 'msg': 'List should have at least 1 item after validation, not 0', 'input': [], 'ctx': {'field_type': 'List', 'min_length': 1, 'actual_length': 0}}, {'type': 'too_short', 'loc': ('body', 'stop', 'list[list[int]]'), 'msg': 'List should have at least 1 item after validation, not 0', 'input': [], 'ctx': {'field_type': 'List', 'min_length': 1, 'actual_length': 0}}]", 'type': 'invalid_request_error', 'param': None, 'code': None}}
// 'chatgpt-4o-latest': 4096,
// 'gpt-4o-audio-preview-2024-10-01': 16384,
// 'gpt-4o-audio-preview': 16384,

// error litellm.NotFoundError: OpenAIException - Error code: 404 - {'error': {'message': 'The model `ft:gpt-3.5-turbo-0125` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
// 'ft:gpt-3.5-turbo-0125': 4096,
// 'ft:gpt-3.5-turbo-0613': 4096,
// 'ft:gpt-3.5-turbo-1106': 4096,
// 'ft:gpt-3.5-turbo': 4096,
// 'ft:gpt-4-0613': 4096,
// 'ft:gpt-4o-2024-08-06': 16384,
// 'ft:gpt-4o-mini-2024-07-18': 16384,
// 'gpt-4-32k-0613': 4096,
// 'gpt-4-32k': 4096,
// 'groq/llama-3.1-405b-reasoning': 8192,
// 'groq/llama2-70b-4096': 4096,

// error litellm.NotFoundError: OpenAIException - Error code: 404 - {'error': {'message': 'The model `gpt-3.5-turbo-0301` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
// 'gpt-3.5-turbo-0301': 4096,
// 'gpt-3.5-turbo-0613': 4096,
// 'gpt-3.5-turbo-16k-0613': 4096,
// 'gpt-4-1106-vision-preview': 4096,
// 'gpt-4-vision-preview': 4096,

// error litellm.NotFoundError: VertexAIException - {
// "error": {
// "code": 404,
// "message": "models/gemini-gemma-2-27b-it is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.",
// "status": "NOT_FOUND"
// }
// }
// 'gemini/gemini-gemma-2-27b-it': 8192,
// 'gemini/gemini-gemma-2-9b-it': 8192,

// error litellm.NotFoundError: VertexAIException - {
// "error": {
// "code": 404,
// "message": "Gemini 1.0 Pro Vision has been deprecated on July 12, 2024. Consider switching to different model, for example gemini-1.5-flash.",
// "status": "NOT_FOUND"
// }
// }
// 'gemini/gemini-pro-vision': 2048,

// These are 0 tokens, idk why we would want to use them.
// "text-moderation-007": 0,
// "text-moderation-latest": 0,
// "text-moderation-stable": 0
};

export type LLMMaxTokensKey = keyof typeof LLM_MAX_TOKENS;
Loading