-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_enforcement.py
More file actions
42 lines (31 loc) · 878 Bytes
/
basic_enforcement.py
File metadata and controls
42 lines (31 loc) · 878 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
34
35
36
37
38
39
40
41
42
# examples/basic_enforcement.py
from veloryn import execute, print_summary
from openai import OpenAI
client = OpenAI()
TASK_ID = "basic-enforcement"
MAX_COST = 0.1
def run_task():
response = client.responses.create(
model="gpt-4o",
input="Analyze this startup idea: AI-powered fitness coach",
max_output_tokens=800,
)
return {
"output": response.output_text,
"usage": {
"input_tokens": response.usage.input_tokens,
"output_tokens": response.usage.output_tokens,
},
}
while True:
try:
execute(
task_id=TASK_ID,
run_task=run_task,
input_data="Startup analysis",
model="gpt-4o",
max_cost=MAX_COST,
)
except RuntimeError:
break
print_summary(TASK_ID)