From e91dc1e00fed6b296592d7ed61f4c9d8617828fc Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 3 Apr 2025 21:57:05 -0700 Subject: [PATCH] refactor chat playground --- .../src/components/chat_ui.tsx | 369 +++++++++--------- 1 file changed, 174 insertions(+), 195 deletions(-) diff --git a/ui/litellm-dashboard/src/components/chat_ui.tsx b/ui/litellm-dashboard/src/components/chat_ui.tsx index 4027b1febc0..0231f523252 100644 --- a/ui/litellm-dashboard/src/components/chat_ui.tsx +++ b/ui/litellm-dashboard/src/components/chat_ui.tsx @@ -226,206 +226,185 @@ const ChatUI: React.FC = ({ return (
- - +
+ {/* Left Sidebar with Controls */} +
+
+ API Key Source + setApiKeySource(value as "session" | "custom")} - options={[ - { value: 'session', label: 'Current UI Session' }, - { value: 'custom', label: 'Virtual Key' }, - ]} +
+ Select Model: + ({ - value: option.model_group, - label: option.model_group - })), - { value: 'custom', label: 'Enter custom model' } - ]} - style={{ width: "350px" }} - showSearch={true} - /> - {showCustomModelInput && ( - { - // Using setTimeout to create a simple debounce effect - if (customModelTimeout.current) { - clearTimeout(customModelTimeout.current); - } - - customModelTimeout.current = setTimeout(() => { - setSelectedModel(value); - }, 500); // 500ms delay after typing stops - }} - /> - )} - - - - - - {/* Clear Chat Button */} - -
- - - - - {/* Chat */} - - - - - {chatHistory.map((message, index) => ( - - -
- {message.role} - {message.role === "assistant" && message.model && ( - - {message.model} - - )} -
-
- {message.isImage ? ( - Generated image - ) : ( - & { - inline?: boolean; - node?: any; - }) { - const match = /language-(\w+)/.exec(className || ''); - return !inline && match ? ( - - {String(children).replace(/\n$/, '')} - - ) : ( - - {children} - - ); - } - }} + ) : ( + & { + inline?: boolean; + node?: any; + }) { + const match = /language-(\w+)/.exec(className || ''); + return !inline && match ? ( + - {message.content} - - )} -
-
-
- ))} - - -
- - - -
-
-
- setInputMessage(e.target.value)} - onKeyDown={handleKeyDown} - placeholder={ - endpointType === EndpointType.CHAT - ? "Type your message..." - : "Describe the image you want to generate..." - } - /> - + {String(children).replace(/\n$/, '')} + + ) : ( + + {children} + + ); + } + }} + > + {message.content} + + )}
- - - - - - +
+ ))} +
+
+ +
+
+ setInputMessage(e.target.value)} + onKeyDown={handleKeyDown} + placeholder={ + endpointType === EndpointType.CHAT + ? "Type your message..." + : "Describe the image you want to generate..." + } + /> + +
+
+
+
); };