mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
fix(ui): match the Decisions cURL URL to the send path and block copying an invalid payload
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
b5f52c91a8
commit
1e8a6ade2a
3 changed files with 18 additions and 4 deletions
|
|
@ -1,15 +1,28 @@
|
|||
import CopyButton from "@/components/shared/CopyButton";
|
||||
import { buildCurlCommand, type CurlCommandInput } from "./lib/curlCommand";
|
||||
|
||||
export default function CurlPreview(input: CurlCommandInput) {
|
||||
interface CurlPreviewProps extends CurlCommandInput {
|
||||
errorCount?: number;
|
||||
}
|
||||
|
||||
export default function CurlPreview({ errorCount = 0, ...input }: CurlPreviewProps) {
|
||||
const command = buildCurlCommand(input);
|
||||
const invalid = errorCount > 0;
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 flex-col rounded-md border">
|
||||
<div className="flex items-center justify-between gap-2 border-b px-3 py-2 text-sm">
|
||||
<span className="font-medium">cURL request</span>
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<span>Replace $LITELLM_API_KEY with a virtual key</span>
|
||||
<CopyButton value={command} label="Copy cURL" variant="action" />
|
||||
{invalid ? (
|
||||
<span role="alert" className="text-destructive">
|
||||
Fix {errorCount} {errorCount === 1 ? "issue" : "issues"} on the Form tab before copying
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<span>Replace $LITELLM_API_KEY with a virtual key</span>
|
||||
<CopyButton value={command} label="Copy cURL" variant="action" />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<pre
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =
|
|||
endpoint={endpoint}
|
||||
payload={validation.payload === undefined ? rawPayload : JSON.stringify(validation.payload)}
|
||||
authHeaderName={getGlobalLitellmHeaderName()}
|
||||
errorCount={validation.issues.filter((issue) => issue.severity === "error").length}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const prettyPayload = (payload: string): string => {
|
|||
|
||||
export const buildCurlCommand = ({ baseUrl, endpoint, payload, authHeaderName }: CurlCommandInput): string =>
|
||||
[
|
||||
`curl -X POST ${shellSingleQuote(`${baseUrl.replace(/\/+$/, "")}${endpoint}`)}`,
|
||||
`curl -X POST ${shellSingleQuote(`${baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl}${endpoint}`)}`,
|
||||
` -H "${shellDoubleQuoteLiteral(authHeaderName)}: Bearer ${CURL_KEY_PLACEHOLDER}"`,
|
||||
` -H "Content-Type: application/json"`,
|
||||
` -d ${shellSingleQuote(prettyPayload(payload))}`,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue