Skip to content

Commit a627e55

Browse files
committed
Merge remote-tracking branch 'upstream/main' into chore/send-hook-results-in-streaming-chunks
2 parents 6e0b90c + da1a1d0 commit a627e55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3961
-401
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Local configuration file
2+
conf.json
3+
14
# Logs
25
logs
36
*.log

conf.example.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"plugins_enabled": [
3+
"default",
4+
"portkey",
5+
"aporia",
6+
"sydelabs",
7+
"pillar",
8+
"patronus",
9+
"pangea",
10+
"promptsecurity",
11+
"panw-prisma-airs",
12+
"walledai"
13+
],
14+
"credentials": {
15+
"portkey": {
16+
"apiKey": "..."
17+
}
18+
},
19+
"cache": false,
20+
"integrations": [
21+
{
22+
"provider": "anthropic",
23+
"slug": "dev_team_anthropic",
24+
"credentials": {
25+
"apiKey": "sk-ant-"
26+
},
27+
"rate_limits": [
28+
{
29+
"type": "requests",
30+
"unit": "rph",
31+
"value": 3
32+
},
33+
{
34+
"type": "tokens",
35+
"unit": "rph",
36+
"value": 3000
37+
}
38+
],
39+
"models": [
40+
{
41+
"slug": "claude-3-7-sonnet-20250219",
42+
"status": "active",
43+
"pricing_config": null
44+
}
45+
]
46+
}
47+
]
48+
}

conf_sample.json

Whitespace-only changes.

initializeSettings.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
export const defaultOrganisationDetails = {
2+
id: 'self-hosted-organisation',
3+
name: 'Portkey self hosted',
4+
settings: {
5+
debug_log: 1,
6+
is_virtual_key_limit_enabled: 1,
7+
allowed_guardrails: ['BASIC', 'PARTNER', 'PRO'],
8+
},
9+
workspaceDetails: {},
10+
defaults: {
11+
metadata: null,
12+
},
13+
usageLimits: [],
14+
rateLimits: [],
15+
organisationDefaults: {
16+
input_guardrails: null,
17+
},
18+
};
19+
20+
const transformIntegrations = (integrations: any) => {
21+
return integrations.map((integration: any) => {
22+
return {
23+
id: integration.slug, //need to do consistent hashing for caching
24+
ai_provider_name: integration.provider,
25+
model_config: {
26+
...integration.credentials,
27+
},
28+
...(integration.credentials?.apiKey && {
29+
key: integration.credentials.apiKey,
30+
}),
31+
slug: integration.slug,
32+
usage_limits: null,
33+
status: 'active',
34+
integration_id: integration.slug,
35+
object: 'virtual-key',
36+
integration_details: {
37+
id: integration.slug,
38+
slug: integration.slug,
39+
usage_limits: integration.usage_limits,
40+
rate_limits: integration.rate_limits,
41+
models: integration.models,
42+
allow_all_models: integration.allow_all_models,
43+
},
44+
};
45+
});
46+
};
47+
48+
export const getSettings = async () => {
49+
try {
50+
const isFetchSettingsFromFile =
51+
process?.env?.FETCH_SETTINGS_FROM_FILE === 'true';
52+
if (!isFetchSettingsFromFile) {
53+
return undefined;
54+
}
55+
let settings: any = undefined;
56+
const { readFile } = await import('fs/promises');
57+
const settingsFile = await readFile('./conf.json', 'utf-8');
58+
const settingsFileJson = JSON.parse(settingsFile);
59+
60+
if (settingsFileJson) {
61+
settings = {};
62+
settings.organisationDetails = defaultOrganisationDetails;
63+
if (settingsFileJson.integrations) {
64+
settings.integrations = transformIntegrations(
65+
settingsFileJson.integrations
66+
);
67+
}
68+
return settings;
69+
}
70+
} catch (error) {
71+
console.log(
72+
'WARNING: unable to load settings from your conf.json file',
73+
error
74+
);
75+
}
76+
};

0 commit comments

Comments
 (0)