Add Cloudflare AI provider support and enhance connection management
- Introduced Cloudflare AI as a new provider with specific configurations in providerModels.js and providers.js. - Updated DefaultExecutor to handle account ID resolution for Cloudflare AI connections. - Enhanced AddApiKeyModal and EditConnectionModal to include account ID input for Cloudflare AI. - Implemented validation for Cloudflare AI API key connections in testUtils.js and route.js. - Updated UI components to reflect changes in provider management and connection handling.
This commit is contained in:
@@ -20,6 +20,7 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
deployment: "",
|
||||
organization: "",
|
||||
});
|
||||
const [cloudflareData, setCloudflareData] = useState({ accountId: "" });
|
||||
const [testing, setTesting] = useState(false);
|
||||
const [testResult, setTestResult] = useState(null);
|
||||
const [validating, setValidating] = useState(false);
|
||||
@@ -42,6 +43,9 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
organization: connection.providerSpecificData.organization || "",
|
||||
});
|
||||
}
|
||||
if (connection.provider === "cloudflare-ai" && connection.providerSpecificData) {
|
||||
setCloudflareData({ accountId: connection.providerSpecificData.accountId || "" });
|
||||
}
|
||||
setTestResult(null);
|
||||
setValidationResult(null);
|
||||
}
|
||||
@@ -49,6 +53,7 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
|
||||
const isOAuth = connection?.authType === "oauth";
|
||||
const isAzure = connection?.provider === "azure";
|
||||
const isCloudflareAi = connection?.provider === "cloudflare-ai";
|
||||
const isCompatible = connection
|
||||
? (isOpenAICompatibleProvider(connection.provider) || isAnthropicCompatibleProvider(connection.provider))
|
||||
: false;
|
||||
@@ -80,6 +85,7 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
provider: connection.provider,
|
||||
apiKey: formData.apiKey,
|
||||
...(isAzure ? { providerSpecificData: azureData } : {}),
|
||||
...(isCloudflareAi ? { providerSpecificData: cloudflareData } : {}),
|
||||
}),
|
||||
});
|
||||
const data = await res.json();
|
||||
@@ -113,6 +119,7 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
provider: connection.provider,
|
||||
apiKey: formData.apiKey,
|
||||
...(isAzure ? { providerSpecificData: azureData } : {}),
|
||||
...(isCloudflareAi ? { providerSpecificData: cloudflareData } : {}),
|
||||
}),
|
||||
});
|
||||
const data = await res.json();
|
||||
@@ -140,6 +147,9 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
organization: azureData.organization,
|
||||
};
|
||||
}
|
||||
if (isCloudflareAi) {
|
||||
updates.providerSpecificData = { accountId: cloudflareData.accountId };
|
||||
}
|
||||
|
||||
await onSave(updates);
|
||||
} finally {
|
||||
@@ -197,6 +207,19 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
</>
|
||||
)}
|
||||
|
||||
{isCloudflareAi && (
|
||||
<div className="bg-sidebar/50 p-4 rounded-lg border border-accent/20">
|
||||
<h3 className="font-semibold mb-3 text-sm">Cloudflare Workers AI</h3>
|
||||
<Input
|
||||
label="Account ID"
|
||||
value={cloudflareData.accountId}
|
||||
onChange={(e) => setCloudflareData({ ...cloudflareData, accountId: e.target.value })}
|
||||
placeholder="abc123def456..."
|
||||
hint="Find in right sidebar of dash.cloudflare.com"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isAzure && (
|
||||
<div className="bg-sidebar/50 p-4 rounded-lg border border-accent/20">
|
||||
<h3 className="font-semibold mb-3 text-sm">Azure OpenAI Configuration</h3>
|
||||
@@ -233,7 +256,7 @@ export default function EditConnectionModal({ isOpen, connection, proxyPools, on
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isCompatible && !isAzure && (
|
||||
{!isCompatible && !isAzure && !isCloudflareAi && (
|
||||
<div className="flex items-center gap-3">
|
||||
<Button onClick={handleTest} variant="secondary" disabled={testing}>
|
||||
{testing ? "Testing..." : "Test Connection"}
|
||||
|
||||
Reference in New Issue
Block a user