mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Add default query param in UI
This commit is contained in:
parent
4a50c55d84
commit
1ceb7d8e29
3 changed files with 87 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import {
|
|||
ApiOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import KeyValueInput from "./key_value_input";
|
||||
import QueryParamInput from "./query_param_input";
|
||||
import { passThroughItem } from "./pass_through_settings";
|
||||
import RoutePreview from "./route_preview";
|
||||
import NotificationsManager from "./molecules/notifications_manager";
|
||||
|
|
@ -295,6 +296,34 @@ const AddPassThroughEndpoint: React.FC<AddFallbacksProps> = ({
|
|||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
{/* Default Query Parameters Section */}
|
||||
<Card className="p-6">
|
||||
<Title className="text-lg font-semibold text-gray-900 mb-2">Default Query Parameters</Title>
|
||||
<Subtitle className="text-gray-600 mb-6">
|
||||
Add query parameters that will be automatically sent with every request to the target API
|
||||
</Subtitle>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<span className="text-sm font-medium text-gray-700 flex items-center">
|
||||
Default Query Parameters (Optional)
|
||||
<Tooltip title="Query parameters that will be added to all requests. Clients can override these by providing their own values.">
|
||||
<InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
}
|
||||
name="default_query_params"
|
||||
extra={
|
||||
<div className="text-xs text-gray-500 mt-2">
|
||||
<div className="font-medium mb-1">Parameters are sent with all GET, POST, PUT, PATCH requests</div>
|
||||
<div>Client parameters override defaults. Examples: version=v1, format=json, key=default</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<QueryParamInput />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
{/* Security Section */}
|
||||
<PassThroughSecuritySection
|
||||
premiumUser={premiumUser}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export interface passThroughItem {
|
|||
auth?: boolean;
|
||||
methods?: string[];
|
||||
guardrails?: Record<string, { request_fields?: string[]; response_fields?: string[] } | null>;
|
||||
default_query_params?: Record<string, string>;
|
||||
}
|
||||
|
||||
// Password field component for headers
|
||||
|
|
|
|||
57
ui/litellm-dashboard/src/components/query_param_input.tsx
Normal file
57
ui/litellm-dashboard/src/components/query_param_input.tsx
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import React, { useState } from "react";
|
||||
import { Button, Space } from "antd";
|
||||
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
import { TextInput } from "@tremor/react";
|
||||
|
||||
interface QueryParamInputProps {
|
||||
value?: Record<string, string>;
|
||||
onChange?: (value: Record<string, string>) => void;
|
||||
}
|
||||
|
||||
const QueryParamInput: React.FC<QueryParamInputProps> = ({ value = {}, onChange }) => {
|
||||
const [pairs, setPairs] = useState<[string, string][]>(Object.entries(value));
|
||||
|
||||
const handleAdd = () => {
|
||||
setPairs([...pairs, ["", ""]]);
|
||||
};
|
||||
|
||||
const handleRemove = (index: number) => {
|
||||
const newPairs = pairs.filter((_, i) => i !== index);
|
||||
setPairs(newPairs);
|
||||
onChange?.(Object.fromEntries(newPairs));
|
||||
};
|
||||
|
||||
const handleChange = (index: number, key: string, val: string) => {
|
||||
const newPairs = [...pairs];
|
||||
newPairs[index] = [key, val];
|
||||
setPairs(newPairs);
|
||||
onChange?.(Object.fromEntries(newPairs));
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{pairs.map(([key, val], index) => (
|
||||
<Space key={index} style={{ display: "flex", marginBottom: 8 }} align="center">
|
||||
<TextInput
|
||||
placeholder="Parameter Name (e.g., version)"
|
||||
value={key}
|
||||
onChange={(e) => handleChange(index, e.target.value, val)}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Parameter Value (e.g., v1)"
|
||||
value={val}
|
||||
onChange={(e) => handleChange(index, key, e.target.value)}
|
||||
/>
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "center", height: "100%" }}>
|
||||
<MinusCircleOutlined onClick={() => handleRemove(index)} style={{ cursor: "pointer" }} />
|
||||
</div>
|
||||
</Space>
|
||||
))}
|
||||
<Button type="dashed" onClick={handleAdd} icon={<PlusOutlined />}>
|
||||
Add Query Parameter
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default QueryParamInput;
|
||||
Loading…
Add table
Reference in a new issue