-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathlocustfile.py
More file actions
74 lines (68 loc) · 2.28 KB
/
Copy pathlocustfile.py
File metadata and controls
74 lines (68 loc) · 2.28 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import random
import time
from locust import HttpUser, between, task
class ChatUser(HttpUser):
wait_time = between(5, 20)
@task
def ask_question(self):
self.client.get(
"/",
name="home",
)
time.sleep(self.wait_time())
first_question = random.choice(
[
"What is included in my Northwind Health Plus plan that is not in standard?",
"What does a Product Manager do?",
"What happens in a performance review?",
"Whats your whistleblower policy?",
]
)
response = self.client.post(
"/chat",
name="initial chat",
json={
"messages": [
{
"content": first_question,
"role": "user",
},
],
"context": {
"overrides": {
"retrieval_mode": "hybrid",
"semantic_ranker": True,
"semantic_captions": False,
"top": 3,
"suggest_followup_questions": True,
},
},
},
)
time.sleep(self.wait_time())
# use one of the follow up questions.
follow_up_question = random.choice(response.json()["context"]["followup_questions"])
result_message = response.json()["message"]["content"]
self.client.post(
"/chat",
name="follow up chat",
json={
"messages": [
{"content": first_question, "role": "user"},
{
"content": result_message,
"role": "assistant",
},
{"content": follow_up_question, "role": "user"},
],
"context": {
"overrides": {
"retrieval_mode": "hybrid",
"semantic_ranker": True,
"semantic_captions": False,
"top": 3,
"suggest_followup_questions": False,
},
},
},
)