-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodel.py
More file actions
769 lines (605 loc) · 25.1 KB
/
Copy pathmodel.py
File metadata and controls
769 lines (605 loc) · 25.1 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# generated by datamodel-codegen:
# filename: public-api.yaml
# timestamp: 2026-07-10T01:01:06+00:00
from __future__ import annotations
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from pydantic import AnyUrl, BaseModel, Field, RootModel, confloat, conint, constr
class AccountMonthToDateInfo(BaseModel):
"""
Account usage information for the current month
"""
iqs: int = Field(..., description="The number of image queries in the current month.")
escalations: int = Field(..., description="The number of escalations in the current month.")
active_detectors: int = Field(..., description="The number of active detectors in the current month.")
iqs_limit: Optional[int] = Field(..., description="The limit on the number of image queries in the current month.")
escalations_limit: Optional[int] = Field(
..., description="The limit on the number of escalations in the current month."
)
active_detectors_limit: Optional[int] = Field(
..., description="The limit on the number of active detectors in the current month."
)
class BBoxGeometry(BaseModel):
"""
Mixin for serializers to handle data in the StrictBaseModel format
"""
left: float
top: float
right: float
bottom: float
x: float
y: float
class BBoxGeometryRequest(BaseModel):
"""
Mixin for serializers to handle data in the StrictBaseModel format
"""
left: float
top: float
right: float
bottom: float
class BlankEnum(Enum):
field_ = ""
class Condition(BaseModel):
verb: str
parameters: Dict[str, Any]
class ConditionRequest(BaseModel):
verb: str
parameters: Dict[str, Any]
class DetectorGroup(BaseModel):
id: str
name: constr(max_length=100)
class DetectorGroupRequest(BaseModel):
name: constr(min_length=1, max_length=100)
class DetectorModeEnum(str, Enum):
"""
* `BINARY` - BINARY
* `COUNT` - COUNT
* `MULTI_CLASS` - MULTI_CLASS
* `TEXT` - TEXT
* `BOUNDING_BOX` - BOUNDING_BOX
"""
BINARY = "BINARY"
COUNT = "COUNT"
MULTI_CLASS = "MULTI_CLASS"
TEXT = "TEXT"
BOUNDING_BOX = "BOUNDING_BOX"
class DetectorTypeEnum(str, Enum):
detector = "detector"
class EdgeModelInfo(BaseModel):
"""
Information for the model running on edge, including temporary presigned urls to the model binaries
"""
model_binary_id: Optional[str] = None
model_binary_url: Optional[str] = None
oodd_model_binary_id: Optional[str] = None
oodd_model_binary_url: Optional[str] = None
pipeline_config: Optional[Any] = None
oodd_pipeline_config: Optional[Any] = None
predictor_metadata: Optional[Any] = None
minimal_compatible: bool = False
class ImageQueryTypeEnum(str, Enum):
image_query = "image_query"
class MLPipeline(BaseModel):
"""
A single ML pipeline attached to a detector.
Includes training status and metrics for the Pipeline Details UI.
"""
id: str
pipeline_config: str = Field(..., description="Get the resolved pipeline config, including defaults.")
is_active_pipeline: bool = Field(
...,
description=(
"If True, this is the pipeline is used for inference, active learning, etc. for its parent Predictor."
),
)
is_edge_pipeline: bool = Field(..., description="If True, this pipeline is enabled for edge inference.")
is_unclear_pipeline: bool = Field(
..., description="If True, this pipeline is used to train classifier for human unclear label prediction."
)
is_oodd_pipeline: bool = Field(..., description="If True, this pipeline is used for OODD.")
is_enabled: bool = Field(..., description="If False, this pipeline will not be run for any use case.")
created_at: datetime
trained_at: Optional[datetime] = Field(...)
type: str = Field(..., description="Determine the pipeline type (active, shadow, unclear, oodd).")
friendly_name: Optional[str] = Field(..., description="Get the friendly name from the MLBinary.")
model_binary_id: Optional[str] = Field(...)
training_in_progress: Optional[Dict[str, Any]] = Field(
..., description="Check if training is currently in progress for this pipeline."
)
metrics: Dict[str, Any] = Field(
..., description="Get the metrics for this pipeline from MLBinary metadata and evaluation results."
)
eval_mlbinary_key: Optional[str] = Field(..., description="Get the MLBinary key that was evaluated.")
eval_mlbinary_revision_number: Optional[int] = Field(
..., description="Get the revision number of the MLBinary that was evaluated."
)
eval_mlbinary_friendly_name: Optional[str] = Field(
..., description="Get the friendly name of the MLBinary that was evaluated."
)
class ModeEnum(str, Enum):
BINARY = "BINARY"
COUNT = "COUNT"
MULTI_CLASS = "MULTI_CLASS"
TEXT = "TEXT"
BOUNDING_BOX = "BOUNDING_BOX"
class Note(BaseModel):
detector_id: str
content: Optional[str] = Field(None, description="Text content of the note.")
is_pinned: Optional[bool] = None
class NoteRequest(BaseModel):
content: Optional[str] = Field(None, description="Text content of the note.")
is_pinned: Optional[bool] = None
image: Optional[bytes] = None
class NullEnum(Enum):
NoneType_None = None
class PaginatedMLPipelineList(BaseModel):
count: int = Field(..., examples=[123])
next: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=4"])
previous: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=2"])
results: List[MLPipeline]
class PayloadTemplate(BaseModel):
template: str
headers: Optional[Dict[str, str]] = None
class PayloadTemplateRequest(BaseModel):
template: constr(min_length=1)
headers: Optional[Dict[str, constr(min_length=1)]] = None
class PrimingGroup(BaseModel):
"""
A PrimingGroup owned by the authenticated user.
"""
id: str
name: constr(max_length=100)
detector_mode: Optional[Union[DetectorModeEnum, BlankEnum, NullEnum]] = Field(
None,
description=(
"Detector mode this priming group is intended for (BINARY, MULTI_CLASS, etc.). Validated against the"
" pipeline_config of every active and shadow base MLBinary in clean(). Nullable only for legacy rows"
" pre-dating this field; new PrimingGroups must set it.\n\n* `BINARY` - BINARY\n* `COUNT` - COUNT\n*"
" `MULTI_CLASS` - MULTI_CLASS\n* `TEXT` - TEXT\n* `BOUNDING_BOX` - BOUNDING_BOX"
),
)
num_classes: Optional[int] = Field(
...,
description=(
"Number of output classes this priming group is trained for. Set automatically from the source predictor"
" when created via create_user_priming_group (MULTI_CLASS only). Nullable for legacy rows and for modes"
" where class count isn't meaningful; a follow-up PR will tighten this after manual backfill."
),
)
is_global: bool = Field(
...,
description=(
"If True, this priming group is shared to all Groundlight users. Can only be set by Groundlight admins."
),
)
canonical_query: Optional[constr(max_length=300)] = Field(
None, description="Canonical semantic query for this priming group"
)
active_pipeline_config: Optional[constr(max_length=8192)] = Field(
None,
description=(
"Active pipeline config override for new detectors created in this priming group. If set, this overrides"
" the default active pipeline config at creation time.Can be either a pipeline name or full config string."
),
)
priming_group_specific_shadow_pipeline_configs: Optional[Any] = Field(
None,
description=(
"Configs for shadow pipelines to create for detectors in this priming group. These are added to the default"
" shadow pipeline configs for a detector of the given mode. Each entry is either a pipeline name or full"
" config string. "
),
)
disable_shadow_pipelines: Optional[bool] = Field(
None,
description=(
"If True, new detectors added to this priming group will not receive the mode-specific default shadow"
" pipelines from INITIAL_SHADOW_PIPELINE_CONFIG_SET. Priming-group-specific shadow configs still apply. Use"
" this to guarantee the primed active MLBinary is never switched off by a shadow pipeline being promoted."
),
)
created_at: datetime
class PrimingGroupCreationInputRequest(BaseModel):
"""
Input for creating a new user-owned PrimingGroup seeded from an existing MLPipeline.
"""
name: constr(min_length=1, max_length=100) = Field(..., description="Name for the new priming group.")
source_ml_pipeline_id: constr(min_length=1, max_length=44) = Field(
..., description="ID of an MLPipeline owned by this account whose trained model will seed the priming group."
)
detector_mode: DetectorModeEnum = Field(
...,
description=(
"Detector mode this priming group is intended for (BINARY, MULTI_CLASS, etc.). Must match the mode"
" supported by the source MLPipeline's pipeline_config.\n\n* `BINARY` - BINARY\n* `COUNT` - COUNT\n*"
" `MULTI_CLASS` - MULTI_CLASS\n* `TEXT` - TEXT\n* `BOUNDING_BOX` - BOUNDING_BOX"
),
)
canonical_query: Optional[constr(max_length=300)] = Field(
None, description="Optional canonical semantic query describing this priming group."
)
disable_shadow_pipelines: bool = Field(
False,
description=(
"If true, new detectors added to this priming group will not receive the default shadow pipelines. This"
" guarantees the primed active model is never switched off."
),
)
class ROI(BaseModel):
"""
Mixin for serializers to handle data in the StrictBaseModel format
"""
label: str = Field(..., description="The label of the bounding box.")
score: float = Field(..., description="The confidence of the bounding box.")
geometry: BBoxGeometry
class ROIRequest(BaseModel):
"""
Mixin for serializers to handle data in the StrictBaseModel format
"""
label: constr(min_length=1) = Field(..., description="The label of the bounding box.")
geometry: BBoxGeometryRequest
class ResultTypeEnum(str, Enum):
binary_classification = "binary_classification"
counting = "counting"
multi_classification = "multi_classification"
text_recognition = "text_recognition"
bounding_box = "bounding_box"
class SnoozeTimeUnitEnum(str, Enum):
"""
* `DAYS` - DAYS
* `HOURS` - HOURS
* `MINUTES` - MINUTES
* `SECONDS` - SECONDS
"""
DAYS = "DAYS"
HOURS = "HOURS"
MINUTES = "MINUTES"
SECONDS = "SECONDS"
class StatusEnum(str, Enum):
"""
* `ON` - ON
* `OFF` - OFF
"""
ON = "ON"
OFF = "OFF"
class WebhookAction(BaseModel):
url: AnyUrl
include_image: Optional[bool] = None
payload_template: Optional[PayloadTemplate] = None
last_message_failed: Optional[bool] = None
last_failure_error: Optional[str] = None
last_failed_at: Optional[datetime] = None
class WebhookActionRequest(BaseModel):
url: AnyUrl
include_image: Optional[bool] = None
payload_template: Optional[PayloadTemplateRequest] = None
last_message_failed: Optional[bool] = None
last_failure_error: Optional[str] = None
last_failed_at: Optional[datetime] = None
class ResultType(Enum):
binary_classification = "binary_classification"
class BinaryClassificationResult(BaseModel):
confidence: Optional[confloat(ge=0.0, le=1.0)] = None
source: Optional[str] = None
result_type: Optional[ResultType] = None
from_edge: Optional[bool] = None
label: str
class ResultType2(Enum):
counting = "counting"
class CountingResult(BaseModel):
confidence: Optional[confloat(ge=0.0, le=1.0)] = None
source: Optional[str] = None
result_type: Optional[ResultType2] = None
from_edge: Optional[bool] = None
count: Optional[conint(ge=0)] = Field(...)
greater_than_max: Optional[bool] = None
class ResultType3(Enum):
multi_classification = "multi_classification"
class MultiClassificationResult(BaseModel):
confidence: Optional[confloat(ge=0.0, le=1.0)] = None
source: Optional[str] = None
result_type: Optional[ResultType3] = None
from_edge: Optional[bool] = None
label: str
class ResultType4(Enum):
text_recognition = "text_recognition"
class TextRecognitionResult(BaseModel):
confidence: Optional[confloat(ge=0.0, le=1.0)] = None
source: Optional[str] = None
result_type: Optional[ResultType4] = None
from_edge: Optional[bool] = None
text: Optional[str] = Field(...)
truncated: bool
class ResultType5(Enum):
bounding_box = "bounding_box"
class BoundingBoxResult(BaseModel):
confidence: Optional[confloat(ge=0.0, le=1.0)] = None
source: Optional[str] = None
result_type: Optional[ResultType5] = None
from_edge: Optional[bool] = None
label: str
class CountModeConfiguration(BaseModel):
max_count: Optional[conint(ge=1, le=50)] = None
class_name: str
class MultiClassModeConfiguration(BaseModel):
class_names: List[str]
num_classes: Optional[int] = None
class TextModeConfiguration(BaseModel):
value_max_length: Optional[conint(ge=1, le=250)] = None
class BoundingBoxModeConfiguration(BaseModel):
class_name: str
max_num_bboxes: Optional[conint(ge=1, le=50)] = None
class ChannelEnum(str, Enum):
TEXT = "TEXT"
EMAIL = "EMAIL"
class Action(BaseModel):
channel: ChannelEnum
recipient: str
include_image: bool
class ActionList(RootModel[List[Action]]):
root: List[Action]
class AnnotationsRequestedEnum(str, Enum):
BINARY_CLASSIFICATION = "BINARY_CLASSIFICATION"
BOUNDING_BOXES = "BOUNDING_BOXES"
class EscalationTypeEnum(str, Enum):
STANDARD = "STANDARD"
NO_HUMAN_LABELING = "NO_HUMAN_LABELING"
class SourceEnum(str, Enum):
INITIAL_PLACEHOLDER = "INITIAL_PLACEHOLDER"
CLOUD = "CLOUD"
CUST = "CUST"
HUMAN_CLOUD_ENSEMBLE = "HUMAN_CLOUD_ENSEMBLE"
AI_CLOUD = "AI_CLOUD"
AI_CLOUD_ENSEMBLE = "AI_CLOUD_ENSEMBLE"
HUMAN_AI_CLOUD_ENSEMBLE = "HUMAN_AI_CLOUD_ENSEMBLE"
ALG = "ALG"
ALG_REC = "ALG_REC"
ALG_UNCLEAR = "ALG_UNCLEAR"
EDGE = "EDGE"
class VerbEnum(str, Enum):
ANSWERED_CONSECUTIVELY = "ANSWERED_CONSECUTIVELY"
ANSWERED_WITHIN_TIME = "ANSWERED_WITHIN_TIME"
CHANGED_TO = "CHANGED_TO"
NO_CHANGE = "NO_CHANGE"
NO_QUERIES = "NO_QUERIES"
class BoundingBoxLabelEnum(str, Enum):
NO_OBJECTS = "NO_OBJECTS"
BOUNDING_BOX = "BOUNDING_BOX"
GREATER_THAN_MAX = "GREATER_THAN_MAX"
UNCLEAR = "UNCLEAR"
class Source(str, Enum):
STILL_PROCESSING = "STILL_PROCESSING"
CLOUD = "CLOUD"
USER = "USER"
CLOUD_ENSEMBLE = "CLOUD_ENSEMBLE"
ALGORITHM = "ALGORITHM"
AI_CLOUD = "AI_CLOUD"
AI_CLOUD_ENSEMBLE = "AI_CLOUD_ENSEMBLE"
HUMAN_AI_CLOUD_ENSEMBLE = "HUMAN_AI_CLOUD_ENSEMBLE"
EDGE = "EDGE"
class Label(str, Enum):
YES = "YES"
NO = "NO"
UNCLEAR = "UNCLEAR"
class VerdictEnum(str, Enum):
"""
* `YES` - YES
* `NO` - NO
* `UNSURE` - UNSURE
"""
YES = "YES"
NO = "NO"
UNSURE = "UNSURE"
class VlmVerificationCost(BaseModel):
input_tokens: Optional[int] = Field(...)
output_tokens: Optional[int] = Field(...)
total_cost_usd: Optional[float] = Field(...)
class VlmVerificationResult(BaseModel):
verdict: VerdictEnum
confidence: confloat(ge=0.0, le=1.0)
reasoning: str
class AllNotes(BaseModel):
"""
Serializes all notes for a given detector, grouped by type as listed in UserProfile.NoteCategoryChoices
The fields must match whats in USERPROFILE.NoteCategoryChoices
"""
CUSTOMER: List[Note]
GL: List[Note]
class Detector(BaseModel):
"""
Groundlight Detectors provide answers to natural language questions about images.
Each detector can answer a single question, and multiple detectors can be strung together for
more complex logic. Detectors can be created through the create_detector method, or through the
create_[MODE]_detector methods for pro tier users
"""
id: str = Field(..., description="A unique ID for this object.")
type: DetectorTypeEnum = Field(..., description="The type of this object.")
created_at: datetime = Field(..., description="When this detector was created.")
name: constr(max_length=200) = Field(..., description="A short, descriptive name for the detector.")
query: str = Field(..., description="A question about the image.")
group_name: str = Field(..., description="Which group should this detector be part of?")
confidence_threshold: confloat(ge=0.0, le=1.0) = Field(
0.9,
description=(
"If the detector's prediction is below this confidence threshold, send the image query for human review."
),
)
patience_time: confloat(ge=0.0, le=3600.0) = Field(
30.0, description="How long Groundlight will attempt to generate a confident prediction"
)
metadata: Optional[Dict[str, Any]] = Field(..., description="Metadata about the detector.")
mode: str
mode_configuration: Optional[Dict[str, Any]] = Field(...)
status: Optional[Union[StatusEnum, BlankEnum]] = None
escalation_type: Optional[str] = None
class DetectorCreationInputRequest(BaseModel):
"""
Helper serializer for validating POST /detectors input.
"""
name: constr(min_length=1, max_length=200) = Field(..., description="A short, descriptive name for the detector.")
query: constr(min_length=1, max_length=300) = Field(..., description="A question about the image.")
group_name: Optional[constr(min_length=1, max_length=100)] = Field(
None, description="Which group should this detector be part of?"
)
confidence_threshold: confloat(ge=0.0, le=1.0) = Field(
0.9,
description=(
"If the detector's prediction is below this confidence threshold, send the image query for human review."
),
)
patience_time: confloat(ge=0.0, le=3600.0) = Field(
30.0, description="How long Groundlight will attempt to generate a confident prediction"
)
pipeline_config: Optional[constr(max_length=100)] = Field(
None, description="(Advanced usage) Configuration needed to instantiate a prediction pipeline."
)
edge_pipeline_config: Optional[constr(max_length=100)] = Field(
None,
description=(
"(Advanced usage) Configuration for the edge inference pipeline. If not specified, the mode's default edge"
" pipeline is used."
),
)
metadata: Optional[constr(min_length=1, max_length=1362)] = Field(
None,
description=(
"Base64-encoded metadata for the detector. This should be a JSON object with string keys. The size after"
" encoding should not exceed 1362 bytes, corresponding to 1KiB before encoding."
),
)
mode: ModeEnum = Field(
"BINARY",
description=(
"Mode in which this detector will work.\n\n* `BINARY` - BINARY\n* `COUNT` - COUNT\n* `MULTI_CLASS` -"
" MULTI_CLASS\n* `TEXT` - TEXT\n* `BOUNDING_BOX` - BOUNDING_BOX"
),
)
mode_configuration: Optional[
Union[CountModeConfiguration, MultiClassModeConfiguration, TextModeConfiguration, BoundingBoxModeConfiguration]
] = None
priming_group_id: Optional[constr(min_length=1, max_length=44)] = Field(
None, description="ID of an existing PrimingGroup to associate with this detector (optional)."
)
class ImageQuery(BaseModel):
"""
ImageQuery objects are the answers to natural language questions about images created by detectors.
"""
metadata: Optional[Dict[str, Any]] = Field(..., description="Metadata about the image query.")
id: str = Field(..., description="A unique ID for this object.")
type: ImageQueryTypeEnum = Field(..., description="The type of this object.")
created_at: datetime = Field(..., description="When was this detector created?")
query: str = Field(..., description="A question about the image.")
detector_id: str = Field(..., description="Which detector was used on this image query?")
result_type: ResultTypeEnum = Field(..., description="What type of result are we returning?")
result: Optional[
Union[
BinaryClassificationResult,
CountingResult,
MultiClassificationResult,
TextRecognitionResult,
BoundingBoxResult,
]
] = Field(...)
patience_time: float = Field(..., description="How long to wait for a confident response.")
confidence_threshold: float = Field(
..., description="Min confidence needed to accept the response of the image query."
)
rois: Optional[List[ROI]] = Field(
..., description="An array of regions of interest (bounding boxes) collected on image"
)
text: Optional[str] = Field(..., description="A text field on image query.")
done_processing: bool = Field(
False,
description="EDGE ONLY - Whether the image query has completed escalating and will receive no new results.",
)
class LabelValue(BaseModel):
confidence: Optional[float] = Field(...)
class_name: Optional[str] = Field(
..., description="Return a human-readable class name for this label (e.g. YES/NO)"
)
rois: Optional[List[ROI]] = None
annotations_requested: List[str]
created_at: datetime
detector_id: Optional[int] = Field(...)
source: str
text: Optional[str] = Field(..., description="Text annotations")
class LabelValueRequest(BaseModel):
label: Optional[str] = Field(...)
image_query_id: constr(min_length=1)
rois: Optional[List[ROIRequest]] = None
class PaginatedDetectorList(BaseModel):
count: int = Field(..., examples=[123])
next: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=4"])
previous: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=2"])
results: List[Detector]
class PaginatedImageQueryList(BaseModel):
count: int = Field(..., examples=[123])
next: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=4"])
previous: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=2"])
results: List[ImageQuery]
class PaginatedPrimingGroupList(BaseModel):
count: int = Field(..., examples=[123])
next: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=4"])
previous: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=2"])
results: List[PrimingGroup]
class PatchedDetectorRequest(BaseModel):
"""
Groundlight Detectors provide answers to natural language questions about images.
Each detector can answer a single question, and multiple detectors can be strung together for
more complex logic. Detectors can be created through the create_detector method, or through the
create_[MODE]_detector methods for pro tier users
"""
name: Optional[constr(min_length=1, max_length=200)] = Field(
None, description="A short, descriptive name for the detector."
)
confidence_threshold: confloat(ge=0.0, le=1.0) = Field(
0.9,
description=(
"If the detector's prediction is below this confidence threshold, send the image query for human review."
),
)
patience_time: confloat(ge=0.0, le=3600.0) = Field(
30.0, description="How long Groundlight will attempt to generate a confident prediction"
)
status: Optional[Union[StatusEnum, BlankEnum]] = None
escalation_type: Optional[constr(min_length=1)] = None
class Rule(BaseModel):
id: int
detector_id: str
detector_name: str
name: constr(max_length=44)
enabled: bool = True
snooze_time_enabled: bool = False
snooze_time_value: conint(ge=0) = 0
snooze_time_unit: SnoozeTimeUnitEnum = "DAYS"
human_review_required: bool = False
condition: Condition
action: Optional[Union[Action, ActionList]] = None
webhook_action: Optional[List[WebhookAction]] = None
class RuleRequest(BaseModel):
name: constr(min_length=1, max_length=44)
enabled: bool = True
snooze_time_enabled: bool = False
snooze_time_value: conint(ge=0) = 0
snooze_time_unit: SnoozeTimeUnitEnum = "DAYS"
human_review_required: bool = False
condition: ConditionRequest
action: Optional[Union[Action, ActionList]] = None
webhook_action: Optional[List[WebhookActionRequest]] = None
class VlmVerification(BaseModel):
"""
Response shape for POST /v1/vlm-verifications.
"""
id: str
type: str
created_at: datetime
query: str
model_id: str
result: VlmVerificationResult
cost: VlmVerificationCost
class PaginatedRuleList(BaseModel):
count: int = Field(..., examples=[123])
next: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=4"])
previous: Optional[AnyUrl] = Field(None, examples=["http://api.example.org/accounts/?page=2"])
results: List[Rule]