mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(ui): remove unused ChatInputBar and ModelSelector files
This commit is contained in:
parent
6661520afb
commit
2b1c0fb783
2 changed files with 0 additions and 214 deletions
|
|
@ -1,107 +0,0 @@
|
|||
import React, { useState } from "react";
|
||||
import { Button, Input, Popover, Tooltip } from "antd";
|
||||
import { ApiOutlined, BorderOutlined, PaperClipOutlined, SendOutlined } from "@ant-design/icons";
|
||||
|
||||
interface Props {
|
||||
onSend: (text: string) => void;
|
||||
isStreaming: boolean;
|
||||
onStop: () => void;
|
||||
selectedMCPServers: string[];
|
||||
onMCPChange: (servers: string[]) => void;
|
||||
isLoadingModels: boolean;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
const ChatInputBar: React.FC<Props> = ({
|
||||
onSend,
|
||||
isStreaming,
|
||||
onStop,
|
||||
selectedMCPServers,
|
||||
onMCPChange,
|
||||
isLoadingModels,
|
||||
accessToken,
|
||||
}) => {
|
||||
const [text, setText] = useState<string>("");
|
||||
const [mcpPopoverOpen, setMcpPopoverOpen] = useState<boolean>(false);
|
||||
|
||||
const handleSend = () => {
|
||||
if (text.trim() === "" || isStreaming || isLoadingModels) return;
|
||||
onSend(text.trim());
|
||||
setText("");
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSend();
|
||||
}
|
||||
};
|
||||
|
||||
const mcpButtonLabel =
|
||||
selectedMCPServers.length > 0
|
||||
? `MCP (${selectedMCPServers.length})`
|
||||
: "MCP";
|
||||
|
||||
const mcpPopoverContent = (
|
||||
<div style={{ minWidth: 200 }}>
|
||||
{/* MCPConnectPicker - LIT-2170 */}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "flex-end",
|
||||
gap: 8,
|
||||
padding: "12px 16px",
|
||||
borderTop: "1px solid #e5e7eb",
|
||||
backgroundColor: "#ffffff",
|
||||
}}
|
||||
>
|
||||
<Popover
|
||||
content={mcpPopoverContent}
|
||||
title="MCP Servers"
|
||||
trigger="click"
|
||||
open={mcpPopoverOpen}
|
||||
onOpenChange={setMcpPopoverOpen}
|
||||
placement="topLeft"
|
||||
>
|
||||
<Button icon={<ApiOutlined />}>
|
||||
{mcpButtonLabel}
|
||||
</Button>
|
||||
</Popover>
|
||||
|
||||
<Tooltip title="Coming soon">
|
||||
<Button icon={<PaperClipOutlined />} disabled />
|
||||
</Tooltip>
|
||||
|
||||
<Input.TextArea
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder="Message..."
|
||||
autoSize={{ minRows: 1, maxRows: 5 }}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
|
||||
{isStreaming ? (
|
||||
<Button
|
||||
icon={<BorderOutlined />}
|
||||
onClick={onStop}
|
||||
type="primary"
|
||||
danger
|
||||
/>
|
||||
) : (
|
||||
<Button
|
||||
icon={<SendOutlined />}
|
||||
onClick={handleSend}
|
||||
type="primary"
|
||||
disabled={isStreaming || isLoadingModels || text.trim() === ""}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChatInputBar;
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { Select, Skeleton } from "antd";
|
||||
import { fetchAvailableModels, ModelGroup } from "../playground/llm_calls/fetch_models";
|
||||
|
||||
const LOCALSTORAGE_KEY = "litellm_chat_selected_model";
|
||||
const MAX_DISPLAY_LENGTH = 40;
|
||||
|
||||
interface Props {
|
||||
accessToken: string;
|
||||
selectedModel: string;
|
||||
onChange: (model: string) => void;
|
||||
onLoadingChange: (loading: boolean) => void;
|
||||
}
|
||||
|
||||
const ModelSelector: React.FC<Props> = ({
|
||||
accessToken,
|
||||
selectedModel,
|
||||
onChange,
|
||||
onLoadingChange,
|
||||
}) => {
|
||||
const [models, setModels] = useState<ModelGroup[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [fetchFailed, setFetchFailed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
const load = async () => {
|
||||
setLoading(true);
|
||||
onLoadingChange(true);
|
||||
try {
|
||||
const fetched = await fetchAvailableModels(accessToken);
|
||||
if (cancelled) return;
|
||||
|
||||
setModels(fetched);
|
||||
|
||||
if (fetched.length > 0) {
|
||||
const persisted = localStorage.getItem(LOCALSTORAGE_KEY);
|
||||
const modelNames = fetched.map((m) => m.model_group);
|
||||
|
||||
if (persisted && modelNames.includes(persisted)) {
|
||||
onChange(persisted);
|
||||
} else {
|
||||
// Persisted model not in list — clear stale value and default to first
|
||||
if (persisted) {
|
||||
localStorage.removeItem(LOCALSTORAGE_KEY);
|
||||
}
|
||||
onChange(fetched[0].model_group);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) {
|
||||
setFetchFailed(true);
|
||||
}
|
||||
} finally {
|
||||
if (!cancelled) {
|
||||
setLoading(false);
|
||||
onLoadingChange(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
load();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [accessToken]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const handleChange = (value: string) => {
|
||||
localStorage.setItem(LOCALSTORAGE_KEY, value);
|
||||
onChange(value);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Skeleton.Input active style={{ width: 220 }} />;
|
||||
}
|
||||
|
||||
if (fetchFailed || models.length === 0) {
|
||||
return (
|
||||
<span style={{ color: "#8c8c8c", fontSize: 13 }}>
|
||||
No models available — check your proxy config
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Select
|
||||
value={selectedModel}
|
||||
onChange={handleChange}
|
||||
style={{ width: 220 }}
|
||||
showSearch
|
||||
filterOption={(input, option) =>
|
||||
(option?.label as string ?? "").toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
options={models.map((m) => ({
|
||||
value: m.model_group,
|
||||
label:
|
||||
m.model_group.length > MAX_DISPLAY_LENGTH
|
||||
? `${m.model_group.slice(0, MAX_DISPLAY_LENGTH)}…`
|
||||
: m.model_group,
|
||||
}))}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelSelector;
|
||||
Loading…
Add table
Reference in a new issue