feat(admin-dashboard): add support for Bedrock and OpenAI-compatible LLM slices in admin router config
- Implemented `buildBedrockSlice` function to handle multi-kilobyte Bedrock bearer tokens. - Enhanced `createAdminRouterConfigService` to classify Bedrock and OpenAI-compatible LLM upstreams by baseURL. - Added new interfaces for `AdminRouterBedrockSlice` and `AdminRouterOpenAICompatibleSlice`. - Updated router config form to support Bedrock and OpenAI-compatible slices. - Created tests for Bedrock and OpenAI-compatible slice compilation and behavior. - Modified UI components to accommodate new slice types and improve user experience. - Ensured proper normalization of API server URLs to HTTPS when necessary.
This commit is contained in:
@@ -19,6 +19,13 @@ const TRUSTED_STANDALONE_API_SERVER_ORIGINS = [
|
||||
'https://airi-server-dev.up.railway.app',
|
||||
]
|
||||
|
||||
const TRUSTED_HTTPS_API_SERVER_HOSTS = new Map(
|
||||
TRUSTED_STANDALONE_API_SERVER_ORIGINS.map((origin) => {
|
||||
const url = new URL(origin)
|
||||
return [url.hostname, origin]
|
||||
}),
|
||||
)
|
||||
|
||||
const TRUSTED_LOCAL_API_SERVER_ORIGIN_PATTERNS = [
|
||||
/^http:\/\/localhost(:\d+)?$/,
|
||||
/^http:\/\/127\.0\.0\.1(:\d+)?$/,
|
||||
@@ -89,7 +96,12 @@ function normalizeTrustedApiServerUrl(value: string | null): string | null {
|
||||
return null
|
||||
|
||||
try {
|
||||
const origin = new URL(value).origin
|
||||
const url = new URL(value)
|
||||
const normalizedHttpsOrigin = TRUSTED_HTTPS_API_SERVER_HOSTS.get(url.hostname)
|
||||
if (normalizedHttpsOrigin)
|
||||
return normalizedHttpsOrigin
|
||||
|
||||
const origin = url.origin
|
||||
|
||||
if (TRUSTED_STANDALONE_API_SERVER_ORIGINS.includes(origin))
|
||||
return origin
|
||||
|
||||
Reference in New Issue
Block a user