@@ -88,6 +88,19 @@ class HeaderItem(BaseModel):
8888 fixed : bool = True
8989
9090
91+ class CookieItem (BaseModel ):
92+ """
93+ Represents a single HTTP cookie item for a request.
94+
95+ Attributes:
96+ key: The cookie name.
97+ value: The cookie value.
98+ """
99+
100+ key : str
101+ value : str
102+
103+
91104class CertConfig (BaseModel ):
92105 """
93106 Configuration for SSL/TLS certificates.
@@ -123,19 +136,24 @@ class TaskCreateReq(BaseModel):
123136 api_path : str = Field (
124137 default = "/v1/chat/completions" , description = "API path to test"
125138 )
126- model : str = Field (... , description = "Name of the model to test" )
139+ model : Optional [ str ] = Field (default = "" , description = "Name of the model to test" )
127140 duration : int = Field (
128141 default = 300 , ge = 1 , description = "Duration of the test in seconds"
129142 )
130143 concurrent_users : int = Field (..., ge = 1 , description = "Number of concurrent users" )
131144 spawn_rate : int = Field (ge = 1 , description = "Number of users to spawn per second" )
132- chat_type : int = Field (ge = 0 , description = "Type of chat interaction" )
145+ chat_type : Optional [int ] = Field (
146+ default = 0 , ge = 0 , description = "Type of chat interaction"
147+ )
133148 stream_mode : bool = Field (
134149 default = True , description = "Whether to use streaming response"
135150 )
136151 headers : List [HeaderItem ] = Field (
137152 default_factory = list , description = "List of request headers"
138153 )
154+ cookies : List [CookieItem ] = Field (
155+ default_factory = list , description = "List of request cookies"
156+ )
139157 cert_config : Optional [CertConfig ] = Field (
140158 default = None , description = "Certificate configuration"
141159 )
@@ -145,6 +163,12 @@ class TaskCreateReq(BaseModel):
145163 user_prompt : Optional [str ] = Field (
146164 default = "" , description = "User prompt for the model"
147165 )
166+ request_payload : Optional [str ] = Field (
167+ default = "" , description = "Custom request payload for non-chat APIs (JSON string)"
168+ )
169+ field_mapping : Optional [Dict [str , str ]] = Field (
170+ default = None , description = "Field mapping configuration for custom APIs"
171+ )
148172
149173
150174class TaskResultItem (BaseModel ):
@@ -289,20 +313,23 @@ class Task(Base):
289313 name = Column (String (255 ), nullable = False )
290314 status = Column (String (32 ), nullable = False )
291315 target_host = Column (String (255 ), nullable = False )
292- model = Column (String (100 ), nullable = False )
316+ model = Column (String (100 ), nullable = True )
293317 system_prompt = Column (Text , nullable = True )
294318 user_prompt = Column (Text , nullable = True )
295319 stream_mode = Column (String (20 ), nullable = False )
296320 concurrent_users = Column (Integer , nullable = False )
297321 spawn_rate = Column (Integer , nullable = False )
298322 duration = Column (Integer , nullable = False )
299- chat_type = Column (Integer , nullable = False )
323+ chat_type = Column (Integer , nullable = True )
300324 log_file = Column (Text , nullable = True )
301325 result_file = Column (Text , nullable = True )
302326 cert_file = Column (String (255 ), nullable = True )
303327 key_file = Column (String (255 ), nullable = True )
304328 headers = Column (Text , nullable = True )
305- # api_path = Column(String(255), nullable=True)
329+ cookies = Column (Text , nullable = True )
330+ api_path = Column (String (255 ), nullable = True )
331+ request_payload = Column (Text , nullable = True )
332+ field_mapping = Column (Text , nullable = True )
306333 error_message = Column (Text , nullable = True )
307334 created_at = Column (DateTime , server_default = func .now ())
308335 updated_at = Column (DateTime , server_default = func .now (), onupdate = func .now ())
@@ -326,10 +353,10 @@ class TaskResult(Base):
326353 p90_latency = Column (Float , nullable = False )
327354 rps = Column (Float , nullable = False )
328355 avg_content_length = Column (Float , nullable = False )
329- total_tps = Column (Float , nullable = False )
330- completion_tps = Column (Float , nullable = False )
331- avg_total_tokens_per_req = Column (Float , nullable = False )
332- avg_completion_tokens_per_req = Column (Float , nullable = False )
356+ total_tps = Column (Float , nullable = True , default = 0.0 )
357+ completion_tps = Column (Float , nullable = True , default = 0.0 )
358+ avg_total_tokens_per_req = Column (Float , nullable = True , default = 0.0 )
359+ avg_completion_tokens_per_req = Column (Float , nullable = True , default = 0.0 )
333360 created_at = Column (DateTime , server_default = func .now ())
334361 updated_at = Column (DateTime , server_default = func .now (), onupdate = func .now ())
335362
@@ -349,8 +376,18 @@ def to_task_result_item(self) -> TaskResultItem:
349376 rps = self .rps ,
350377 avg_content_length = self .avg_content_length ,
351378 created_at = self .created_at .isoformat () if self .created_at else "" ,
352- total_tps = self .total_tps ,
353- completion_tps = self .completion_tps ,
354- avg_total_tokens_per_req = self .avg_total_tokens_per_req ,
355- avg_completion_tokens_per_req = self .avg_completion_tokens_per_req ,
379+ total_tps = self .total_tps if self .total_tps is not None else 0.0 ,
380+ completion_tps = (
381+ self .completion_tps if self .completion_tps is not None else 0.0
382+ ),
383+ avg_total_tokens_per_req = (
384+ self .avg_total_tokens_per_req
385+ if self .avg_total_tokens_per_req is not None
386+ else 0.0
387+ ),
388+ avg_completion_tokens_per_req = (
389+ self .avg_completion_tokens_per_req
390+ if self .avg_completion_tokens_per_req is not None
391+ else 0.0
392+ ),
356393 )
0 commit comments