seekrai 0.3.2__py3-none-any.whl → 0.4.1__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.
@@ -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(
seekrai/filemanager.py CHANGED
@@ -91,10 +91,9 @@ def _prepare_output(
91
91
 
92
92
  content_type = str(headers.get("content-type"))
93
93
 
94
- assert remote_name, (
95
- "No model name found in fine_tune object. "
96
- "Please specify an `output` file name."
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 = 0,
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 = 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
 
seekrai/types/__init__.py CHANGED
@@ -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):
seekrai/types/finetune.py CHANGED
@@ -172,6 +172,7 @@ class FinetuneResponse(BaseModel):
172
172
  inference_available: bool = False
173
173
  project_id: Optional[int] = None # TODO - fix this
174
174
  completed_at: datetime | None = None
175
+ description: str | None = None
175
176
 
176
177
  # dataset token count
177
178
  # TODO
@@ -0,0 +1,8 @@
1
+ from enum import Enum
2
+
3
+
4
+ class IngestionJobStatus(Enum):
5
+ QUEUED = "queued"
6
+ RUNNING = "running"
7
+ COMPLETED = "completed"
8
+ FAILED = "failed"
seekrai/utils/files.py CHANGED
@@ -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 ,3)} 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'Expected string. Found {type(json_line["text"])}.'
120
+ f"Expected string. Found {type(json_line['text'])}."
121
121
  )
122
122
 
123
123
  report_dict["is_check_passed"] = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: seekrai
3
- Version: 0.3.2
3
+ Version: 0.4.1
4
4
  Summary: Python client for SeekrAI
5
5
  Home-page: https://gitlab.cb.ntent.com/ml/seekr-py
6
6
  License: Apache-2.0
@@ -1,14 +1,14 @@
1
1
  seekrai/__init__.py,sha256=HC6iy-IdwqecabH-6a80Lsy9qO2PBToAI0WqEErV41c,935
2
2
  seekrai/abstract/__init__.py,sha256=wNiOTW9TJpUgfCJCG-wAbhhWWH2PtoVpAuL3nxvQGps,56
3
- seekrai/abstract/api_requestor.py,sha256=tI43JdbUfNQHWjvRrenUM7C7Ea-zD-7yd2JNS-Lki04,18297
3
+ seekrai/abstract/api_requestor.py,sha256=NT41M0_Utfw61bMqibP1PEdIIQmmKWfzj-Y-xk4DNY0,18395
4
4
  seekrai/client.py,sha256=Yhejl-2a-Uoc8nWi-XxETZT4a4Ou_t_TRLcp0e9APIY,5376
5
5
  seekrai/constants.py,sha256=hoR2iF5te5Ydjt_lxIOSGID4vESIakG4F-3xAWdwxaU,1854
6
6
  seekrai/error.py,sha256=rAYL8qEd8INwYMMKvhS-HKeC3QkWL4Wq-zfazFU-zBg,4861
7
- seekrai/filemanager.py,sha256=8RuSzJvELD-fCI2Wd_t0jSKeVrmFwF7E5AzXIgDFxNA,9572
7
+ seekrai/filemanager.py,sha256=5tl7fjsLbNy-U1Ko_5iQSdkZ0Bca_bhvR9FhWpaG8FA,9561
8
8
  seekrai/resources/__init__.py,sha256=-OpvrZp0c_ro_e1G14gjOILtcSfpSOeRZeK8kt41WLo,1014
9
- seekrai/resources/alignment.py,sha256=6qQm9w0Em0q3zVeOzs8cX3wulr-B-wh4Pcr3pboIeTE,4468
9
+ seekrai/resources/alignment.py,sha256=MMrADpXNZa0eQ-jqfLcP7-fisJXgpRl-03GPdkjkTcc,5951
10
10
  seekrai/resources/chat/__init__.py,sha256=KmtPupgECtEN80NyvcnSmieTAFXhwmVxhMHP0qhspA4,618
11
- seekrai/resources/chat/completions.py,sha256=pGBVrIvUfY-wr0ooiywzuhIjZ4GwiojH3ofmRE6bYlw,11643
11
+ seekrai/resources/chat/completions.py,sha256=U75hKIDBAX8h5-4aFe20DowO1adqBD6ZRHjPK9EdqqM,11653
12
12
  seekrai/resources/completions.py,sha256=w3La3zPMlN00y-b-tJwLgvZVH-xK_dKC6ktI5Ggn1us,8564
13
13
  seekrai/resources/deployments.py,sha256=HmP7MuxAlLUoQl6z705_d1Y53MDvGgSQXhlgN3DKX2A,6078
14
14
  seekrai/resources/embeddings.py,sha256=3lohUrkdFqzSg8FgS7p4r87jwjE0NXU1PilWv278quk,2705
@@ -18,9 +18,9 @@ seekrai/resources/images.py,sha256=E48lAe7YsZ2WXBHR_qz4SF7P4Y-U7t61m_bWNS91pM0,4
18
18
  seekrai/resources/models.py,sha256=Pdd0S0gZdratWcHJPKNb7LkEdUGjr3xNR06W6GDiyxk,5000
19
19
  seekrai/resources/projects.py,sha256=AWJUeUDSzkbxBksHjJ4a3c83UR62TlMGHutm2NdV6Xk,3790
20
20
  seekrai/seekrflow_response.py,sha256=5RFEQzamDy7sTSDkxSsZQThZ3biNmeCPeHWdrFId5Go,1320
21
- seekrai/types/__init__.py,sha256=E41__vAq-tnm5aVYW0Ef1Ky-GMPnMpUKlyLr3pYhLSM,2358
21
+ seekrai/types/__init__.py,sha256=34IvdhaeKDNqA03G0nwta8sptpURzbXeTlqr6mhagnw,2532
22
22
  seekrai/types/abstract.py,sha256=TqWFQV_6bPblywfCH-r8FCkXWvPkc9KlJ4QVgyrnaMc,642
23
- seekrai/types/alignment.py,sha256=-lxF0Cyj3w4brMft8WAoc2EDMAlbX7zdRYD04ot98-Y,1129
23
+ seekrai/types/alignment.py,sha256=H9rAYsr4rg7uZCgl2tDZjkeq-b_Ov27gljejH8fC26w,1919
24
24
  seekrai/types/chat_completions.py,sha256=xRTHBbDJDbz0HgW042WX3csQDolhjEuO81w0rzFSeBU,3691
25
25
  seekrai/types/common.py,sha256=OH3l3u-0_5oz1KYrcHMybFESzivDySocYlJAsLSLOWU,1940
26
26
  seekrai/types/completions.py,sha256=lm9AFdZR3Xg5AHPkV-qETHikkwMJmkHrLGr5GG-YR-M,2171
@@ -28,18 +28,19 @@ seekrai/types/deployments.py,sha256=n7_t7DEeBSC8cDJSjIfvWtcgUql1DaEn89zuGYN_RaI,
28
28
  seekrai/types/embeddings.py,sha256=OANoLNOs0aceS8NppVvvcNYQbF7-pAOAmcr30pw64OU,749
29
29
  seekrai/types/error.py,sha256=uTKISs9aRC4_6zwirtNkanxepN8KY-SqCq0kNbfZylQ,370
30
30
  seekrai/types/files.py,sha256=XmtiM6d9i3tnYS-Kii3QpxZJRqemJi2rvLJ32GsECXQ,2602
31
- seekrai/types/finetune.py,sha256=Izh7NfaW7pGzSN5GpWYSaZpkHV2TilE1CF62DrB8vE0,6089
31
+ seekrai/types/finetune.py,sha256=VNuAZx-Lq4Q55hY47obWnFLDr9if93v5Lwr_qcyCtfU,6124
32
32
  seekrai/types/images.py,sha256=Fusj8OhVYFsT8kz636lRGGivLbPXo_ZNgakKwmzJi3U,914
33
+ seekrai/types/ingestion.py,sha256=GqDzPjEA_rtiiDKpEmTOXOitZSSKG-JkH1siII5m8oA,152
33
34
  seekrai/types/models.py,sha256=1ZfW9WwayApkISRizDntjkWhYNv-wkbrRVIfHn2QuC4,1242
34
35
  seekrai/types/projects.py,sha256=JFgpZdovia8Orcnhp6QkIEAXzyPCfKT_bUiwjxUaHHQ,670
35
36
  seekrai/utils/__init__.py,sha256=dfbiYEc47EBVRkq6C4O9y6tTGuPuV3LbV3__v01Mbds,658
36
37
  seekrai/utils/_log.py,sha256=Cayw5B394H2WGVTXPXS2AN8znQdxsgrLqADXgqmokvU,1649
37
38
  seekrai/utils/api_helpers.py,sha256=0Y8BblNIr9h_R12zdmhkxgTlxgoRkbq84QNi4nNWGu8,2385
38
- seekrai/utils/files.py,sha256=B61Pwra49MVVWjPtdkx4hBtAuUe9UI63hdNus87Uq0o,7164
39
+ seekrai/utils/files.py,sha256=7ixn_hgV-6pEhYqLyOp-EN0o8c1CzUwJzX9n3PQ5oqo,7164
39
40
  seekrai/utils/tools.py,sha256=jgJTL-dOIouDbEJLdQpQfpXhqaz_poQYS52adyUtBjo,1781
40
41
  seekrai/version.py,sha256=q6iGQVFor8zXiPP5F-3vy9TndOxKv5JXbaNJ2kdOQws,125
41
- seekrai-0.3.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
42
- seekrai-0.3.2.dist-info/METADATA,sha256=M1kwCRaiObFvV3IpKSYII0kx3_FqGyPRZ8tU1ukz3e8,4748
43
- seekrai-0.3.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
44
- seekrai-0.3.2.dist-info/entry_points.txt,sha256=N49yOEGi1sK7Xr13F_rkkcOxQ88suyiMoOmRhUHTZ_U,48
45
- seekrai-0.3.2.dist-info/RECORD,,
42
+ seekrai-0.4.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
+ seekrai-0.4.1.dist-info/METADATA,sha256=28ojGXBP-65YoZv0VfwQ__mN76eC_I53aSso7caRz_E,4748
44
+ seekrai-0.4.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
45
+ seekrai-0.4.1.dist-info/entry_points.txt,sha256=N49yOEGi1sK7Xr13F_rkkcOxQ88suyiMoOmRhUHTZ_U,48
46
+ seekrai-0.4.1.dist-info/RECORD,,