mirror of
https://gh-proxy.org/https://github.com/klinsmaya/gateway.git
synced 2026-11-08 17:17:32 +08:00
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
export const defaultOrganisationDetails = {
|
|
id: '00000000-0000-0000-0000-000000000000',
|
|
name: 'Portkey self hosted',
|
|
settings: {
|
|
debug_log: 1,
|
|
is_virtual_key_limit_enabled: 1,
|
|
allowed_guardrails: ['BASIC', 'PARTNER', 'PRO'],
|
|
},
|
|
workspaceDetails: {},
|
|
defaults: {
|
|
metadata: null,
|
|
},
|
|
usageLimits: [],
|
|
rateLimits: [],
|
|
organisationDefaults: {
|
|
input_guardrails: null,
|
|
},
|
|
};
|
|
|
|
const transformIntegrations = (integrations: any) => {
|
|
return integrations.map((integration: any) => {
|
|
return {
|
|
id: integration.slug, //need to do consistent hashing for caching
|
|
ai_provider_name: integration.provider,
|
|
model_config: {
|
|
...integration.credentials,
|
|
},
|
|
...(integration.credentials?.apiKey && {
|
|
key: integration.credentials.apiKey,
|
|
}),
|
|
slug: integration.slug,
|
|
usage_limits: null,
|
|
status: 'active',
|
|
integration_id: integration.slug,
|
|
object: 'virtual-key',
|
|
integration_details: {
|
|
id: integration.slug,
|
|
slug: integration.slug,
|
|
usage_limits: integration.usage_limits,
|
|
rate_limits: integration.rate_limits,
|
|
models: integration.models,
|
|
},
|
|
};
|
|
});
|
|
};
|
|
|
|
let settings: any = undefined;
|
|
try {
|
|
const settingsFile = await import('./settings.json');
|
|
if (settingsFile) {
|
|
settings = {};
|
|
settings.organisationDetails = defaultOrganisationDetails;
|
|
if (settingsFile.integrations) {
|
|
settings.integrations = transformIntegrations(settingsFile.integrations);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.log(
|
|
'WARNING: Unable to import settings from the path, please make sure the file exists',
|
|
error
|
|
);
|
|
}
|
|
|
|
export { settings };
|