Skip to content

Commit a00a65b

Browse files
tonybaloneydfl-aeb
authored andcommitted
Improve locust test script (Azure-Samples#2357)
* Improve the logic in the locust tests * ask for follow up questions * With the GPT-V test * reformatted file
1 parent 93bfd76 commit a00a65b

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

locustfile.py

+29-18
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@ class ChatUser(HttpUser):
99

1010
@task
1111
def ask_question(self):
12-
self.client.get("/")
13-
time.sleep(5)
14-
self.client.post(
12+
self.client.get(
13+
"/",
14+
name="home",
15+
)
16+
time.sleep(self.wait_time())
17+
first_question = random.choice(
18+
[
19+
"What is included in my Northwind Health Plus plan that is not in standard?",
20+
"What does a Product Manager do?",
21+
"What happens in a performance review?",
22+
"Whats your whistleblower policy?",
23+
]
24+
)
25+
26+
response = self.client.post(
1527
"/chat",
28+
name="initial chat",
1629
json={
1730
"messages": [
1831
{
19-
"content": random.choice(
20-
[
21-
"What is included in my Northwind Health Plus plan that is not in standard?",
22-
"What does a Product Manager do?",
23-
"What happens in a performance review?",
24-
"Whats your whistleblower policy?",
25-
]
26-
),
32+
"content": first_question,
2733
"role": "user",
2834
},
2935
],
@@ -33,22 +39,27 @@ def ask_question(self):
3339
"semantic_ranker": True,
3440
"semantic_captions": False,
3541
"top": 3,
36-
"suggest_followup_questions": False,
42+
"suggest_followup_questions": True,
3743
},
3844
},
3945
},
4046
)
41-
time.sleep(5)
47+
time.sleep(self.wait_time())
48+
# use one of the follow up questions.
49+
follow_up_question = random.choice(response.json()["context"]["followup_questions"])
50+
result_message = response.json()["message"]["content"]
51+
4252
self.client.post(
4353
"/chat",
54+
name="follow up chat",
4455
json={
4556
"messages": [
46-
{"content": "What happens in a performance review?", "role": "user"},
57+
{"content": first_question, "role": "user"},
4758
{
48-
"content": "During a performance review, employees will receive feedback on their performance over the past year, including both successes and areas for improvement. The feedback will be provided by the employee's supervisor and is intended to help the employee develop and grow in their role [employee_handbook-3.pdf]. The review is a two-way dialogue between the employee and their manager, so employees are encouraged to be honest and open during the process [employee_handbook-3.pdf]. The employee will also have the opportunity to discuss their goals and objectives for the upcoming year [employee_handbook-3.pdf]. A written summary of the performance review will be provided to the employee, which will include a rating of their performance, feedback, and goals and objectives for the upcoming year [employee_handbook-3.pdf].",
59+
"content": result_message,
4960
"role": "assistant",
5061
},
51-
{"content": "Does my plan cover eye exams?", "role": "user"},
62+
{"content": follow_up_question, "role": "user"},
5263
],
5364
"context": {
5465
"overrides": {
@@ -69,7 +80,7 @@ class ChatVisionUser(HttpUser):
6980
@task
7081
def ask_question(self):
7182
self.client.get("/")
72-
time.sleep(5)
83+
time.sleep(self.wait_time())
7384
self.client.post(
7485
"/chat/stream",
7586
json={
@@ -99,7 +110,7 @@ def ask_question(self):
99110
"session_state": None,
100111
},
101112
)
102-
time.sleep(5)
113+
time.sleep(self.wait_time())
103114
self.client.post(
104115
"/chat/stream",
105116
json={

0 commit comments

Comments
 (0)