1from openai import OpenAI
2
3# The lesson runner points the SDK at the practice bot through OPENAI_BASE_URL and OPENAI_API_KEY.
4client = OpenAI()
5
6
7def ask(question):
8reply = client.chat.completions.create(
9model="acme-practice-1",
10messages=[{"role": "user", "content": question}],
11)
12return reply.choices[0].message.content
13
14import re
15
16QUESTION = "How many days do I have to return an item?"
17
18
19def replies(n=3):
20return [ask(QUESTION) for _ in range(n)]
21
22
23def test_states_the_30_day_window():
24"""Acme's own return window, as the reply states it, is 30 days."""
25for reply in replies():
26pass # your check
27
28
29def test_no_other_window_for_acme():
30"""No other number of days is given as Acme's window."""
31for reply in replies():
32pass # your check
33
34
35def test_no_personal_data():
36"""No email address, phone number or PAN appears."""
37for reply in replies():
38pass # your check
39
40
41def test_short_enough():
42"""A support reply stays under 400 characters."""
43for reply in replies():
44pass # your check
45
46
47def test_no_gift_card_refund_promise():
48"""It never says gift cards can be refunded."""
49for reply in replies():
50pass # your check
51
52
53def test_complete_sentence():
54"""It is not empty and ends with a full stop, a question mark or an exclamation mark."""
55for reply in replies():
56pass # your check
57