scorable 1.6.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scorable might be problematic. Click here for more details.
- root/__about__.py +4 -0
- root/__init__.py +17 -0
- root/client.py +207 -0
- root/datasets.py +231 -0
- root/execution_logs.py +162 -0
- root/generated/__init__.py +0 -0
- root/generated/openapi_aclient/__init__.py +1 -0
- root/generated/openapi_aclient/api/__init__.py +1 -0
- root/generated/openapi_aclient/api/datasets_api.py +1274 -0
- root/generated/openapi_aclient/api/evaluators_api.py +3641 -0
- root/generated/openapi_aclient/api/execution_logs_api.py +751 -0
- root/generated/openapi_aclient/api/judges_api.py +3794 -0
- root/generated/openapi_aclient/api/models_api.py +1473 -0
- root/generated/openapi_aclient/api/objectives_api.py +1767 -0
- root/generated/openapi_aclient/api_client.py +662 -0
- root/generated/openapi_aclient/api_response.py +22 -0
- root/generated/openapi_aclient/configuration.py +470 -0
- root/generated/openapi_aclient/exceptions.py +197 -0
- root/generated/openapi_aclient/models/__init__.py +122 -0
- root/generated/openapi_aclient/models/data_set_create.py +118 -0
- root/generated/openapi_aclient/models/data_set_create_request.py +105 -0
- root/generated/openapi_aclient/models/data_set_list.py +129 -0
- root/generated/openapi_aclient/models/data_set_type.py +36 -0
- root/generated/openapi_aclient/models/dataset_range_request.py +93 -0
- root/generated/openapi_aclient/models/evaluator.py +273 -0
- root/generated/openapi_aclient/models/evaluator_calibration_output.py +101 -0
- root/generated/openapi_aclient/models/evaluator_calibration_result.py +134 -0
- root/generated/openapi_aclient/models/evaluator_demonstrations.py +107 -0
- root/generated/openapi_aclient/models/evaluator_demonstrations_request.py +107 -0
- root/generated/openapi_aclient/models/evaluator_execution_function_parameter_property_request.py +86 -0
- root/generated/openapi_aclient/models/evaluator_execution_function_parameter_request.py +109 -0
- root/generated/openapi_aclient/models/evaluator_execution_function_parameter_type_enum.py +35 -0
- root/generated/openapi_aclient/models/evaluator_execution_function_request.py +99 -0
- root/generated/openapi_aclient/models/evaluator_execution_functions_request.py +98 -0
- root/generated/openapi_aclient/models/evaluator_execution_functions_type_enum.py +35 -0
- root/generated/openapi_aclient/models/evaluator_execution_request.py +134 -0
- root/generated/openapi_aclient/models/evaluator_execution_result.py +114 -0
- root/generated/openapi_aclient/models/evaluator_inputs_value.py +100 -0
- root/generated/openapi_aclient/models/evaluator_inputs_value_items.py +89 -0
- root/generated/openapi_aclient/models/evaluator_list_output.py +198 -0
- root/generated/openapi_aclient/models/evaluator_reference.py +90 -0
- root/generated/openapi_aclient/models/evaluator_reference_request.py +90 -0
- root/generated/openapi_aclient/models/evaluator_request.py +194 -0
- root/generated/openapi_aclient/models/evaluator_result.py +110 -0
- root/generated/openapi_aclient/models/execution_log_details.py +291 -0
- root/generated/openapi_aclient/models/execution_log_details_evaluation_context.py +83 -0
- root/generated/openapi_aclient/models/execution_log_details_evaluator_latencies_inner.py +83 -0
- root/generated/openapi_aclient/models/execution_log_list.py +217 -0
- root/generated/openapi_aclient/models/execution_log_list_evaluation_context.py +83 -0
- root/generated/openapi_aclient/models/generation_model_params_request.py +93 -0
- root/generated/openapi_aclient/models/id.py +87 -0
- root/generated/openapi_aclient/models/input_variable.py +121 -0
- root/generated/openapi_aclient/models/input_variable_request.py +82 -0
- root/generated/openapi_aclient/models/judge.py +178 -0
- root/generated/openapi_aclient/models/judge_execution_request.py +114 -0
- root/generated/openapi_aclient/models/judge_execution_response.py +97 -0
- root/generated/openapi_aclient/models/judge_files_inner.py +84 -0
- root/generated/openapi_aclient/models/judge_generator_request.py +142 -0
- root/generated/openapi_aclient/models/judge_generator_response.py +88 -0
- root/generated/openapi_aclient/models/judge_invite_request.py +87 -0
- root/generated/openapi_aclient/models/judge_list.py +156 -0
- root/generated/openapi_aclient/models/judge_rectifier_request_request.py +114 -0
- root/generated/openapi_aclient/models/judge_rectifier_response.py +121 -0
- root/generated/openapi_aclient/models/judge_request.py +108 -0
- root/generated/openapi_aclient/models/model.py +126 -0
- root/generated/openapi_aclient/models/model_list.py +115 -0
- root/generated/openapi_aclient/models/model_params.py +89 -0
- root/generated/openapi_aclient/models/model_params_request.py +89 -0
- root/generated/openapi_aclient/models/model_request.py +118 -0
- root/generated/openapi_aclient/models/nested_evaluator.py +110 -0
- root/generated/openapi_aclient/models/nested_evaluator_objective.py +87 -0
- root/generated/openapi_aclient/models/nested_evaluator_request.py +92 -0
- root/generated/openapi_aclient/models/nested_objective_evaluator.py +105 -0
- root/generated/openapi_aclient/models/nested_objective_evaluator_request.py +92 -0
- root/generated/openapi_aclient/models/nested_objective_list.py +111 -0
- root/generated/openapi_aclient/models/nested_user_details.py +88 -0
- root/generated/openapi_aclient/models/nested_user_details_request.py +82 -0
- root/generated/openapi_aclient/models/nested_vector_objective.py +88 -0
- root/generated/openapi_aclient/models/nested_vector_objective_request.py +82 -0
- root/generated/openapi_aclient/models/objective.py +157 -0
- root/generated/openapi_aclient/models/objective_list.py +128 -0
- root/generated/openapi_aclient/models/objective_request.py +113 -0
- root/generated/openapi_aclient/models/objective_validator.py +100 -0
- root/generated/openapi_aclient/models/objective_validator_request.py +90 -0
- root/generated/openapi_aclient/models/paginated_data_set_list_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_evaluator_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_evaluator_list_output_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_execution_log_list_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_judge_list_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_model_list_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_objective_list.py +111 -0
- root/generated/openapi_aclient/models/paginated_objective_list_list.py +111 -0
- root/generated/openapi_aclient/models/patched_evaluator_request.py +194 -0
- root/generated/openapi_aclient/models/patched_judge_request.py +110 -0
- root/generated/openapi_aclient/models/patched_model_request.py +118 -0
- root/generated/openapi_aclient/models/patched_objective_request.py +113 -0
- root/generated/openapi_aclient/models/provider.py +99 -0
- root/generated/openapi_aclient/models/reference_variable.py +123 -0
- root/generated/openapi_aclient/models/reference_variable_request.py +83 -0
- root/generated/openapi_aclient/models/skill_execution_validator_result.py +130 -0
- root/generated/openapi_aclient/models/skill_test_data_request.py +107 -0
- root/generated/openapi_aclient/models/skill_test_data_request_dataset_range.py +93 -0
- root/generated/openapi_aclient/models/skill_test_input_request.py +171 -0
- root/generated/openapi_aclient/models/skill_type_enum.py +36 -0
- root/generated/openapi_aclient/models/status_change.py +84 -0
- root/generated/openapi_aclient/models/status_change_request.py +84 -0
- root/generated/openapi_aclient/models/status_change_status_enum.py +36 -0
- root/generated/openapi_aclient/models/status_enum.py +38 -0
- root/generated/openapi_aclient/models/validation_result_status.py +36 -0
- root/generated/openapi_aclient/models/visibility_enum.py +38 -0
- root/generated/openapi_aclient/rest.py +166 -0
- root/generated/openapi_aclient_README.md +239 -0
- root/generated/openapi_client/__init__.py +1 -0
- root/generated/openapi_client/api/__init__.py +1 -0
- root/generated/openapi_client/api/datasets_api.py +1274 -0
- root/generated/openapi_client/api/evaluators_api.py +3641 -0
- root/generated/openapi_client/api/execution_logs_api.py +751 -0
- root/generated/openapi_client/api/judges_api.py +3794 -0
- root/generated/openapi_client/api/models_api.py +1473 -0
- root/generated/openapi_client/api/objectives_api.py +1767 -0
- root/generated/openapi_client/api_client.py +659 -0
- root/generated/openapi_client/api_response.py +22 -0
- root/generated/openapi_client/configuration.py +474 -0
- root/generated/openapi_client/exceptions.py +197 -0
- root/generated/openapi_client/models/__init__.py +120 -0
- root/generated/openapi_client/models/data_set_create.py +118 -0
- root/generated/openapi_client/models/data_set_create_request.py +105 -0
- root/generated/openapi_client/models/data_set_list.py +129 -0
- root/generated/openapi_client/models/data_set_type.py +36 -0
- root/generated/openapi_client/models/dataset_range_request.py +93 -0
- root/generated/openapi_client/models/evaluator.py +273 -0
- root/generated/openapi_client/models/evaluator_calibration_output.py +101 -0
- root/generated/openapi_client/models/evaluator_calibration_result.py +134 -0
- root/generated/openapi_client/models/evaluator_demonstrations.py +107 -0
- root/generated/openapi_client/models/evaluator_demonstrations_request.py +107 -0
- root/generated/openapi_client/models/evaluator_execution_function_parameter_property_request.py +86 -0
- root/generated/openapi_client/models/evaluator_execution_function_parameter_request.py +109 -0
- root/generated/openapi_client/models/evaluator_execution_function_parameter_type_enum.py +35 -0
- root/generated/openapi_client/models/evaluator_execution_function_request.py +99 -0
- root/generated/openapi_client/models/evaluator_execution_functions_request.py +98 -0
- root/generated/openapi_client/models/evaluator_execution_functions_type_enum.py +35 -0
- root/generated/openapi_client/models/evaluator_execution_request.py +134 -0
- root/generated/openapi_client/models/evaluator_execution_result.py +114 -0
- root/generated/openapi_client/models/evaluator_inputs_value.py +100 -0
- root/generated/openapi_client/models/evaluator_inputs_value_items.py +89 -0
- root/generated/openapi_client/models/evaluator_list_output.py +198 -0
- root/generated/openapi_client/models/evaluator_reference.py +90 -0
- root/generated/openapi_client/models/evaluator_reference_request.py +90 -0
- root/generated/openapi_client/models/evaluator_request.py +194 -0
- root/generated/openapi_client/models/evaluator_result.py +110 -0
- root/generated/openapi_client/models/execution_log_details.py +291 -0
- root/generated/openapi_client/models/execution_log_details_evaluation_context.py +83 -0
- root/generated/openapi_client/models/execution_log_details_evaluator_latencies_inner.py +83 -0
- root/generated/openapi_client/models/execution_log_list.py +215 -0
- root/generated/openapi_client/models/execution_log_list_evaluation_context.py +83 -0
- root/generated/openapi_client/models/generation_model_params_request.py +93 -0
- root/generated/openapi_client/models/id.py +87 -0
- root/generated/openapi_client/models/input_variable.py +121 -0
- root/generated/openapi_client/models/input_variable_request.py +82 -0
- root/generated/openapi_client/models/judge.py +178 -0
- root/generated/openapi_client/models/judge_execution_request.py +114 -0
- root/generated/openapi_client/models/judge_execution_response.py +97 -0
- root/generated/openapi_client/models/judge_files_inner.py +84 -0
- root/generated/openapi_client/models/judge_generator_request.py +142 -0
- root/generated/openapi_client/models/judge_generator_response.py +88 -0
- root/generated/openapi_client/models/judge_invite_request.py +87 -0
- root/generated/openapi_client/models/judge_list.py +156 -0
- root/generated/openapi_client/models/judge_rectifier_request_request.py +114 -0
- root/generated/openapi_client/models/judge_rectifier_response.py +121 -0
- root/generated/openapi_client/models/judge_request.py +108 -0
- root/generated/openapi_client/models/model.py +126 -0
- root/generated/openapi_client/models/model_list.py +115 -0
- root/generated/openapi_client/models/model_params.py +89 -0
- root/generated/openapi_client/models/model_params_request.py +89 -0
- root/generated/openapi_client/models/model_request.py +118 -0
- root/generated/openapi_client/models/nested_evaluator.py +110 -0
- root/generated/openapi_client/models/nested_evaluator_objective.py +87 -0
- root/generated/openapi_client/models/nested_evaluator_request.py +92 -0
- root/generated/openapi_client/models/nested_objective_evaluator.py +105 -0
- root/generated/openapi_client/models/nested_objective_evaluator_request.py +92 -0
- root/generated/openapi_client/models/nested_objective_list.py +111 -0
- root/generated/openapi_client/models/nested_user_details.py +88 -0
- root/generated/openapi_client/models/nested_user_details_request.py +82 -0
- root/generated/openapi_client/models/nested_vector_objective.py +88 -0
- root/generated/openapi_client/models/nested_vector_objective_request.py +82 -0
- root/generated/openapi_client/models/objective.py +157 -0
- root/generated/openapi_client/models/objective_list.py +128 -0
- root/generated/openapi_client/models/objective_request.py +113 -0
- root/generated/openapi_client/models/objective_validator.py +100 -0
- root/generated/openapi_client/models/objective_validator_request.py +90 -0
- root/generated/openapi_client/models/paginated_data_set_list_list.py +111 -0
- root/generated/openapi_client/models/paginated_evaluator_list.py +111 -0
- root/generated/openapi_client/models/paginated_evaluator_list_output_list.py +111 -0
- root/generated/openapi_client/models/paginated_execution_log_list_list.py +111 -0
- root/generated/openapi_client/models/paginated_judge_list_list.py +111 -0
- root/generated/openapi_client/models/paginated_model_list_list.py +111 -0
- root/generated/openapi_client/models/paginated_objective_list.py +111 -0
- root/generated/openapi_client/models/paginated_objective_list_list.py +111 -0
- root/generated/openapi_client/models/patched_evaluator_request.py +194 -0
- root/generated/openapi_client/models/patched_judge_request.py +110 -0
- root/generated/openapi_client/models/patched_model_request.py +118 -0
- root/generated/openapi_client/models/patched_objective_request.py +113 -0
- root/generated/openapi_client/models/provider.py +99 -0
- root/generated/openapi_client/models/reference_variable.py +123 -0
- root/generated/openapi_client/models/reference_variable_request.py +83 -0
- root/generated/openapi_client/models/skill_execution_validator_result.py +130 -0
- root/generated/openapi_client/models/skill_test_data_request.py +107 -0
- root/generated/openapi_client/models/skill_test_data_request_dataset_range.py +93 -0
- root/generated/openapi_client/models/skill_test_input_request.py +171 -0
- root/generated/openapi_client/models/skill_type_enum.py +36 -0
- root/generated/openapi_client/models/status_change.py +84 -0
- root/generated/openapi_client/models/status_change_request.py +84 -0
- root/generated/openapi_client/models/status_change_status_enum.py +36 -0
- root/generated/openapi_client/models/status_enum.py +38 -0
- root/generated/openapi_client/models/validation_result_status.py +36 -0
- root/generated/openapi_client/models/visibility_enum.py +38 -0
- root/generated/openapi_client/rest.py +203 -0
- root/generated/openapi_client_README.md +238 -0
- root/judges.py +681 -0
- root/models.py +197 -0
- root/objectives.py +343 -0
- root/py.typed +0 -0
- root/skills.py +1707 -0
- root/utils.py +90 -0
- scorable-1.6.4.dist-info/METADATA +395 -0
- scorable-1.6.4.dist-info/RECORD +228 -0
- scorable-1.6.4.dist-info/WHEEL +4 -0
- scorable-1.6.4.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool
|
|
22
|
+
from typing_extensions import Annotated, Self
|
|
23
|
+
|
|
24
|
+
from root.generated.openapi_aclient.models.input_variable_request import InputVariableRequest
|
|
25
|
+
from root.generated.openapi_aclient.models.objective_request import ObjectiveRequest
|
|
26
|
+
from root.generated.openapi_aclient.models.reference_variable_request import ReferenceVariableRequest
|
|
27
|
+
from root.generated.openapi_aclient.models.skill_test_data_request_dataset_range import SkillTestDataRequestDatasetRange
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SkillTestInputRequest(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
SkillTestInputRequest
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
|
|
35
|
+
test_data: Optional[List[List[Annotated[str, Field(min_length=1, strict=True)]]]] = None
|
|
36
|
+
test_dataset_id: Optional[Annotated[str, Field(min_length=1, strict=True)]] = None
|
|
37
|
+
dataset_range: Optional[SkillTestDataRequestDatasetRange] = None
|
|
38
|
+
prompt: Annotated[str, Field(min_length=1, strict=True)]
|
|
39
|
+
reference_variables: Optional[List[ReferenceVariableRequest]] = None
|
|
40
|
+
input_variables: Optional[List[InputVariableRequest]] = None
|
|
41
|
+
models: Optional[List[Annotated[str, Field(min_length=1, strict=True)]]] = None
|
|
42
|
+
name: Optional[Annotated[str, Field(min_length=1, strict=True)]] = None
|
|
43
|
+
pii_filter: Optional[StrictBool] = False
|
|
44
|
+
objective: Optional[ObjectiveRequest] = None
|
|
45
|
+
is_evaluator: Optional[StrictBool] = False
|
|
46
|
+
__properties: ClassVar[List[str]] = [
|
|
47
|
+
"test_data",
|
|
48
|
+
"test_dataset_id",
|
|
49
|
+
"dataset_range",
|
|
50
|
+
"prompt",
|
|
51
|
+
"reference_variables",
|
|
52
|
+
"input_variables",
|
|
53
|
+
"models",
|
|
54
|
+
"name",
|
|
55
|
+
"pii_filter",
|
|
56
|
+
"objective",
|
|
57
|
+
"is_evaluator",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
model_config = ConfigDict(
|
|
61
|
+
populate_by_name=True,
|
|
62
|
+
validate_assignment=True,
|
|
63
|
+
protected_namespaces=(),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def to_str(self) -> str:
|
|
67
|
+
"""Returns the string representation of the model using alias"""
|
|
68
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
69
|
+
|
|
70
|
+
def to_json(self) -> str:
|
|
71
|
+
"""Returns the JSON representation of the model using alias"""
|
|
72
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
73
|
+
return json.dumps(self.to_dict())
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
77
|
+
"""Create an instance of SkillTestInputRequest from a JSON string"""
|
|
78
|
+
return cls.from_dict(json.loads(json_str))
|
|
79
|
+
|
|
80
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
81
|
+
"""Return the dictionary representation of the model using alias.
|
|
82
|
+
|
|
83
|
+
This has the following differences from calling pydantic's
|
|
84
|
+
`self.model_dump(by_alias=True)`:
|
|
85
|
+
|
|
86
|
+
* `None` is only added to the output dict for nullable fields that
|
|
87
|
+
were set at model initialization. Other fields with value `None`
|
|
88
|
+
are ignored.
|
|
89
|
+
"""
|
|
90
|
+
excluded_fields: Set[str] = set([])
|
|
91
|
+
|
|
92
|
+
_dict = self.model_dump(
|
|
93
|
+
by_alias=True,
|
|
94
|
+
exclude=excluded_fields,
|
|
95
|
+
exclude_none=True,
|
|
96
|
+
)
|
|
97
|
+
# override the default output from pydantic by calling `to_dict()` of dataset_range
|
|
98
|
+
if self.dataset_range:
|
|
99
|
+
_dict["dataset_range"] = self.dataset_range.to_dict()
|
|
100
|
+
# override the default output from pydantic by calling `to_dict()` of each item in reference_variables (list)
|
|
101
|
+
_items = []
|
|
102
|
+
if self.reference_variables:
|
|
103
|
+
for _item in self.reference_variables:
|
|
104
|
+
if _item:
|
|
105
|
+
_items.append(_item.to_dict())
|
|
106
|
+
_dict["reference_variables"] = _items
|
|
107
|
+
# override the default output from pydantic by calling `to_dict()` of each item in input_variables (list)
|
|
108
|
+
_items = []
|
|
109
|
+
if self.input_variables:
|
|
110
|
+
for _item in self.input_variables:
|
|
111
|
+
if _item:
|
|
112
|
+
_items.append(_item.to_dict())
|
|
113
|
+
_dict["input_variables"] = _items
|
|
114
|
+
# override the default output from pydantic by calling `to_dict()` of objective
|
|
115
|
+
if self.objective:
|
|
116
|
+
_dict["objective"] = self.objective.to_dict()
|
|
117
|
+
# set to None if test_data (nullable) is None
|
|
118
|
+
# and model_fields_set contains the field
|
|
119
|
+
if self.test_data is None and "test_data" in self.model_fields_set:
|
|
120
|
+
_dict["test_data"] = None
|
|
121
|
+
|
|
122
|
+
# set to None if dataset_range (nullable) is None
|
|
123
|
+
# and model_fields_set contains the field
|
|
124
|
+
if self.dataset_range is None and "dataset_range" in self.model_fields_set:
|
|
125
|
+
_dict["dataset_range"] = None
|
|
126
|
+
|
|
127
|
+
# set to None if name (nullable) is None
|
|
128
|
+
# and model_fields_set contains the field
|
|
129
|
+
if self.name is None and "name" in self.model_fields_set:
|
|
130
|
+
_dict["name"] = None
|
|
131
|
+
|
|
132
|
+
# set to None if objective (nullable) is None
|
|
133
|
+
# and model_fields_set contains the field
|
|
134
|
+
if self.objective is None and "objective" in self.model_fields_set:
|
|
135
|
+
_dict["objective"] = None
|
|
136
|
+
|
|
137
|
+
return _dict
|
|
138
|
+
|
|
139
|
+
@classmethod
|
|
140
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
141
|
+
"""Create an instance of SkillTestInputRequest from a dict"""
|
|
142
|
+
if obj is None:
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
if not isinstance(obj, dict):
|
|
146
|
+
return cls.model_validate(obj)
|
|
147
|
+
|
|
148
|
+
_obj = cls.model_validate(
|
|
149
|
+
{
|
|
150
|
+
"test_data": obj.get("test_data"),
|
|
151
|
+
"test_dataset_id": obj.get("test_dataset_id"),
|
|
152
|
+
"dataset_range": SkillTestDataRequestDatasetRange.from_dict(obj["dataset_range"])
|
|
153
|
+
if obj.get("dataset_range") is not None
|
|
154
|
+
else None,
|
|
155
|
+
"prompt": obj.get("prompt"),
|
|
156
|
+
"reference_variables": [
|
|
157
|
+
ReferenceVariableRequest.from_dict(_item) for _item in obj["reference_variables"]
|
|
158
|
+
]
|
|
159
|
+
if obj.get("reference_variables") is not None
|
|
160
|
+
else None,
|
|
161
|
+
"input_variables": [InputVariableRequest.from_dict(_item) for _item in obj["input_variables"]]
|
|
162
|
+
if obj.get("input_variables") is not None
|
|
163
|
+
else None,
|
|
164
|
+
"models": obj.get("models"),
|
|
165
|
+
"name": obj.get("name"),
|
|
166
|
+
"pii_filter": obj.get("pii_filter") if obj.get("pii_filter") is not None else False,
|
|
167
|
+
"objective": ObjectiveRequest.from_dict(obj["objective"]) if obj.get("objective") is not None else None,
|
|
168
|
+
"is_evaluator": obj.get("is_evaluator") if obj.get("is_evaluator") is not None else False,
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
return _obj
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SkillTypeEnum(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
* `managed` - managed * `native` - native
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
MANAGED = "managed"
|
|
31
|
+
NATIVE = "native"
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json(cls, json_str: str) -> Self:
|
|
35
|
+
"""Create an instance of SkillTypeEnum from a JSON string"""
|
|
36
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
from root.generated.openapi_aclient.models.status_change_status_enum import StatusChangeStatusEnum
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class StatusChange(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
StatusChange
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
|
|
32
|
+
status: StatusChangeStatusEnum
|
|
33
|
+
__properties: ClassVar[List[str]] = ["status"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
populate_by_name=True,
|
|
37
|
+
validate_assignment=True,
|
|
38
|
+
protected_namespaces=(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of StatusChange from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([])
|
|
66
|
+
|
|
67
|
+
_dict = self.model_dump(
|
|
68
|
+
by_alias=True,
|
|
69
|
+
exclude=excluded_fields,
|
|
70
|
+
exclude_none=True,
|
|
71
|
+
)
|
|
72
|
+
return _dict
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
76
|
+
"""Create an instance of StatusChange from a dict"""
|
|
77
|
+
if obj is None:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
if not isinstance(obj, dict):
|
|
81
|
+
return cls.model_validate(obj)
|
|
82
|
+
|
|
83
|
+
_obj = cls.model_validate({"status": obj.get("status")})
|
|
84
|
+
return _obj
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict
|
|
22
|
+
from typing_extensions import Self
|
|
23
|
+
|
|
24
|
+
from root.generated.openapi_aclient.models.status_change_status_enum import StatusChangeStatusEnum
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class StatusChangeRequest(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
StatusChangeRequest
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
|
|
32
|
+
status: StatusChangeStatusEnum
|
|
33
|
+
__properties: ClassVar[List[str]] = ["status"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
populate_by_name=True,
|
|
37
|
+
validate_assignment=True,
|
|
38
|
+
protected_namespaces=(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of StatusChangeRequest from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([])
|
|
66
|
+
|
|
67
|
+
_dict = self.model_dump(
|
|
68
|
+
by_alias=True,
|
|
69
|
+
exclude=excluded_fields,
|
|
70
|
+
exclude_none=True,
|
|
71
|
+
)
|
|
72
|
+
return _dict
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
76
|
+
"""Create an instance of StatusChangeRequest from a dict"""
|
|
77
|
+
if obj is None:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
if not isinstance(obj, dict):
|
|
81
|
+
return cls.model_validate(obj)
|
|
82
|
+
|
|
83
|
+
_obj = cls.model_validate({"status": obj.get("status")})
|
|
84
|
+
return _obj
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class StatusChangeStatusEnum(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
* `unlisted` - unlisted * `listed` - listed
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
UNLISTED = "unlisted"
|
|
31
|
+
LISTED = "listed"
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json(cls, json_str: str) -> Self:
|
|
35
|
+
"""Create an instance of StatusChangeStatusEnum from a JSON string"""
|
|
36
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class StatusEnum(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
* `unlisted` - unlisted * `listed` - listed * `public` - public * `public_unlisted` - public_unlisted
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
UNLISTED = "unlisted"
|
|
31
|
+
LISTED = "listed"
|
|
32
|
+
PUBLIC = "public"
|
|
33
|
+
PUBLIC_UNLISTED = "public_unlisted"
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def from_json(cls, json_str: str) -> Self:
|
|
37
|
+
"""Create an instance of StatusEnum from a JSON string"""
|
|
38
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ValidationResultStatus(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
* `pending` - Pending * `finished` - Finished
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
PENDING = "pending"
|
|
31
|
+
FINISHED = "finished"
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json(cls, json_str: str) -> Self:
|
|
35
|
+
"""Create an instance of ValidationResultStatus from a JSON string"""
|
|
36
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class VisibilityEnum(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
* `global` - global * `public` - public * `listed` - listed * `unlisted` - unlisted
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
GLOBAL = "global"
|
|
31
|
+
PUBLIC = "public"
|
|
32
|
+
LISTED = "listed"
|
|
33
|
+
UNLISTED = "unlisted"
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def from_json(cls, json_str: str) -> Self:
|
|
37
|
+
"""Create an instance of VisibilityEnum from a JSON string"""
|
|
38
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Root Signals API
|
|
5
|
+
|
|
6
|
+
Root Signals JSON API provides a way to access Root Signals using provisioned API token
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0 (latest)
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
import io
|
|
15
|
+
import json
|
|
16
|
+
import re
|
|
17
|
+
import ssl
|
|
18
|
+
from typing import Optional, Union
|
|
19
|
+
|
|
20
|
+
import aiohttp
|
|
21
|
+
import aiohttp_retry
|
|
22
|
+
|
|
23
|
+
from root.generated.openapi_aclient.exceptions import ApiException, ApiValueError
|
|
24
|
+
|
|
25
|
+
RESTResponseType = aiohttp.ClientResponse
|
|
26
|
+
|
|
27
|
+
ALLOW_RETRY_METHODS = frozenset({"DELETE", "GET", "HEAD", "OPTIONS", "PUT", "TRACE"})
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class RESTResponse(io.IOBase):
|
|
31
|
+
def __init__(self, resp) -> None:
|
|
32
|
+
self.response = resp
|
|
33
|
+
self.status = resp.status
|
|
34
|
+
self.reason = resp.reason
|
|
35
|
+
self.data = None
|
|
36
|
+
|
|
37
|
+
async def read(self):
|
|
38
|
+
if self.data is None:
|
|
39
|
+
self.data = await self.response.read()
|
|
40
|
+
return self.data
|
|
41
|
+
|
|
42
|
+
def getheaders(self):
|
|
43
|
+
"""Returns a CIMultiDictProxy of the response headers."""
|
|
44
|
+
return self.response.headers
|
|
45
|
+
|
|
46
|
+
def getheader(self, name, default=None):
|
|
47
|
+
"""Returns a given response header."""
|
|
48
|
+
return self.response.headers.get(name, default)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class RESTClientObject:
|
|
52
|
+
def __init__(self, configuration) -> None:
|
|
53
|
+
# maxsize is number of requests to host that are allowed in parallel
|
|
54
|
+
maxsize = configuration.connection_pool_maxsize
|
|
55
|
+
|
|
56
|
+
ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert)
|
|
57
|
+
if configuration.cert_file:
|
|
58
|
+
ssl_context.load_cert_chain(configuration.cert_file, keyfile=configuration.key_file)
|
|
59
|
+
|
|
60
|
+
if not configuration.verify_ssl:
|
|
61
|
+
ssl_context.check_hostname = False
|
|
62
|
+
ssl_context.verify_mode = ssl.CERT_NONE
|
|
63
|
+
|
|
64
|
+
connector = aiohttp.TCPConnector(limit=maxsize, ssl=ssl_context)
|
|
65
|
+
|
|
66
|
+
self.proxy = configuration.proxy
|
|
67
|
+
self.proxy_headers = configuration.proxy_headers
|
|
68
|
+
|
|
69
|
+
# https pool manager
|
|
70
|
+
self.pool_manager = aiohttp.ClientSession(connector=connector, trust_env=True)
|
|
71
|
+
|
|
72
|
+
retries = configuration.retries
|
|
73
|
+
self.retry_client: Optional[aiohttp_retry.RetryClient]
|
|
74
|
+
if retries is not None:
|
|
75
|
+
self.retry_client = aiohttp_retry.RetryClient(
|
|
76
|
+
client_session=self.pool_manager,
|
|
77
|
+
retry_options=aiohttp_retry.ExponentialRetry(
|
|
78
|
+
attempts=retries, factor=0.0, start_timeout=0.0, max_timeout=120.0
|
|
79
|
+
),
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
self.retry_client = None
|
|
83
|
+
|
|
84
|
+
async def close(self):
|
|
85
|
+
await self.pool_manager.close()
|
|
86
|
+
if self.retry_client is not None:
|
|
87
|
+
await self.retry_client.close()
|
|
88
|
+
|
|
89
|
+
async def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None):
|
|
90
|
+
"""Execute request
|
|
91
|
+
|
|
92
|
+
:param method: http request method
|
|
93
|
+
:param url: http request url
|
|
94
|
+
:param headers: http request headers
|
|
95
|
+
:param body: request json body, for `application/json`
|
|
96
|
+
:param post_params: request post parameters,
|
|
97
|
+
`application/x-www-form-urlencoded`
|
|
98
|
+
and `multipart/form-data`
|
|
99
|
+
:param _request_timeout: timeout setting for this request. If one
|
|
100
|
+
number provided, it will be total request
|
|
101
|
+
timeout. It can also be a pair (tuple) of
|
|
102
|
+
(connection, read) timeouts.
|
|
103
|
+
"""
|
|
104
|
+
method = method.upper()
|
|
105
|
+
assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]
|
|
106
|
+
|
|
107
|
+
if post_params and body:
|
|
108
|
+
raise ApiValueError("body parameter cannot be used with post_params parameter.")
|
|
109
|
+
|
|
110
|
+
post_params = post_params or {}
|
|
111
|
+
headers = headers or {}
|
|
112
|
+
# url already contains the URL query string
|
|
113
|
+
timeout = _request_timeout or 5 * 60
|
|
114
|
+
|
|
115
|
+
if "Content-Type" not in headers:
|
|
116
|
+
headers["Content-Type"] = "application/json"
|
|
117
|
+
|
|
118
|
+
args = {"method": method, "url": url, "timeout": timeout, "headers": headers}
|
|
119
|
+
|
|
120
|
+
if self.proxy:
|
|
121
|
+
args["proxy"] = self.proxy
|
|
122
|
+
if self.proxy_headers:
|
|
123
|
+
args["proxy_headers"] = self.proxy_headers
|
|
124
|
+
|
|
125
|
+
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
|
126
|
+
if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
|
|
127
|
+
if re.search("json", headers["Content-Type"], re.IGNORECASE):
|
|
128
|
+
if body is not None:
|
|
129
|
+
body = json.dumps(body)
|
|
130
|
+
args["data"] = body
|
|
131
|
+
elif headers["Content-Type"] == "application/x-www-form-urlencoded":
|
|
132
|
+
args["data"] = aiohttp.FormData(post_params)
|
|
133
|
+
elif headers["Content-Type"] == "multipart/form-data":
|
|
134
|
+
# must del headers['Content-Type'], or the correct
|
|
135
|
+
# Content-Type which generated by aiohttp
|
|
136
|
+
del headers["Content-Type"]
|
|
137
|
+
data = aiohttp.FormData()
|
|
138
|
+
for param in post_params:
|
|
139
|
+
k, v = param
|
|
140
|
+
if isinstance(v, tuple) and len(v) == 3:
|
|
141
|
+
data.add_field(k, value=v[1], filename=v[0], content_type=v[2])
|
|
142
|
+
else:
|
|
143
|
+
data.add_field(k, v)
|
|
144
|
+
args["data"] = data
|
|
145
|
+
|
|
146
|
+
# Pass a `bytes` parameter directly in the body to support
|
|
147
|
+
# other content types than Json when `body` argument is provided
|
|
148
|
+
# in serialized form
|
|
149
|
+
elif isinstance(body, bytes):
|
|
150
|
+
args["data"] = body
|
|
151
|
+
else:
|
|
152
|
+
# Cannot generate the request from given parameters
|
|
153
|
+
msg = """Cannot prepare a request message for provided
|
|
154
|
+
arguments. Please check that your arguments match
|
|
155
|
+
declared content type."""
|
|
156
|
+
raise ApiException(status=0, reason=msg)
|
|
157
|
+
|
|
158
|
+
pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient]
|
|
159
|
+
if self.retry_client is not None and method in ALLOW_RETRY_METHODS:
|
|
160
|
+
pool_manager = self.retry_client
|
|
161
|
+
else:
|
|
162
|
+
pool_manager = self.pool_manager
|
|
163
|
+
|
|
164
|
+
r = await pool_manager.request(**args)
|
|
165
|
+
|
|
166
|
+
return RESTResponse(r)
|