lightningrod-ai 0.1.6__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.
- lightningrod/__init__.py +66 -0
- lightningrod/_display.py +204 -0
- lightningrod/_errors.py +67 -0
- lightningrod/_generated/__init__.py +8 -0
- lightningrod/_generated/api/__init__.py +1 -0
- lightningrod/_generated/api/datasets/__init__.py +1 -0
- lightningrod/_generated/api/datasets/create_dataset_datasets_post.py +133 -0
- lightningrod/_generated/api/datasets/get_dataset_datasets_dataset_id_get.py +168 -0
- lightningrod/_generated/api/datasets/get_dataset_samples_datasets_dataset_id_samples_get.py +209 -0
- lightningrod/_generated/api/datasets/upload_samples_datasets_dataset_id_samples_post.py +190 -0
- lightningrod/_generated/api/file_sets/__init__.py +1 -0
- lightningrod/_generated/api/file_sets/add_file_to_set_filesets_file_set_id_files_post.py +190 -0
- lightningrod/_generated/api/file_sets/create_file_set_filesets_post.py +174 -0
- lightningrod/_generated/api/file_sets/get_file_set_filesets_file_set_id_get.py +168 -0
- lightningrod/_generated/api/file_sets/list_file_sets_filesets_get.py +173 -0
- lightningrod/_generated/api/file_sets/list_files_in_set_filesets_file_set_id_files_get.py +209 -0
- lightningrod/_generated/api/files/__init__.py +1 -0
- lightningrod/_generated/api/files/create_file_upload_files_post.py +174 -0
- lightningrod/_generated/api/open_ai_compatible/__init__.py +1 -0
- lightningrod/_generated/api/open_ai_compatible/chat_completions_openai_chat_completions_post.py +174 -0
- lightningrod/_generated/api/organizations/__init__.py +1 -0
- lightningrod/_generated/api/organizations/get_balance_organizations_balance_get.py +131 -0
- lightningrod/_generated/api/samples/__init__.py +1 -0
- lightningrod/_generated/api/samples/validate_sample_samples_validate_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/__init__.py +1 -0
- lightningrod/_generated/api/transform_jobs/cost_estimation_transform_jobs_cost_estimation_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/create_transform_job_transform_jobs_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/get_transform_job_metrics_transform_jobs_job_id_metrics_get.py +172 -0
- lightningrod/_generated/api/transform_jobs/get_transform_job_transform_jobs_job_id_get.py +168 -0
- lightningrod/_generated/client.py +268 -0
- lightningrod/_generated/errors.py +16 -0
- lightningrod/_generated/models/__init__.py +147 -0
- lightningrod/_generated/models/answer_type.py +129 -0
- lightningrod/_generated/models/answer_type_enum.py +11 -0
- lightningrod/_generated/models/balance_response.py +61 -0
- lightningrod/_generated/models/chat_completion_request.py +216 -0
- lightningrod/_generated/models/chat_completion_response.py +146 -0
- lightningrod/_generated/models/chat_message.py +69 -0
- lightningrod/_generated/models/choice.py +97 -0
- lightningrod/_generated/models/create_dataset_response.py +61 -0
- lightningrod/_generated/models/create_file_set_file_request.py +101 -0
- lightningrod/_generated/models/create_file_set_file_request_metadata_type_0.py +46 -0
- lightningrod/_generated/models/create_file_set_request.py +83 -0
- lightningrod/_generated/models/create_file_upload_request.py +91 -0
- lightningrod/_generated/models/create_file_upload_response.py +165 -0
- lightningrod/_generated/models/create_file_upload_response_metadata_type_0.py +46 -0
- lightningrod/_generated/models/create_transform_job_request.py +312 -0
- lightningrod/_generated/models/dataset_metadata.py +69 -0
- lightningrod/_generated/models/estimate_cost_request.py +243 -0
- lightningrod/_generated/models/estimate_cost_response.py +117 -0
- lightningrod/_generated/models/event_usage_summary.py +80 -0
- lightningrod/_generated/models/file_set.py +128 -0
- lightningrod/_generated/models/file_set_file.py +203 -0
- lightningrod/_generated/models/file_set_file_metadata_type_0.py +57 -0
- lightningrod/_generated/models/file_set_query_seed_generator.py +136 -0
- lightningrod/_generated/models/file_set_seed_generator.py +126 -0
- lightningrod/_generated/models/filter_criteria.py +83 -0
- lightningrod/_generated/models/forward_looking_question.py +130 -0
- lightningrod/_generated/models/forward_looking_question_generator.py +217 -0
- lightningrod/_generated/models/gdelt_seed_generator.py +103 -0
- lightningrod/_generated/models/http_validation_error.py +79 -0
- lightningrod/_generated/models/job_usage.py +185 -0
- lightningrod/_generated/models/job_usage_by_step_type_0.py +59 -0
- lightningrod/_generated/models/label.py +143 -0
- lightningrod/_generated/models/list_file_set_files_response.py +113 -0
- lightningrod/_generated/models/list_file_sets_response.py +75 -0
- lightningrod/_generated/models/llm_model_usage_summary.py +98 -0
- lightningrod/_generated/models/mock_transform_config.py +243 -0
- lightningrod/_generated/models/mock_transform_config_metadata_additions.py +46 -0
- lightningrod/_generated/models/model_config.py +316 -0
- lightningrod/_generated/models/model_source_type.py +16 -0
- lightningrod/_generated/models/news_context.py +82 -0
- lightningrod/_generated/models/news_context_generator.py +127 -0
- lightningrod/_generated/models/news_seed_generator.py +220 -0
- lightningrod/_generated/models/paginated_samples_response.py +113 -0
- lightningrod/_generated/models/pipeline_metrics_response.py +99 -0
- lightningrod/_generated/models/question.py +74 -0
- lightningrod/_generated/models/question_and_label_generator.py +217 -0
- lightningrod/_generated/models/question_generator.py +217 -0
- lightningrod/_generated/models/question_pipeline.py +417 -0
- lightningrod/_generated/models/question_renderer.py +123 -0
- lightningrod/_generated/models/rag_context.py +82 -0
- lightningrod/_generated/models/response_message.py +69 -0
- lightningrod/_generated/models/rollout.py +130 -0
- lightningrod/_generated/models/rollout_generator.py +139 -0
- lightningrod/_generated/models/rollout_parsed_output_type_0.py +46 -0
- lightningrod/_generated/models/sample.py +323 -0
- lightningrod/_generated/models/sample_meta.py +46 -0
- lightningrod/_generated/models/seed.py +135 -0
- lightningrod/_generated/models/step_cost_breakdown.py +109 -0
- lightningrod/_generated/models/transform_job.py +268 -0
- lightningrod/_generated/models/transform_job_status.py +11 -0
- lightningrod/_generated/models/transform_step_metrics_response.py +131 -0
- lightningrod/_generated/models/transform_type.py +25 -0
- lightningrod/_generated/models/upload_samples_request.py +75 -0
- lightningrod/_generated/models/upload_samples_response.py +69 -0
- lightningrod/_generated/models/usage.py +77 -0
- lightningrod/_generated/models/usage_summary.py +102 -0
- lightningrod/_generated/models/usage_summary_events.py +59 -0
- lightningrod/_generated/models/usage_summary_llm_by_model.py +59 -0
- lightningrod/_generated/models/validate_sample_response.py +69 -0
- lightningrod/_generated/models/validation_error.py +90 -0
- lightningrod/_generated/models/web_search_labeler.py +120 -0
- lightningrod/_generated/py.typed +1 -0
- lightningrod/_generated/types.py +54 -0
- lightningrod/client.py +48 -0
- lightningrod/datasets/__init__.py +4 -0
- lightningrod/datasets/client.py +174 -0
- lightningrod/datasets/dataset.py +255 -0
- lightningrod/files/__init__.py +0 -0
- lightningrod/files/client.py +58 -0
- lightningrod/filesets/__init__.py +0 -0
- lightningrod/filesets/client.py +106 -0
- lightningrod/organization/__init__.py +0 -0
- lightningrod/organization/client.py +17 -0
- lightningrod/py.typed +0 -0
- lightningrod/transforms/__init__.py +0 -0
- lightningrod/transforms/client.py +154 -0
- lightningrod_ai-0.1.6.dist-info/METADATA +122 -0
- lightningrod_ai-0.1.6.dist-info/RECORD +123 -0
- lightningrod_ai-0.1.6.dist-info/WHEEL +5 -0
- lightningrod_ai-0.1.6.dist-info/licenses/LICENSE +23 -0
- lightningrod_ai-0.1.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ..models.rollout_parsed_output_type_0 import RolloutParsedOutputType0
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="Rollout")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class Rollout:
|
|
20
|
+
"""A single model rollout/response.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
model_name (str):
|
|
24
|
+
content (str):
|
|
25
|
+
parsed_output (None | RolloutParsedOutputType0 | Unset):
|
|
26
|
+
reasoning (None | str | Unset):
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
model_name: str
|
|
30
|
+
content: str
|
|
31
|
+
parsed_output: None | RolloutParsedOutputType0 | Unset = UNSET
|
|
32
|
+
reasoning: None | str | Unset = UNSET
|
|
33
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
34
|
+
|
|
35
|
+
def to_dict(self) -> dict[str, Any]:
|
|
36
|
+
from ..models.rollout_parsed_output_type_0 import RolloutParsedOutputType0
|
|
37
|
+
|
|
38
|
+
model_name = self.model_name
|
|
39
|
+
|
|
40
|
+
content = self.content
|
|
41
|
+
|
|
42
|
+
parsed_output: dict[str, Any] | None | Unset
|
|
43
|
+
if isinstance(self.parsed_output, Unset):
|
|
44
|
+
parsed_output = UNSET
|
|
45
|
+
elif isinstance(self.parsed_output, RolloutParsedOutputType0):
|
|
46
|
+
parsed_output = self.parsed_output.to_dict()
|
|
47
|
+
else:
|
|
48
|
+
parsed_output = self.parsed_output
|
|
49
|
+
|
|
50
|
+
reasoning: None | str | Unset
|
|
51
|
+
if isinstance(self.reasoning, Unset):
|
|
52
|
+
reasoning = UNSET
|
|
53
|
+
else:
|
|
54
|
+
reasoning = self.reasoning
|
|
55
|
+
|
|
56
|
+
field_dict: dict[str, Any] = {}
|
|
57
|
+
field_dict.update(self.additional_properties)
|
|
58
|
+
field_dict.update(
|
|
59
|
+
{
|
|
60
|
+
"model_name": model_name,
|
|
61
|
+
"content": content,
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
if parsed_output is not UNSET:
|
|
65
|
+
field_dict["parsed_output"] = parsed_output
|
|
66
|
+
if reasoning is not UNSET:
|
|
67
|
+
field_dict["reasoning"] = reasoning
|
|
68
|
+
|
|
69
|
+
return field_dict
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
73
|
+
from ..models.rollout_parsed_output_type_0 import RolloutParsedOutputType0
|
|
74
|
+
|
|
75
|
+
d = dict(src_dict)
|
|
76
|
+
model_name = d.pop("model_name")
|
|
77
|
+
|
|
78
|
+
content = d.pop("content")
|
|
79
|
+
|
|
80
|
+
def _parse_parsed_output(data: object) -> None | RolloutParsedOutputType0 | Unset:
|
|
81
|
+
if data is None:
|
|
82
|
+
return data
|
|
83
|
+
if isinstance(data, Unset):
|
|
84
|
+
return data
|
|
85
|
+
try:
|
|
86
|
+
if not isinstance(data, dict):
|
|
87
|
+
raise TypeError()
|
|
88
|
+
parsed_output_type_0 = RolloutParsedOutputType0.from_dict(data)
|
|
89
|
+
|
|
90
|
+
return parsed_output_type_0
|
|
91
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
92
|
+
pass
|
|
93
|
+
return cast(None | RolloutParsedOutputType0 | Unset, data)
|
|
94
|
+
|
|
95
|
+
parsed_output = _parse_parsed_output(d.pop("parsed_output", UNSET))
|
|
96
|
+
|
|
97
|
+
def _parse_reasoning(data: object) -> None | str | Unset:
|
|
98
|
+
if data is None:
|
|
99
|
+
return data
|
|
100
|
+
if isinstance(data, Unset):
|
|
101
|
+
return data
|
|
102
|
+
return cast(None | str | Unset, data)
|
|
103
|
+
|
|
104
|
+
reasoning = _parse_reasoning(d.pop("reasoning", UNSET))
|
|
105
|
+
|
|
106
|
+
rollout = cls(
|
|
107
|
+
model_name=model_name,
|
|
108
|
+
content=content,
|
|
109
|
+
parsed_output=parsed_output,
|
|
110
|
+
reasoning=reasoning,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
rollout.additional_properties = d
|
|
114
|
+
return rollout
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def additional_keys(self) -> list[str]:
|
|
118
|
+
return list(self.additional_properties.keys())
|
|
119
|
+
|
|
120
|
+
def __getitem__(self, key: str) -> Any:
|
|
121
|
+
return self.additional_properties[key]
|
|
122
|
+
|
|
123
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
124
|
+
self.additional_properties[key] = value
|
|
125
|
+
|
|
126
|
+
def __delitem__(self, key: str) -> None:
|
|
127
|
+
del self.additional_properties[key]
|
|
128
|
+
|
|
129
|
+
def __contains__(self, key: str) -> bool:
|
|
130
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ..models.model_config import ModelConfig
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="RolloutGenerator")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class RolloutGenerator:
|
|
20
|
+
"""
|
|
21
|
+
Attributes:
|
|
22
|
+
models (list[ModelConfig]): Model names or ModelConfig objects
|
|
23
|
+
config_type (Literal['ROLLOUT_GENERATOR'] | Unset): Default: 'ROLLOUT_GENERATOR'.
|
|
24
|
+
prompt_template (None | str | Unset): Prompt template with {column} placeholders. If None, uses sample.prompt
|
|
25
|
+
input_columns (list[str] | Unset): Columns to substitute into template (from meta)
|
|
26
|
+
output_schema (Any | None | Unset): Pydantic model for structured output
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
models: list[ModelConfig]
|
|
30
|
+
config_type: Literal["ROLLOUT_GENERATOR"] | Unset = "ROLLOUT_GENERATOR"
|
|
31
|
+
prompt_template: None | str | Unset = UNSET
|
|
32
|
+
input_columns: list[str] | Unset = UNSET
|
|
33
|
+
output_schema: Any | None | Unset = UNSET
|
|
34
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
35
|
+
|
|
36
|
+
def to_dict(self) -> dict[str, Any]:
|
|
37
|
+
models = []
|
|
38
|
+
for models_item_data in self.models:
|
|
39
|
+
models_item = models_item_data.to_dict()
|
|
40
|
+
models.append(models_item)
|
|
41
|
+
|
|
42
|
+
config_type = self.config_type
|
|
43
|
+
|
|
44
|
+
prompt_template: None | str | Unset
|
|
45
|
+
if isinstance(self.prompt_template, Unset):
|
|
46
|
+
prompt_template = UNSET
|
|
47
|
+
else:
|
|
48
|
+
prompt_template = self.prompt_template
|
|
49
|
+
|
|
50
|
+
input_columns: list[str] | Unset = UNSET
|
|
51
|
+
if not isinstance(self.input_columns, Unset):
|
|
52
|
+
input_columns = self.input_columns
|
|
53
|
+
|
|
54
|
+
output_schema: Any | None | Unset
|
|
55
|
+
if isinstance(self.output_schema, Unset):
|
|
56
|
+
output_schema = UNSET
|
|
57
|
+
else:
|
|
58
|
+
output_schema = self.output_schema
|
|
59
|
+
|
|
60
|
+
field_dict: dict[str, Any] = {}
|
|
61
|
+
field_dict.update(self.additional_properties)
|
|
62
|
+
field_dict.update(
|
|
63
|
+
{
|
|
64
|
+
"models": models,
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
if config_type is not UNSET:
|
|
68
|
+
field_dict["config_type"] = config_type
|
|
69
|
+
if prompt_template is not UNSET:
|
|
70
|
+
field_dict["prompt_template"] = prompt_template
|
|
71
|
+
if input_columns is not UNSET:
|
|
72
|
+
field_dict["input_columns"] = input_columns
|
|
73
|
+
if output_schema is not UNSET:
|
|
74
|
+
field_dict["output_schema"] = output_schema
|
|
75
|
+
|
|
76
|
+
return field_dict
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
80
|
+
from ..models.model_config import ModelConfig
|
|
81
|
+
|
|
82
|
+
d = dict(src_dict)
|
|
83
|
+
models = []
|
|
84
|
+
_models = d.pop("models")
|
|
85
|
+
for models_item_data in _models:
|
|
86
|
+
models_item = ModelConfig.from_dict(models_item_data)
|
|
87
|
+
|
|
88
|
+
models.append(models_item)
|
|
89
|
+
|
|
90
|
+
config_type = cast(Literal["ROLLOUT_GENERATOR"] | Unset, d.pop("config_type", UNSET))
|
|
91
|
+
if config_type != "ROLLOUT_GENERATOR" and not isinstance(config_type, Unset):
|
|
92
|
+
raise ValueError(f"config_type must match const 'ROLLOUT_GENERATOR', got '{config_type}'")
|
|
93
|
+
|
|
94
|
+
def _parse_prompt_template(data: object) -> None | str | Unset:
|
|
95
|
+
if data is None:
|
|
96
|
+
return data
|
|
97
|
+
if isinstance(data, Unset):
|
|
98
|
+
return data
|
|
99
|
+
return cast(None | str | Unset, data)
|
|
100
|
+
|
|
101
|
+
prompt_template = _parse_prompt_template(d.pop("prompt_template", UNSET))
|
|
102
|
+
|
|
103
|
+
input_columns = cast(list[str], d.pop("input_columns", UNSET))
|
|
104
|
+
|
|
105
|
+
def _parse_output_schema(data: object) -> Any | None | Unset:
|
|
106
|
+
if data is None:
|
|
107
|
+
return data
|
|
108
|
+
if isinstance(data, Unset):
|
|
109
|
+
return data
|
|
110
|
+
return cast(Any | None | Unset, data)
|
|
111
|
+
|
|
112
|
+
output_schema = _parse_output_schema(d.pop("output_schema", UNSET))
|
|
113
|
+
|
|
114
|
+
rollout_generator = cls(
|
|
115
|
+
models=models,
|
|
116
|
+
config_type=config_type,
|
|
117
|
+
prompt_template=prompt_template,
|
|
118
|
+
input_columns=input_columns,
|
|
119
|
+
output_schema=output_schema,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
rollout_generator.additional_properties = d
|
|
123
|
+
return rollout_generator
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def additional_keys(self) -> list[str]:
|
|
127
|
+
return list(self.additional_properties.keys())
|
|
128
|
+
|
|
129
|
+
def __getitem__(self, key: str) -> Any:
|
|
130
|
+
return self.additional_properties[key]
|
|
131
|
+
|
|
132
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
133
|
+
self.additional_properties[key] = value
|
|
134
|
+
|
|
135
|
+
def __delitem__(self, key: str) -> None:
|
|
136
|
+
del self.additional_properties[key]
|
|
137
|
+
|
|
138
|
+
def __contains__(self, key: str) -> bool:
|
|
139
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="RolloutParsedOutputType0")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class RolloutParsedOutputType0:
|
|
14
|
+
""" """
|
|
15
|
+
|
|
16
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
17
|
+
|
|
18
|
+
def to_dict(self) -> dict[str, Any]:
|
|
19
|
+
field_dict: dict[str, Any] = {}
|
|
20
|
+
field_dict.update(self.additional_properties)
|
|
21
|
+
|
|
22
|
+
return field_dict
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
26
|
+
d = dict(src_dict)
|
|
27
|
+
rollout_parsed_output_type_0 = cls()
|
|
28
|
+
|
|
29
|
+
rollout_parsed_output_type_0.additional_properties = d
|
|
30
|
+
return rollout_parsed_output_type_0
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def additional_keys(self) -> list[str]:
|
|
34
|
+
return list(self.additional_properties.keys())
|
|
35
|
+
|
|
36
|
+
def __getitem__(self, key: str) -> Any:
|
|
37
|
+
return self.additional_properties[key]
|
|
38
|
+
|
|
39
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
40
|
+
self.additional_properties[key] = value
|
|
41
|
+
|
|
42
|
+
def __delitem__(self, key: str) -> None:
|
|
43
|
+
del self.additional_properties[key]
|
|
44
|
+
|
|
45
|
+
def __contains__(self, key: str) -> bool:
|
|
46
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ..models.forward_looking_question import ForwardLookingQuestion
|
|
13
|
+
from ..models.label import Label
|
|
14
|
+
from ..models.news_context import NewsContext
|
|
15
|
+
from ..models.question import Question
|
|
16
|
+
from ..models.rag_context import RAGContext
|
|
17
|
+
from ..models.rollout import Rollout
|
|
18
|
+
from ..models.sample_meta import SampleMeta
|
|
19
|
+
from ..models.seed import Seed
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
T = TypeVar("T", bound="Sample")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@_attrs_define
|
|
26
|
+
class Sample:
|
|
27
|
+
"""
|
|
28
|
+
Attributes:
|
|
29
|
+
seed (None | Seed | Unset):
|
|
30
|
+
question (ForwardLookingQuestion | None | Question | Unset):
|
|
31
|
+
label (Label | None | Unset):
|
|
32
|
+
prompt (None | str | Unset):
|
|
33
|
+
context (list[NewsContext | RAGContext] | None | Unset):
|
|
34
|
+
rollouts (list[Rollout] | None | Unset):
|
|
35
|
+
meta (SampleMeta | Unset):
|
|
36
|
+
is_valid (bool | Unset): Default: True.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
seed: None | Seed | Unset = UNSET
|
|
40
|
+
question: ForwardLookingQuestion | None | Question | Unset = UNSET
|
|
41
|
+
label: Label | None | Unset = UNSET
|
|
42
|
+
prompt: None | str | Unset = UNSET
|
|
43
|
+
context: list[NewsContext | RAGContext] | None | Unset = UNSET
|
|
44
|
+
rollouts: list[Rollout] | None | Unset = UNSET
|
|
45
|
+
meta: SampleMeta | Unset = UNSET
|
|
46
|
+
is_valid: bool | Unset = True
|
|
47
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
48
|
+
|
|
49
|
+
def to_dict(self) -> dict[str, Any]:
|
|
50
|
+
from ..models.forward_looking_question import ForwardLookingQuestion
|
|
51
|
+
from ..models.label import Label
|
|
52
|
+
from ..models.news_context import NewsContext
|
|
53
|
+
from ..models.question import Question
|
|
54
|
+
from ..models.seed import Seed
|
|
55
|
+
|
|
56
|
+
seed: dict[str, Any] | None | Unset
|
|
57
|
+
if isinstance(self.seed, Unset):
|
|
58
|
+
seed = UNSET
|
|
59
|
+
elif isinstance(self.seed, Seed):
|
|
60
|
+
seed = self.seed.to_dict()
|
|
61
|
+
else:
|
|
62
|
+
seed = self.seed
|
|
63
|
+
|
|
64
|
+
question: dict[str, Any] | None | Unset
|
|
65
|
+
if isinstance(self.question, Unset):
|
|
66
|
+
question = UNSET
|
|
67
|
+
elif isinstance(self.question, ForwardLookingQuestion):
|
|
68
|
+
question = self.question.to_dict()
|
|
69
|
+
elif isinstance(self.question, Question):
|
|
70
|
+
question = self.question.to_dict()
|
|
71
|
+
else:
|
|
72
|
+
question = self.question
|
|
73
|
+
|
|
74
|
+
label: dict[str, Any] | None | Unset
|
|
75
|
+
if isinstance(self.label, Unset):
|
|
76
|
+
label = UNSET
|
|
77
|
+
elif isinstance(self.label, Label):
|
|
78
|
+
label = self.label.to_dict()
|
|
79
|
+
else:
|
|
80
|
+
label = self.label
|
|
81
|
+
|
|
82
|
+
prompt: None | str | Unset
|
|
83
|
+
if isinstance(self.prompt, Unset):
|
|
84
|
+
prompt = UNSET
|
|
85
|
+
else:
|
|
86
|
+
prompt = self.prompt
|
|
87
|
+
|
|
88
|
+
context: list[dict[str, Any]] | None | Unset
|
|
89
|
+
if isinstance(self.context, Unset):
|
|
90
|
+
context = UNSET
|
|
91
|
+
elif isinstance(self.context, list):
|
|
92
|
+
context = []
|
|
93
|
+
for context_type_0_item_data in self.context:
|
|
94
|
+
context_type_0_item: dict[str, Any]
|
|
95
|
+
if isinstance(context_type_0_item_data, NewsContext):
|
|
96
|
+
context_type_0_item = context_type_0_item_data.to_dict()
|
|
97
|
+
else:
|
|
98
|
+
context_type_0_item = context_type_0_item_data.to_dict()
|
|
99
|
+
|
|
100
|
+
context.append(context_type_0_item)
|
|
101
|
+
|
|
102
|
+
else:
|
|
103
|
+
context = self.context
|
|
104
|
+
|
|
105
|
+
rollouts: list[dict[str, Any]] | None | Unset
|
|
106
|
+
if isinstance(self.rollouts, Unset):
|
|
107
|
+
rollouts = UNSET
|
|
108
|
+
elif isinstance(self.rollouts, list):
|
|
109
|
+
rollouts = []
|
|
110
|
+
for rollouts_type_0_item_data in self.rollouts:
|
|
111
|
+
rollouts_type_0_item = rollouts_type_0_item_data.to_dict()
|
|
112
|
+
rollouts.append(rollouts_type_0_item)
|
|
113
|
+
|
|
114
|
+
else:
|
|
115
|
+
rollouts = self.rollouts
|
|
116
|
+
|
|
117
|
+
meta: dict[str, Any] | Unset = UNSET
|
|
118
|
+
if not isinstance(self.meta, Unset):
|
|
119
|
+
meta = self.meta.to_dict()
|
|
120
|
+
|
|
121
|
+
is_valid = self.is_valid
|
|
122
|
+
|
|
123
|
+
field_dict: dict[str, Any] = {}
|
|
124
|
+
field_dict.update(self.additional_properties)
|
|
125
|
+
field_dict.update({})
|
|
126
|
+
if seed is not UNSET:
|
|
127
|
+
field_dict["seed"] = seed
|
|
128
|
+
if question is not UNSET:
|
|
129
|
+
field_dict["question"] = question
|
|
130
|
+
if label is not UNSET:
|
|
131
|
+
field_dict["label"] = label
|
|
132
|
+
if prompt is not UNSET:
|
|
133
|
+
field_dict["prompt"] = prompt
|
|
134
|
+
if context is not UNSET:
|
|
135
|
+
field_dict["context"] = context
|
|
136
|
+
if rollouts is not UNSET:
|
|
137
|
+
field_dict["rollouts"] = rollouts
|
|
138
|
+
if meta is not UNSET:
|
|
139
|
+
field_dict["meta"] = meta
|
|
140
|
+
if is_valid is not UNSET:
|
|
141
|
+
field_dict["is_valid"] = is_valid
|
|
142
|
+
|
|
143
|
+
return field_dict
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
147
|
+
from ..models.forward_looking_question import ForwardLookingQuestion
|
|
148
|
+
from ..models.label import Label
|
|
149
|
+
from ..models.news_context import NewsContext
|
|
150
|
+
from ..models.question import Question
|
|
151
|
+
from ..models.rag_context import RAGContext
|
|
152
|
+
from ..models.rollout import Rollout
|
|
153
|
+
from ..models.sample_meta import SampleMeta
|
|
154
|
+
from ..models.seed import Seed
|
|
155
|
+
|
|
156
|
+
d = dict(src_dict)
|
|
157
|
+
|
|
158
|
+
def _parse_seed(data: object) -> None | Seed | Unset:
|
|
159
|
+
if data is None:
|
|
160
|
+
return data
|
|
161
|
+
if isinstance(data, Unset):
|
|
162
|
+
return data
|
|
163
|
+
try:
|
|
164
|
+
if not isinstance(data, dict):
|
|
165
|
+
raise TypeError()
|
|
166
|
+
seed_type_0 = Seed.from_dict(data)
|
|
167
|
+
|
|
168
|
+
return seed_type_0
|
|
169
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
170
|
+
pass
|
|
171
|
+
return cast(None | Seed | Unset, data)
|
|
172
|
+
|
|
173
|
+
seed = _parse_seed(d.pop("seed", UNSET))
|
|
174
|
+
|
|
175
|
+
def _parse_question(data: object) -> ForwardLookingQuestion | None | Question | Unset:
|
|
176
|
+
if data is None:
|
|
177
|
+
return data
|
|
178
|
+
if isinstance(data, Unset):
|
|
179
|
+
return data
|
|
180
|
+
try:
|
|
181
|
+
if not isinstance(data, dict):
|
|
182
|
+
raise TypeError()
|
|
183
|
+
question_type_0_type_0 = ForwardLookingQuestion.from_dict(data)
|
|
184
|
+
|
|
185
|
+
return question_type_0_type_0
|
|
186
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
187
|
+
pass
|
|
188
|
+
try:
|
|
189
|
+
if not isinstance(data, dict):
|
|
190
|
+
raise TypeError()
|
|
191
|
+
question_type_0_type_1 = Question.from_dict(data)
|
|
192
|
+
|
|
193
|
+
return question_type_0_type_1
|
|
194
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
195
|
+
pass
|
|
196
|
+
return cast(ForwardLookingQuestion | None | Question | Unset, data)
|
|
197
|
+
|
|
198
|
+
question = _parse_question(d.pop("question", UNSET))
|
|
199
|
+
|
|
200
|
+
def _parse_label(data: object) -> Label | None | Unset:
|
|
201
|
+
if data is None:
|
|
202
|
+
return data
|
|
203
|
+
if isinstance(data, Unset):
|
|
204
|
+
return data
|
|
205
|
+
try:
|
|
206
|
+
if not isinstance(data, dict):
|
|
207
|
+
raise TypeError()
|
|
208
|
+
label_type_0 = Label.from_dict(data)
|
|
209
|
+
|
|
210
|
+
return label_type_0
|
|
211
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
212
|
+
pass
|
|
213
|
+
return cast(Label | None | Unset, data)
|
|
214
|
+
|
|
215
|
+
label = _parse_label(d.pop("label", UNSET))
|
|
216
|
+
|
|
217
|
+
def _parse_prompt(data: object) -> None | str | Unset:
|
|
218
|
+
if data is None:
|
|
219
|
+
return data
|
|
220
|
+
if isinstance(data, Unset):
|
|
221
|
+
return data
|
|
222
|
+
return cast(None | str | Unset, data)
|
|
223
|
+
|
|
224
|
+
prompt = _parse_prompt(d.pop("prompt", UNSET))
|
|
225
|
+
|
|
226
|
+
def _parse_context(data: object) -> list[NewsContext | RAGContext] | None | Unset:
|
|
227
|
+
if data is None:
|
|
228
|
+
return data
|
|
229
|
+
if isinstance(data, Unset):
|
|
230
|
+
return data
|
|
231
|
+
try:
|
|
232
|
+
if not isinstance(data, list):
|
|
233
|
+
raise TypeError()
|
|
234
|
+
context_type_0 = []
|
|
235
|
+
_context_type_0 = data
|
|
236
|
+
for context_type_0_item_data in _context_type_0:
|
|
237
|
+
|
|
238
|
+
def _parse_context_type_0_item(data: object) -> NewsContext | RAGContext:
|
|
239
|
+
try:
|
|
240
|
+
if not isinstance(data, dict):
|
|
241
|
+
raise TypeError()
|
|
242
|
+
context_type_0_item_type_0 = NewsContext.from_dict(data)
|
|
243
|
+
|
|
244
|
+
return context_type_0_item_type_0
|
|
245
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
246
|
+
pass
|
|
247
|
+
if not isinstance(data, dict):
|
|
248
|
+
raise TypeError()
|
|
249
|
+
context_type_0_item_type_1 = RAGContext.from_dict(data)
|
|
250
|
+
|
|
251
|
+
return context_type_0_item_type_1
|
|
252
|
+
|
|
253
|
+
context_type_0_item = _parse_context_type_0_item(context_type_0_item_data)
|
|
254
|
+
|
|
255
|
+
context_type_0.append(context_type_0_item)
|
|
256
|
+
|
|
257
|
+
return context_type_0
|
|
258
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
259
|
+
pass
|
|
260
|
+
return cast(list[NewsContext | RAGContext] | None | Unset, data)
|
|
261
|
+
|
|
262
|
+
context = _parse_context(d.pop("context", UNSET))
|
|
263
|
+
|
|
264
|
+
def _parse_rollouts(data: object) -> list[Rollout] | None | Unset:
|
|
265
|
+
if data is None:
|
|
266
|
+
return data
|
|
267
|
+
if isinstance(data, Unset):
|
|
268
|
+
return data
|
|
269
|
+
try:
|
|
270
|
+
if not isinstance(data, list):
|
|
271
|
+
raise TypeError()
|
|
272
|
+
rollouts_type_0 = []
|
|
273
|
+
_rollouts_type_0 = data
|
|
274
|
+
for rollouts_type_0_item_data in _rollouts_type_0:
|
|
275
|
+
rollouts_type_0_item = Rollout.from_dict(rollouts_type_0_item_data)
|
|
276
|
+
|
|
277
|
+
rollouts_type_0.append(rollouts_type_0_item)
|
|
278
|
+
|
|
279
|
+
return rollouts_type_0
|
|
280
|
+
except (TypeError, ValueError, AttributeError, KeyError):
|
|
281
|
+
pass
|
|
282
|
+
return cast(list[Rollout] | None | Unset, data)
|
|
283
|
+
|
|
284
|
+
rollouts = _parse_rollouts(d.pop("rollouts", UNSET))
|
|
285
|
+
|
|
286
|
+
_meta = d.pop("meta", UNSET)
|
|
287
|
+
meta: SampleMeta | Unset
|
|
288
|
+
if isinstance(_meta, Unset):
|
|
289
|
+
meta = UNSET
|
|
290
|
+
else:
|
|
291
|
+
meta = SampleMeta.from_dict(_meta)
|
|
292
|
+
|
|
293
|
+
is_valid = d.pop("is_valid", UNSET)
|
|
294
|
+
|
|
295
|
+
sample = cls(
|
|
296
|
+
seed=seed,
|
|
297
|
+
question=question,
|
|
298
|
+
label=label,
|
|
299
|
+
prompt=prompt,
|
|
300
|
+
context=context,
|
|
301
|
+
rollouts=rollouts,
|
|
302
|
+
meta=meta,
|
|
303
|
+
is_valid=is_valid,
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
sample.additional_properties = d
|
|
307
|
+
return sample
|
|
308
|
+
|
|
309
|
+
@property
|
|
310
|
+
def additional_keys(self) -> list[str]:
|
|
311
|
+
return list(self.additional_properties.keys())
|
|
312
|
+
|
|
313
|
+
def __getitem__(self, key: str) -> Any:
|
|
314
|
+
return self.additional_properties[key]
|
|
315
|
+
|
|
316
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
317
|
+
self.additional_properties[key] = value
|
|
318
|
+
|
|
319
|
+
def __delitem__(self, key: str) -> None:
|
|
320
|
+
del self.additional_properties[key]
|
|
321
|
+
|
|
322
|
+
def __contains__(self, key: str) -> bool:
|
|
323
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="SampleMeta")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class SampleMeta:
|
|
14
|
+
""" """
|
|
15
|
+
|
|
16
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
17
|
+
|
|
18
|
+
def to_dict(self) -> dict[str, Any]:
|
|
19
|
+
field_dict: dict[str, Any] = {}
|
|
20
|
+
field_dict.update(self.additional_properties)
|
|
21
|
+
|
|
22
|
+
return field_dict
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
26
|
+
d = dict(src_dict)
|
|
27
|
+
sample_meta = cls()
|
|
28
|
+
|
|
29
|
+
sample_meta.additional_properties = d
|
|
30
|
+
return sample_meta
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def additional_keys(self) -> list[str]:
|
|
34
|
+
return list(self.additional_properties.keys())
|
|
35
|
+
|
|
36
|
+
def __getitem__(self, key: str) -> Any:
|
|
37
|
+
return self.additional_properties[key]
|
|
38
|
+
|
|
39
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
40
|
+
self.additional_properties[key] = value
|
|
41
|
+
|
|
42
|
+
def __delitem__(self, key: str) -> None:
|
|
43
|
+
del self.additional_properties[key]
|
|
44
|
+
|
|
45
|
+
def __contains__(self, key: str) -> bool:
|
|
46
|
+
return key in self.additional_properties
|