seekrai 0.3.2__tar.gz → 0.4.1__tar.gz
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.
- {seekrai-0.3.2 → seekrai-0.4.1}/PKG-INFO +1 -1
- {seekrai-0.3.2 → seekrai-0.4.1}/pyproject.toml +2 -1
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/abstract/api_requestor.py +2 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/filemanager.py +3 -4
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/alignment.py +49 -4
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/chat/completions.py +3 -4
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/__init__.py +6 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/alignment.py +28 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/finetune.py +1 -0
- seekrai-0.4.1/src/seekrai/types/ingestion.py +8 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/utils/files.py +2 -2
- {seekrai-0.3.2 → seekrai-0.4.1}/LICENSE +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/README.md +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/__init__.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/abstract/__init__.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/client.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/constants.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/error.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/__init__.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/chat/__init__.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/completions.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/deployments.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/embeddings.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/files.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/finetune.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/images.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/models.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/resources/projects.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/seekrflow_response.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/abstract.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/chat_completions.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/common.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/completions.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/deployments.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/embeddings.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/error.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/files.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/images.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/models.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/types/projects.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/utils/__init__.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/utils/_log.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/utils/api_helpers.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/utils/tools.py +0 -0
- {seekrai-0.3.2 → seekrai-0.4.1}/src/seekrai/version.py +0 -0
|
@@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
14
14
|
|
|
15
15
|
[tool.poetry]
|
|
16
16
|
name = "seekrai"
|
|
17
|
-
version = "0.
|
|
17
|
+
version = "0.4.1"
|
|
18
18
|
authors = [
|
|
19
19
|
"SeekrFlow <support@seekr.com>"
|
|
20
20
|
]
|
|
@@ -73,6 +73,7 @@ tox = "^4.14.1"
|
|
|
73
73
|
[tool.poetry.group.dev.dependencies]
|
|
74
74
|
ipdb = "^0.13.13"
|
|
75
75
|
pre-commit = "^3.7.1"
|
|
76
|
+
jupyter = "^1.0.0"
|
|
76
77
|
|
|
77
78
|
[tool.poetry.urls]
|
|
78
79
|
"Homepage" = "https://www.seekr.com/"
|
|
@@ -524,6 +524,8 @@ class APIRequestor:
|
|
|
524
524
|
if rbody.strip().endswith("[DONE]"):
|
|
525
525
|
# TODO
|
|
526
526
|
rbody = rbody.replace("data: [DONE]", "")
|
|
527
|
+
if rbody.startswith("data: "):
|
|
528
|
+
rbody = rbody[len("data: ") :]
|
|
527
529
|
data = json.loads(rbody)
|
|
528
530
|
except (JSONDecodeError, UnicodeDecodeError) as e:
|
|
529
531
|
raise error.APIError(
|
|
@@ -91,10 +91,9 @@ def _prepare_output(
|
|
|
91
91
|
|
|
92
92
|
content_type = str(headers.get("content-type"))
|
|
93
93
|
|
|
94
|
-
assert
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
94
|
+
assert (
|
|
95
|
+
remote_name
|
|
96
|
+
), "No model name found in fine_tune object. Please specify an `output` file name."
|
|
98
97
|
|
|
99
98
|
if step > 0:
|
|
100
99
|
remote_name += f"-checkpoint-{step}"
|
|
@@ -3,9 +3,12 @@ from typing import List
|
|
|
3
3
|
from seekrai.abstract import api_requestor
|
|
4
4
|
from seekrai.seekrflow_response import SeekrFlowResponse
|
|
5
5
|
from seekrai.types import (
|
|
6
|
+
AlignmentEstimationRequest,
|
|
7
|
+
AlignmentEstimationResponse,
|
|
6
8
|
AlignmentList,
|
|
7
9
|
AlignmentRequest,
|
|
8
10
|
AlignmentResponse,
|
|
11
|
+
AlignmentType,
|
|
9
12
|
SeekrFlowClient,
|
|
10
13
|
SeekrFlowRequest,
|
|
11
14
|
)
|
|
@@ -19,14 +22,14 @@ class Alignment:
|
|
|
19
22
|
self,
|
|
20
23
|
instructions: str,
|
|
21
24
|
files: List[str],
|
|
25
|
+
type: AlignmentType = AlignmentType.PRINCIPLE,
|
|
22
26
|
) -> AlignmentResponse:
|
|
23
27
|
requestor = api_requestor.APIRequestor(
|
|
24
28
|
client=self._client,
|
|
25
29
|
)
|
|
26
30
|
|
|
27
31
|
parameter_payload = AlignmentRequest(
|
|
28
|
-
instructions=instructions,
|
|
29
|
-
files=files,
|
|
32
|
+
instructions=instructions, files=files, type=type
|
|
30
33
|
).model_dump()
|
|
31
34
|
|
|
32
35
|
response, _, _ = requestor.request(
|
|
@@ -92,6 +95,27 @@ class Alignment:
|
|
|
92
95
|
|
|
93
96
|
return AlignmentResponse(**response.data)
|
|
94
97
|
|
|
98
|
+
def estimate(self, files: List[str]) -> AlignmentEstimationResponse:
|
|
99
|
+
requestor = api_requestor.APIRequestor(
|
|
100
|
+
client=self._client,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
parameter_payload = AlignmentEstimationRequest(
|
|
104
|
+
files=files,
|
|
105
|
+
).model_dump()
|
|
106
|
+
|
|
107
|
+
response, _, _ = requestor.request(
|
|
108
|
+
options=SeekrFlowRequest(
|
|
109
|
+
method="POST",
|
|
110
|
+
url="flow/alignment/estimate",
|
|
111
|
+
params=parameter_payload,
|
|
112
|
+
),
|
|
113
|
+
stream=False,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
117
|
+
return AlignmentEstimationResponse(**response.data)
|
|
118
|
+
|
|
95
119
|
|
|
96
120
|
class AsyncAlignment:
|
|
97
121
|
def __init__(self, client: SeekrFlowClient) -> None:
|
|
@@ -101,14 +125,14 @@ class AsyncAlignment:
|
|
|
101
125
|
self,
|
|
102
126
|
instructions: str,
|
|
103
127
|
files: List[str],
|
|
128
|
+
type: AlignmentType = AlignmentType.PRINCIPLE,
|
|
104
129
|
) -> AlignmentResponse:
|
|
105
130
|
requestor = api_requestor.APIRequestor(
|
|
106
131
|
client=self._client,
|
|
107
132
|
)
|
|
108
133
|
|
|
109
134
|
parameter_payload = AlignmentRequest(
|
|
110
|
-
instructions=instructions,
|
|
111
|
-
files=files,
|
|
135
|
+
instructions=instructions, files=files, type=type
|
|
112
136
|
).model_dump()
|
|
113
137
|
|
|
114
138
|
response, _, _ = await requestor.arequest(
|
|
@@ -173,3 +197,24 @@ class AsyncAlignment:
|
|
|
173
197
|
assert isinstance(response, SeekrFlowResponse)
|
|
174
198
|
|
|
175
199
|
return AlignmentResponse(**response.data)
|
|
200
|
+
|
|
201
|
+
async def estimate(self, files: List[str]) -> AlignmentEstimationResponse:
|
|
202
|
+
requestor = api_requestor.APIRequestor(
|
|
203
|
+
client=self._client,
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
parameter_payload = AlignmentEstimationRequest(
|
|
207
|
+
files=files,
|
|
208
|
+
).model_dump()
|
|
209
|
+
|
|
210
|
+
response, _, _ = await requestor.arequest(
|
|
211
|
+
options=SeekrFlowRequest(
|
|
212
|
+
method="POST",
|
|
213
|
+
url="flow/alignment/estimate",
|
|
214
|
+
params=parameter_payload,
|
|
215
|
+
),
|
|
216
|
+
stream=False,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
220
|
+
return AlignmentEstimationResponse(**response.data)
|
|
@@ -30,13 +30,13 @@ class ChatCompletions:
|
|
|
30
30
|
repetition_penalty: float = 1,
|
|
31
31
|
stream: bool = False,
|
|
32
32
|
logprobs: bool | None = False,
|
|
33
|
-
top_logprobs: int | None =
|
|
33
|
+
top_logprobs: int | None = None,
|
|
34
34
|
echo: bool = False,
|
|
35
35
|
n: int = 1,
|
|
36
36
|
safety_model: str | None = None,
|
|
37
37
|
response_format: Dict[str, str | Dict[str, Any]] | None = None,
|
|
38
38
|
tools: Dict[str, str | Dict[str, Any]] | None = None,
|
|
39
|
-
tool_choice: str | Dict[str, str | Dict[str, str]] | None =
|
|
39
|
+
tool_choice: str | Dict[str, str | Dict[str, str]] | None = "auto",
|
|
40
40
|
) -> ChatCompletionResponse | Iterator[ChatCompletionChunk]:
|
|
41
41
|
"""
|
|
42
42
|
Method to generate completions based on a given prompt using a specified model.
|
|
@@ -89,7 +89,6 @@ class ChatCompletions:
|
|
|
89
89
|
ChatCompletionResponse | Iterator[ChatCompletionChunk]: Object containing the completions
|
|
90
90
|
or an iterator over completion chunks.
|
|
91
91
|
"""
|
|
92
|
-
|
|
93
92
|
requestor = api_requestor.APIRequestor(
|
|
94
93
|
client=self._client,
|
|
95
94
|
)
|
|
@@ -110,7 +109,7 @@ class ChatCompletions:
|
|
|
110
109
|
n=n,
|
|
111
110
|
safety_model=safety_model,
|
|
112
111
|
response_format=response_format,
|
|
113
|
-
tools=tools,
|
|
112
|
+
tools=tools or [],
|
|
114
113
|
tool_choice=tool_choice,
|
|
115
114
|
).model_dump()
|
|
116
115
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from seekrai.types.abstract import SeekrFlowClient
|
|
2
2
|
from seekrai.types.alignment import (
|
|
3
|
+
AlignmentEstimationRequest,
|
|
4
|
+
AlignmentEstimationResponse,
|
|
3
5
|
AlignmentJobStatus,
|
|
4
6
|
AlignmentList,
|
|
5
7
|
AlignmentRequest,
|
|
6
8
|
AlignmentResponse,
|
|
9
|
+
AlignmentType,
|
|
7
10
|
)
|
|
8
11
|
from seekrai.types.chat_completions import (
|
|
9
12
|
ChatCompletionChunk,
|
|
@@ -87,9 +90,12 @@ __all__ = [
|
|
|
87
90
|
"ModelResponse",
|
|
88
91
|
"ModelList",
|
|
89
92
|
"AlignmentRequest",
|
|
93
|
+
"AlignmentEstimationRequest",
|
|
94
|
+
"AlignmentEstimationResponse",
|
|
90
95
|
"AlignmentResponse",
|
|
91
96
|
"AlignmentJobStatus",
|
|
92
97
|
"AlignmentList",
|
|
98
|
+
"AlignmentType",
|
|
93
99
|
"Project",
|
|
94
100
|
"ProjectWithRuns",
|
|
95
101
|
"GetProjectsResponse",
|
|
@@ -9,6 +9,12 @@ from pydantic import Field
|
|
|
9
9
|
from seekrai.types.abstract import BaseModel
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
class AlignmentType(str, Enum):
|
|
13
|
+
PRINCIPLE = "principle"
|
|
14
|
+
CHAIN_OF_THOUGHT = "chain_of_thought"
|
|
15
|
+
RAFT = "raft"
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
class AlignmentRequest(BaseModel):
|
|
13
19
|
instructions: str = Field(
|
|
14
20
|
default=..., description="Task description/instructions for the alignment task"
|
|
@@ -16,6 +22,28 @@ class AlignmentRequest(BaseModel):
|
|
|
16
22
|
files: List[str] = Field(
|
|
17
23
|
default=..., description="List of file ids to use for alignment"
|
|
18
24
|
)
|
|
25
|
+
type: AlignmentType = Field(
|
|
26
|
+
default=AlignmentType.PRINCIPLE,
|
|
27
|
+
description="Type of alignment task (principle, chain_of_thought, or raft)",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AlignmentEstimationRequest(BaseModel):
|
|
32
|
+
files: List[str] = Field(
|
|
33
|
+
default=...,
|
|
34
|
+
description="List of file ids to use to generate an alignment estimate",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class AlignmentEstimationResponse(BaseModel):
|
|
39
|
+
input_tokens: int = Field(
|
|
40
|
+
default=...,
|
|
41
|
+
description="Estimated number of input tokens for the given files",
|
|
42
|
+
)
|
|
43
|
+
output_tokens: int = Field(
|
|
44
|
+
default=...,
|
|
45
|
+
description="Estimated number of output tokens for the given files",
|
|
46
|
+
)
|
|
19
47
|
|
|
20
48
|
|
|
21
49
|
class AlignmentJobStatus(str, Enum):
|
|
@@ -47,7 +47,7 @@ def check_file(
|
|
|
47
47
|
|
|
48
48
|
if file_size > MAX_FILE_SIZE_GB * NUM_BYTES_IN_GB:
|
|
49
49
|
report_dict["message"] = (
|
|
50
|
-
f"Maximum supported file size is {MAX_FILE_SIZE_GB} GB. Found file with size of {round(file_size / NUM_BYTES_IN_GB
|
|
50
|
+
f"Maximum supported file size is {MAX_FILE_SIZE_GB} GB. Found file with size of {round(file_size / NUM_BYTES_IN_GB, 3)} GB."
|
|
51
51
|
)
|
|
52
52
|
report_dict["is_check_passed"] = False
|
|
53
53
|
elif file_size == 0:
|
|
@@ -117,7 +117,7 @@ def _check_jsonl(file: Path) -> Dict[str, Any]:
|
|
|
117
117
|
report_dict["key_value"] = False
|
|
118
118
|
report_dict["message"] = (
|
|
119
119
|
f'Invalid value type for "text" key on line {idx + 1}. '
|
|
120
|
-
f
|
|
120
|
+
f"Expected string. Found {type(json_line['text'])}."
|
|
121
121
|
)
|
|
122
122
|
|
|
123
123
|
report_dict["is_check_passed"] = False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|