-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.py
More file actions
33 lines (30 loc) · 942 Bytes
/
basic.py
File metadata and controls
33 lines (30 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Basic Veil AI Firewall + OpenAI example."""
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
base_url="https://veil-api.com/v1",
default_headers={
"Authorization": f"Bearer {os.environ['VEIL_API_KEY']}",
"x-upstream-key": os.environ["OPENAI_API_KEY"],
"x-veil-input-policy": "block",
"x-veil-output-policy": "monitor",
},
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": (
"Summarize this support ticket:\n\n"
"From: Sarah Johnson (sarah.j@acme.com)\n"
"Phone: 408-555-7721\n"
"SSN: 521-03-8847\n"
"Card: 4111111111111111\n\n"
"Issue: Charged twice for Premium subscription."
),
}
],
)
print(response.choices[0].message.content)