-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
Copy pathlocustfile.py
139 lines (130 loc) · 4.7 KB
/
locustfile.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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,
},
},
},
)
class ChatVisionUser(HttpUser):
wait_time = between(5, 20)
@task
def ask_question(self):
self.client.get("/")
time.sleep(self.wait_time())
self.client.post(
"/chat/stream",
json={
"messages": [
{
"content": "Can you identify any correlation between oil prices and stock market trends?",
"role": "user",
}
],
"context": {
"overrides": {
"top": 3,
"temperature": 0.3,
"minimum_reranker_score": 0,
"minimum_search_score": 0,
"retrieval_mode": "hybrid",
"semantic_ranker": True,
"semantic_captions": False,
"suggest_followup_questions": False,
"use_oid_security_filter": False,
"use_groups_security_filter": False,
"vector_fields": ["embedding", "imageEmbedding"],
"use_gpt4v": True,
"gpt4v_input": "textAndImages",
}
},
"session_state": None,
},
)
time.sleep(self.wait_time())
self.client.post(
"/chat/stream",
json={
"messages": [
{"content": "Compare the impact of interest rates and GDP in financial markets.", "role": "user"}
],
"context": {
"overrides": {
"top": 3,
"temperature": 0.3,
"minimum_reranker_score": 0,
"minimum_search_score": 0,
"retrieval_mode": "hybrid",
"semantic_ranker": True,
"semantic_captions": False,
"suggest_followup_questions": False,
"use_oid_security_filter": False,
"use_groups_security_filter": False,
"vector_fields": ["embedding", "imageEmbedding"],
"use_gpt4v": True,
"gpt4v_input": "textAndImages",
}
},
"session_state": None,
},
)