Skip to content

Commit c15ff19

Browse files
committed
fix: Resolve merge conflicts
2 parents f3fc5c1 + 2ddd3f5 commit c15ff19

Some content is hidden

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

45 files changed

+1635
-234
lines changed

conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"patronus",
99
"pangea",
1010
"promptsecurity",
11-
"panw-prisma-airs"
11+
"panw-prisma-airs",
12+
"walledai"
1213
],
1314
"credentials": {
1415
"portkey": {

cookbook/monitoring-agents/Autogen_with_Telemetry.ipynb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,20 @@
7474
"output_type": "stream",
7575
"name": "stdout",
7676
"text": [
77-
"Requirement already satisfied: pyautogen in /usr/local/lib/python3.10/dist-packages (0.2.28)\n",
77+
"Requirement already satisfied: ag2 in /usr/local/lib/python3.10/dist-packages (0.2.28)\n",
7878
"Collecting portkey-ai\n",
7979
" Downloading portkey_ai-1.3.2-py3-none-any.whl (86 kB)\n",
8080
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.3/86.3 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
81-
"\u001b[?25hRequirement already satisfied: diskcache in /usr/local/lib/python3.10/dist-packages (from pyautogen) (5.6.3)\n",
82-
"Requirement already satisfied: docker in /usr/local/lib/python3.10/dist-packages (from pyautogen) (7.1.0)\n",
83-
"Requirement already satisfied: flaml in /usr/local/lib/python3.10/dist-packages (from pyautogen) (2.1.2)\n",
84-
"Requirement already satisfied: numpy<2,>=1.17.0 in /usr/local/lib/python3.10/dist-packages (from pyautogen) (1.25.2)\n",
85-
"Requirement already satisfied: openai>=1.3 in /usr/local/lib/python3.10/dist-packages (from pyautogen) (1.30.5)\n",
86-
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from pyautogen) (24.0)\n",
87-
"Requirement already satisfied: pydantic!=2.6.0,<3,>=1.10 in /usr/local/lib/python3.10/dist-packages (from pyautogen) (2.7.1)\n",
88-
"Requirement already satisfied: python-dotenv in /usr/local/lib/python3.10/dist-packages (from pyautogen) (1.0.1)\n",
89-
"Requirement already satisfied: termcolor in /usr/local/lib/python3.10/dist-packages (from pyautogen) (2.4.0)\n",
90-
"Requirement already satisfied: tiktoken in /usr/local/lib/python3.10/dist-packages (from pyautogen) (0.7.0)\n",
81+
"\u001b[?25hRequirement already satisfied: diskcache in /usr/local/lib/python3.10/dist-packages (from ag2) (5.6.3)\n",
82+
"Requirement already satisfied: docker in /usr/local/lib/python3.10/dist-packages (from ag2) (7.1.0)\n",
83+
"Requirement already satisfied: flaml in /usr/local/lib/python3.10/dist-packages (from ag2) (2.1.2)\n",
84+
"Requirement already satisfied: numpy<2,>=1.17.0 in /usr/local/lib/python3.10/dist-packages (from ag2) (1.25.2)\n",
85+
"Requirement already satisfied: openai>=1.3 in /usr/local/lib/python3.10/dist-packages (from ag2) (1.30.5)\n",
86+
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from ag2) (24.0)\n",
87+
"Requirement already satisfied: pydantic!=2.6.0,<3,>=1.10 in /usr/local/lib/python3.10/dist-packages (from ag2) (2.7.1)\n",
88+
"Requirement already satisfied: python-dotenv in /usr/local/lib/python3.10/dist-packages (from ag2) (1.0.1)\n",
89+
"Requirement already satisfied: termcolor in /usr/local/lib/python3.10/dist-packages (from ag2) (2.4.0)\n",
90+
"Requirement already satisfied: tiktoken in /usr/local/lib/python3.10/dist-packages (from ag2) (0.7.0)\n",
9191
"Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from portkey-ai) (0.27.0)\n",
9292
"Collecting mypy<2.0,>=0.991 (from portkey-ai)\n",
9393
" Downloading mypy-1.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB)\n",
@@ -96,28 +96,28 @@
9696
"Collecting mypy-extensions>=1.0.0 (from mypy<2.0,>=0.991->portkey-ai)\n",
9797
" Downloading mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)\n",
9898
"Requirement already satisfied: tomli>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from mypy<2.0,>=0.991->portkey-ai) (2.0.1)\n",
99-
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->pyautogen) (3.7.1)\n",
100-
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai>=1.3->pyautogen) (1.7.0)\n",
101-
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->pyautogen) (1.3.1)\n",
102-
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->pyautogen) (4.66.4)\n",
99+
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->ag2) (3.7.1)\n",
100+
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai>=1.3->ag2) (1.7.0)\n",
101+
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->ag2) (1.3.1)\n",
102+
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.3->ag2) (4.66.4)\n",
103103
"Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx->portkey-ai) (2024.2.2)\n",
104104
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->portkey-ai) (1.0.5)\n",
105105
"Requirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx->portkey-ai) (3.7)\n",
106106
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx->portkey-ai) (0.14.0)\n",
107-
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.6.0,<3,>=1.10->pyautogen) (0.7.0)\n",
108-
"Requirement already satisfied: pydantic-core==2.18.2 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.6.0,<3,>=1.10->pyautogen) (2.18.2)\n",
109-
"Requirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.10/dist-packages (from docker->pyautogen) (2.31.0)\n",
110-
"Requirement already satisfied: urllib3>=1.26.0 in /usr/local/lib/python3.10/dist-packages (from docker->pyautogen) (2.0.7)\n",
111-
"Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.10/dist-packages (from tiktoken->pyautogen) (2024.5.15)\n",
112-
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai>=1.3->pyautogen) (1.2.1)\n",
113-
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->docker->pyautogen) (3.3.2)\n",
107+
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.6.0,<3,>=1.10->ag2) (0.7.0)\n",
108+
"Requirement already satisfied: pydantic-core==2.18.2 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.6.0,<3,>=1.10->ag2) (2.18.2)\n",
109+
"Requirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.10/dist-packages (from docker->ag2) (2.31.0)\n",
110+
"Requirement already satisfied: urllib3>=1.26.0 in /usr/local/lib/python3.10/dist-packages (from docker->ag2) (2.0.7)\n",
111+
"Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.10/dist-packages (from tiktoken->ag2) (2024.5.15)\n",
112+
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai>=1.3->ag2) (1.2.1)\n",
113+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->docker->ag2) (3.3.2)\n",
114114
"Installing collected packages: mypy-extensions, mypy, portkey-ai\n",
115115
"Successfully installed mypy-1.10.0 mypy-extensions-1.0.0 portkey-ai-1.3.2\n"
116116
]
117117
}
118118
],
119119
"source": [
120-
"!pip install -qU pyautogen portkey-ai"
120+
"!pip install -qU ag2 portkey-ai"
121121
]
122122
},
123123
{

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@portkey-ai/gateway",
3-
"version": "1.10.2",
3+
"version": "1.11.0",
44
"description": "A fast AI gateway by Portkey",
55
"repository": {
66
"type": "git",

plugins/default/webhook.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export const handler: PluginHandler = async (
106106
webhookUrl: url,
107107
responseData: response.data,
108108
requestContext: {
109-
headers,
110109
timeout: parameters.timeout || 3000,
111110
},
112111
};
@@ -123,7 +122,6 @@ export const handler: PluginHandler = async (
123122
explanation: `Webhook error: ${e.message}`,
124123
webhookUrl: parameters.webhookURL || 'No URL provided',
125124
requestContext: {
126-
headers: parameters.headers || {},
127125
timeout: parameters.timeout || 3000,
128126
},
129127
// return response body if it's not a ok response and not a timeout error

plugins/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { handler as promptSecurityProtectResponse } from './promptsecurity/prote
4949
import { handler as panwPrismaAirsintercept } from './panw-prisma-airs/intercept';
5050
import { handler as defaultjwt } from './default/jwt';
5151
import { handler as defaultrequiredMetadataKeys } from './default/requiredMetadataKeys';
52+
import { handler as walledaiguardrails } from './walledai/guardrails';
5253

5354
export const plugins = {
5455
default: {
@@ -134,4 +135,7 @@ export const plugins = {
134135
'panw-prisma-airs': {
135136
intercept: panwPrismaAirsintercept,
136137
},
138+
walledai: {
139+
guardrails: walledaiguardrails,
140+
},
137141
};

plugins/walledai/guardrails.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import {
2+
HookEventType,
3+
PluginContext,
4+
PluginHandler,
5+
PluginParameters,
6+
} from '../types';
7+
import { post, getText, getCurrentContentPart } from '../utils';
8+
9+
const API_URL = 'https://services.walled.ai/v1/guardrail/moderate';
10+
11+
const DEFAULT_PII_LIST = [
12+
"Person's Name",
13+
'Address',
14+
'Email Id',
15+
'Contact No',
16+
'Date Of Birth',
17+
'Unique Id',
18+
'Financial Data',
19+
];
20+
21+
const DEFAULT_GREETINGS_LIST = ['Casual & Friendly', 'Professional & Polite'];
22+
23+
export const handler: PluginHandler = async (
24+
context: PluginContext,
25+
parameters: PluginParameters,
26+
eventType: HookEventType
27+
) => {
28+
let error = null;
29+
let verdict = true;
30+
let data = null;
31+
32+
if (!parameters.credentials?.apiKey) {
33+
return {
34+
error: `'parameters.credentials.apiKey' must be set`,
35+
verdict: true,
36+
data,
37+
};
38+
}
39+
40+
const { content, textArray } = getCurrentContentPart(context, eventType);
41+
if (!content) {
42+
return {
43+
error: { message: 'request or response json is empty' },
44+
verdict: true,
45+
data: null,
46+
};
47+
}
48+
let text = textArray.filter((text) => text).join('\n');
49+
50+
// Prepare request body
51+
const requestBody = {
52+
text: text,
53+
text_type: parameters.text_type || 'prompt',
54+
generic_safety_check: parameters.generic_safety_check ?? true,
55+
greetings_list: parameters.greetings_list || DEFAULT_GREETINGS_LIST,
56+
pii_list: parameters.pii_list || DEFAULT_PII_LIST,
57+
compliance_list: parameters.compliance_list || [],
58+
};
59+
// Prepare headers
60+
const requestOptions = {
61+
headers: {
62+
'Content-Type': 'application/json',
63+
Authorization: `Bearer ${parameters.credentials.apiKey}`,
64+
},
65+
};
66+
67+
try {
68+
const response = await post(
69+
API_URL,
70+
requestBody,
71+
requestOptions,
72+
parameters.timeout
73+
);
74+
data = response.data;
75+
if (data.safety[0]?.isSafe == false) {
76+
verdict = false;
77+
}
78+
} catch (e) {
79+
console.log(e);
80+
error = e instanceof Error ? e.message : String(e);
81+
verdict = true;
82+
data = null;
83+
}
84+
return {
85+
error,
86+
verdict,
87+
data,
88+
};
89+
};

plugins/walledai/manifest.json

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"id": "walledai",
3+
"description": "Walled AI",
4+
"credentials": {
5+
"type": "object",
6+
"properties": {
7+
"apiKey": {
8+
"type": "string",
9+
"label": "API Key",
10+
"description": "Find your API key in the Walled AI dashboard (https://dev.walled.ai/)",
11+
"encrypted": true
12+
}
13+
},
14+
"required": ["apiKey"]
15+
},
16+
"functions": [
17+
{
18+
"name": "Walled AI Guardrail for checking safety of LLM inputs",
19+
"id": "guardrails",
20+
"supportedHooks": ["beforeRequestHook", "afterRequestHook"],
21+
"type": "guardrail",
22+
"description": [
23+
{
24+
"type": "subHeading",
25+
"text": "Ensure the safety and compliance of your LLM inputs with Walled AI's advanced guardrail system."
26+
}
27+
],
28+
"parameters": {
29+
"type": "object",
30+
"properties": {
31+
"text_type": {
32+
"type": "string",
33+
"label": "Text Type",
34+
"description": [
35+
{
36+
"type": "subHeading",
37+
"text": "Type of Text , defaults to 'prompt'"
38+
}
39+
],
40+
"default": "prompt"
41+
},
42+
"generic_safety_check": {
43+
"type": "string",
44+
"label": "Generic Safety Check",
45+
"description": [
46+
{
47+
"type": "subHeading",
48+
"text": "Boolean value to enable generic safety checks on the text input. Defaults to 'true'."
49+
}
50+
],
51+
"default": true
52+
},
53+
"greetings_list": {
54+
"type": "array",
55+
"label": "Greetings List",
56+
"description": [
57+
{
58+
"type": "subHeading",
59+
"text": "List of greetings to be used in the guardrail check. This can help in identifying and handling greetings appropriately."
60+
}
61+
],
62+
"items": {
63+
"type": "string"
64+
},
65+
"default": ["Casual & Friendly", "Professional & Polite"]
66+
},
67+
"pii_list": {
68+
"type": "array",
69+
"label": "PII LIST",
70+
"description": [
71+
{
72+
"type": "subHeading",
73+
"text": "Identify all the PII for only the following types of PII will be checked in the text input. Defaults to empty list"
74+
}
75+
],
76+
"items": {
77+
"type": "string",
78+
"enum": [
79+
"Person's Name",
80+
"Address",
81+
"Email Id",
82+
"Contact No",
83+
"Date Of Birth",
84+
"Unique Id",
85+
"Financial Data"
86+
]
87+
},
88+
"default": [
89+
"Person's Name",
90+
"Address",
91+
"Email Id",
92+
"Contact No",
93+
"Date Of Birth",
94+
"Unique Id",
95+
"Financial Data"
96+
]
97+
},
98+
"compliance_list": {
99+
"type": "array",
100+
"label": "List of Compliance Checks",
101+
"description": [
102+
{
103+
"type": "subHeading",
104+
"text": "List of compliance checks to be performed on the text input. This can help in ensuring that the text adheres to specific compliance standards. Defaults to empty"
105+
}
106+
],
107+
"items": {
108+
"type": "string"
109+
},
110+
"default": []
111+
}
112+
}
113+
}
114+
}
115+
]
116+
}

0 commit comments

Comments
 (0)