seekrai 0.0.1__py3-none-any.whl → 0.1.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.
- seekrai/__init__.py +0 -15
- seekrai/abstract/api_requestor.py +121 -297
- seekrai/client.py +10 -11
- seekrai/constants.py +36 -16
- seekrai/error.py +1 -8
- seekrai/filemanager.py +40 -79
- seekrai/resources/chat/completions.py +13 -13
- seekrai/resources/completions.py +4 -4
- seekrai/resources/embeddings.py +4 -2
- seekrai/resources/files.py +17 -9
- seekrai/resources/finetune.py +57 -82
- seekrai/resources/images.py +2 -2
- seekrai/resources/models.py +115 -15
- seekrai/types/__init__.py +5 -4
- seekrai/types/common.py +1 -2
- seekrai/types/files.py +23 -19
- seekrai/types/finetune.py +20 -26
- seekrai/types/models.py +26 -20
- seekrai/utils/_log.py +3 -3
- seekrai/utils/api_helpers.py +2 -2
- seekrai/utils/tools.py +1 -1
- seekrai-0.1.1.dist-info/METADATA +165 -0
- seekrai-0.1.1.dist-info/RECORD +39 -0
- seekrai/cli/__init__.py +0 -0
- seekrai/cli/api/__init__.py +0 -0
- seekrai/cli/api/chat.py +0 -245
- seekrai/cli/api/completions.py +0 -107
- seekrai/cli/api/files.py +0 -125
- seekrai/cli/api/finetune.py +0 -175
- seekrai/cli/api/images.py +0 -82
- seekrai/cli/api/models.py +0 -42
- seekrai/cli/cli.py +0 -77
- seekrai/legacy/__init__.py +0 -0
- seekrai/legacy/base.py +0 -27
- seekrai/legacy/complete.py +0 -91
- seekrai/legacy/embeddings.py +0 -25
- seekrai/legacy/files.py +0 -140
- seekrai/legacy/finetune.py +0 -173
- seekrai/legacy/images.py +0 -25
- seekrai/legacy/models.py +0 -44
- seekrai-0.0.1.dist-info/METADATA +0 -401
- seekrai-0.0.1.dist-info/RECORD +0 -56
- {seekrai-0.0.1.dist-info → seekrai-0.1.1.dist-info}/LICENSE +0 -0
- {seekrai-0.0.1.dist-info → seekrai-0.1.1.dist-info}/WHEEL +0 -0
- {seekrai-0.0.1.dist-info → seekrai-0.1.1.dist-info}/entry_points.txt +0 -0
seekrai/client.py
CHANGED
|
@@ -34,8 +34,8 @@ class SeekrFlow:
|
|
|
34
34
|
"""Construct a new synchronous seekrai client instance.
|
|
35
35
|
|
|
36
36
|
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
37
|
-
- `api_key` from `
|
|
38
|
-
- `base_url` from `
|
|
37
|
+
- `api_key` from `SEEKR_API_KEY`
|
|
38
|
+
- `base_url` from `SEEKR_BASE_URL`
|
|
39
39
|
"""
|
|
40
40
|
|
|
41
41
|
# get api key
|
|
@@ -50,7 +50,7 @@ class SeekrFlow:
|
|
|
50
50
|
|
|
51
51
|
# get base url
|
|
52
52
|
if not base_url:
|
|
53
|
-
base_url = os.environ.get("
|
|
53
|
+
base_url = os.environ.get("SEEKR_BASE_URL")
|
|
54
54
|
|
|
55
55
|
if not base_url:
|
|
56
56
|
base_url = BASE_URL
|
|
@@ -64,7 +64,7 @@ class SeekrFlow:
|
|
|
64
64
|
# SeekrFlowClient object
|
|
65
65
|
self.client = SeekrFlowClient(
|
|
66
66
|
api_key=api_key,
|
|
67
|
-
base_url=enforce_trailing_slash(base_url),
|
|
67
|
+
base_url=enforce_trailing_slash(base_url), # type: ignore
|
|
68
68
|
timeout=timeout,
|
|
69
69
|
max_retries=max_retries,
|
|
70
70
|
supplied_headers=supplied_headers,
|
|
@@ -77,7 +77,6 @@ class SeekrFlow:
|
|
|
77
77
|
self.images = resources.Images(self.client)
|
|
78
78
|
self.models = resources.Models(self.client)
|
|
79
79
|
self.fine_tuning = resources.FineTuning(self.client)
|
|
80
|
-
# self.instruction_fine_tuning = resources.InstructionFineTuning(self.client) # todo
|
|
81
80
|
|
|
82
81
|
|
|
83
82
|
class AsyncSeekrFlow:
|
|
@@ -104,23 +103,23 @@ class AsyncSeekrFlow:
|
|
|
104
103
|
"""Construct a new async seekrai client instance.
|
|
105
104
|
|
|
106
105
|
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
107
|
-
- `api_key` from `
|
|
108
|
-
- `base_url` from `
|
|
106
|
+
- `api_key` from `SEEKR_API_KEY`
|
|
107
|
+
- `base_url` from `SEEKR_BASE_URL`
|
|
109
108
|
"""
|
|
110
109
|
|
|
111
110
|
# get api key
|
|
112
111
|
if not api_key:
|
|
113
|
-
api_key = os.environ.get("
|
|
112
|
+
api_key = os.environ.get("SEEKR_API_KEY")
|
|
114
113
|
|
|
115
114
|
if not api_key:
|
|
116
115
|
raise AuthenticationError(
|
|
117
116
|
"The api_key client option must be set either by passing api_key to the client or by setting the "
|
|
118
|
-
"
|
|
117
|
+
"SEEKR_API_KEY environment variable"
|
|
119
118
|
)
|
|
120
119
|
|
|
121
120
|
# get base url
|
|
122
121
|
if not base_url:
|
|
123
|
-
base_url = os.environ.get("
|
|
122
|
+
base_url = os.environ.get("SEEKR_BASE_URL")
|
|
124
123
|
|
|
125
124
|
if not base_url:
|
|
126
125
|
base_url = BASE_URL
|
|
@@ -134,7 +133,7 @@ class AsyncSeekrFlow:
|
|
|
134
133
|
# SeekrFlowClient object
|
|
135
134
|
self.client = SeekrFlowClient(
|
|
136
135
|
api_key=api_key,
|
|
137
|
-
base_url=enforce_trailing_slash(base_url),
|
|
136
|
+
base_url=enforce_trailing_slash(base_url), # type: ignore
|
|
138
137
|
timeout=timeout,
|
|
139
138
|
max_retries=max_retries,
|
|
140
139
|
supplied_headers=supplied_headers,
|
seekrai/constants.py
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Function to read from environment or default to hardcoded value
|
|
6
|
+
def env_or_default(var_name: str, default: Any) -> Any:
|
|
7
|
+
value = os.getenv(f"SEEKR_{var_name}")
|
|
8
|
+
if value is not None:
|
|
9
|
+
return value.split(",") if isinstance(default, list) else value
|
|
10
|
+
return default
|
|
11
|
+
|
|
12
|
+
|
|
1
13
|
# Session constants
|
|
2
|
-
TIMEOUT_SECS = 600
|
|
3
|
-
MAX_SESSION_LIFETIME_SECS = 180
|
|
4
|
-
MAX_CONNECTION_RETRIES = 2
|
|
5
|
-
MAX_RETRIES = 5
|
|
6
|
-
INITIAL_RETRY_DELAY = 0.5
|
|
7
|
-
MAX_RETRY_DELAY = 8.0
|
|
14
|
+
TIMEOUT_SECS = int(env_or_default("TIMEOUT_SECS", 600))
|
|
15
|
+
MAX_SESSION_LIFETIME_SECS = int(env_or_default("MAX_SESSION_LIFETIME_SECS", 180))
|
|
16
|
+
MAX_CONNECTION_RETRIES = int(env_or_default("MAX_CONNECTION_RETRIES", 2))
|
|
17
|
+
MAX_RETRIES = int(env_or_default("MAX_RETRIES", 5))
|
|
18
|
+
INITIAL_RETRY_DELAY = float(env_or_default("INITIAL_RETRY_DELAY", 0.5))
|
|
19
|
+
MAX_RETRY_DELAY = float(env_or_default("MAX_RETRY_DELAY", 8.0))
|
|
8
20
|
|
|
9
21
|
# API defaults
|
|
10
|
-
|
|
11
|
-
BASE_URL = "http://localhost:8000/v1"
|
|
22
|
+
BASE_URL = env_or_default("BASE_URL", "https://build.seekr.com/v1")
|
|
12
23
|
|
|
13
24
|
# Download defaults
|
|
14
|
-
DOWNLOAD_BLOCK_SIZE =
|
|
15
|
-
|
|
25
|
+
DOWNLOAD_BLOCK_SIZE = int(
|
|
26
|
+
env_or_default("DOWNLOAD_BLOCK_SIZE", 10 * 1024 * 1024)
|
|
27
|
+
) # 10 MB
|
|
28
|
+
DISABLE_TQDM = bool(
|
|
29
|
+
int(env_or_default("DISABLE_TQDM", 0))
|
|
30
|
+
) # Assumes DISABLE_TQDM set as 0 (False) or 1 (True)
|
|
16
31
|
|
|
17
32
|
# Messages
|
|
18
|
-
MISSING_API_KEY_MESSAGE =
|
|
33
|
+
MISSING_API_KEY_MESSAGE = env_or_default(
|
|
34
|
+
"MISSING_API_KEY_MESSAGE",
|
|
35
|
+
"""SEEKR_API_KEY not found.
|
|
19
36
|
Please set it as an environment variable or set it as seekrai.api_key
|
|
20
|
-
Find your SEEKR_API_KEY at https://seekr.com/xxx"""
|
|
37
|
+
Find your SEEKR_API_KEY at https://seekr.com/xxx""",
|
|
38
|
+
)
|
|
21
39
|
|
|
22
40
|
# Minimum number of samples required for fine-tuning file
|
|
23
|
-
MIN_SAMPLES = 100
|
|
41
|
+
MIN_SAMPLES = int(env_or_default("MIN_SAMPLES", 100))
|
|
24
42
|
|
|
25
43
|
# the number of bytes in a gigabyte, used to convert bytes to GB for readable comparison
|
|
26
|
-
NUM_BYTES_IN_GB = 2**30
|
|
44
|
+
NUM_BYTES_IN_GB = int(env_or_default("NUM_BYTES_IN_GB", 2**30))
|
|
27
45
|
|
|
28
46
|
# maximum number of GB sized files we support finetuning for
|
|
29
|
-
MAX_FILE_SIZE_GB = 4.9
|
|
47
|
+
MAX_FILE_SIZE_GB = float(env_or_default("MAX_FILE_SIZE_GB", 4.9))
|
|
30
48
|
|
|
31
49
|
# expected columns for Parquet files
|
|
32
|
-
PARQUET_EXPECTED_COLUMNS =
|
|
50
|
+
PARQUET_EXPECTED_COLUMNS = env_or_default(
|
|
51
|
+
"PARQUET_EXPECTED_COLUMNS", ["input_ids", "attention_mask", "labels"]
|
|
52
|
+
)
|
seekrai/error.py
CHANGED
|
@@ -79,14 +79,7 @@ class JSONError(SeekrFlowException):
|
|
|
79
79
|
class InstanceError(SeekrFlowException):
|
|
80
80
|
def __init__(self, model: str | None = "model", **kwargs: Any) -> None:
|
|
81
81
|
super().__init__(**kwargs)
|
|
82
|
-
self.message = f"""No running instances for {model}.
|
|
83
|
-
You can start an instance with one of the following methods:
|
|
84
|
-
1. navigating to the SeekrFlow Playground at api.seekrflow.ai
|
|
85
|
-
2. starting one in python using seekrflow.Models.start(model_name)
|
|
86
|
-
3. `$ seekrflow models start <MODEL_NAME>` at the command line.
|
|
87
|
-
See `seekrflow.Models.list()` in python or `$ seekrflow models list` in command line
|
|
88
|
-
to get an updated list of valid model names.
|
|
89
|
-
"""
|
|
82
|
+
self.message = f"""No running instances for {model}."""
|
|
90
83
|
|
|
91
84
|
|
|
92
85
|
class RateLimitError(SeekrFlowException):
|
seekrai/filemanager.py
CHANGED
|
@@ -5,19 +5,17 @@ import shutil
|
|
|
5
5
|
import stat
|
|
6
6
|
import tempfile
|
|
7
7
|
import uuid
|
|
8
|
-
from functools import partial
|
|
9
8
|
from pathlib import Path
|
|
10
9
|
from typing import Tuple
|
|
11
10
|
|
|
11
|
+
import httpx
|
|
12
12
|
import requests
|
|
13
|
-
from filelock import FileLock
|
|
14
13
|
from requests.structures import CaseInsensitiveDict
|
|
15
14
|
from tqdm import tqdm
|
|
16
|
-
from tqdm.utils import CallbackIOWrapper
|
|
17
15
|
|
|
18
16
|
import seekrai.utils
|
|
19
17
|
from seekrai.abstract import api_requestor
|
|
20
|
-
from seekrai.constants import DISABLE_TQDM
|
|
18
|
+
from seekrai.constants import DISABLE_TQDM
|
|
21
19
|
from seekrai.error import (
|
|
22
20
|
APIError,
|
|
23
21
|
AuthenticationError,
|
|
@@ -148,7 +146,6 @@ class DownloadManager:
|
|
|
148
146
|
url=url,
|
|
149
147
|
headers={"Range": "bytes=0-1"},
|
|
150
148
|
),
|
|
151
|
-
remaining_retries=MAX_RETRIES,
|
|
152
149
|
stream=False,
|
|
153
150
|
)
|
|
154
151
|
|
|
@@ -189,47 +186,43 @@ class DownloadManager:
|
|
|
189
186
|
url, output, remote_name, fetch_metadata
|
|
190
187
|
)
|
|
191
188
|
|
|
192
|
-
temp_file_manager = partial(
|
|
193
|
-
tempfile.NamedTemporaryFile, mode="wb", dir=file_path.parent, delete=False
|
|
194
|
-
)
|
|
195
|
-
|
|
196
189
|
# Prevent parallel downloads of the same file with a lock.
|
|
197
190
|
lock_path = Path(file_path.as_posix() + ".lock")
|
|
198
191
|
|
|
199
|
-
with
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
stream=True,
|
|
208
|
-
)
|
|
192
|
+
with tempfile.NamedTemporaryFile() as temp_file:
|
|
193
|
+
response = requestor.request_raw(
|
|
194
|
+
options=SeekrFlowRequest(
|
|
195
|
+
method="GET",
|
|
196
|
+
url=url,
|
|
197
|
+
),
|
|
198
|
+
stream=True,
|
|
199
|
+
)
|
|
209
200
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
201
|
+
try:
|
|
202
|
+
response.raise_for_status()
|
|
203
|
+
except Exception as e:
|
|
204
|
+
os.remove(lock_path)
|
|
205
|
+
raise APIError(
|
|
206
|
+
"Error downloading file", http_status=response.status_code
|
|
207
|
+
) from e
|
|
208
|
+
|
|
209
|
+
if not fetch_metadata:
|
|
210
|
+
file_size = int(response.headers.get("content-length", 0))
|
|
211
|
+
|
|
212
|
+
assert file_size != 0, "Unable to retrieve remote file."
|
|
213
|
+
|
|
214
|
+
with tqdm(
|
|
215
|
+
total=file_size,
|
|
216
|
+
unit="B",
|
|
217
|
+
unit_scale=True,
|
|
218
|
+
desc=f"Downloading file {file_path.name}",
|
|
219
|
+
disable=bool(DISABLE_TQDM),
|
|
220
|
+
) as pbar:
|
|
221
|
+
num_bytes_downloaded = response.num_bytes_downloaded
|
|
222
|
+
for chunk in response.iter_bytes():
|
|
223
|
+
temp_file.write(chunk)
|
|
224
|
+
pbar.update(response.num_bytes_downloaded - num_bytes_downloaded)
|
|
225
|
+
num_bytes_downloaded = response.num_bytes_downloaded
|
|
233
226
|
|
|
234
227
|
# Raise exception if remote file size does not match downloaded file size
|
|
235
228
|
if os.stat(temp_file.name).st_size != file_size:
|
|
@@ -252,7 +245,7 @@ class UploadManager:
|
|
|
252
245
|
|
|
253
246
|
@classmethod
|
|
254
247
|
def _redirect_error_handler(
|
|
255
|
-
cls, requestor: api_requestor.APIRequestor, response:
|
|
248
|
+
cls, requestor: api_requestor.APIRequestor, response: httpx.Response
|
|
256
249
|
) -> None:
|
|
257
250
|
if response.status_code == 401:
|
|
258
251
|
raise AuthenticationError(
|
|
@@ -296,7 +289,6 @@ class UploadManager:
|
|
|
296
289
|
override_headers=True,
|
|
297
290
|
headers=headers,
|
|
298
291
|
),
|
|
299
|
-
remaining_retries=MAX_RETRIES,
|
|
300
292
|
)
|
|
301
293
|
|
|
302
294
|
self._redirect_error_handler(requestor, response)
|
|
@@ -327,24 +319,16 @@ class UploadManager:
|
|
|
327
319
|
purpose: FilePurpose,
|
|
328
320
|
redirect: bool = False,
|
|
329
321
|
) -> FileResponse:
|
|
330
|
-
file_id = None
|
|
331
|
-
|
|
332
322
|
requestor = api_requestor.APIRequestor(
|
|
333
323
|
client=self._client,
|
|
334
324
|
)
|
|
335
325
|
|
|
336
|
-
redirect_url = None
|
|
337
326
|
if redirect:
|
|
338
|
-
if file.suffix
|
|
339
|
-
filetype = FileType.jsonl
|
|
340
|
-
elif file.suffix == ".parquet":
|
|
341
|
-
filetype = FileType.parquet
|
|
342
|
-
else:
|
|
327
|
+
if file.suffix not in [".jsonl", ".parquet", ".pt"]:
|
|
343
328
|
raise FileTypeError(
|
|
344
329
|
f"Unknown extension of file {file}. "
|
|
345
|
-
"Only files with extensions .jsonl and .
|
|
330
|
+
"Only files with extensions .jsonl, .parquet, and .pt are supported."
|
|
346
331
|
)
|
|
347
|
-
# redirect_url, file_id = self.get_upload_url(url, file, purpose, filetype)
|
|
348
332
|
|
|
349
333
|
file_size = os.stat(file.as_posix()).st_size
|
|
350
334
|
|
|
@@ -354,40 +338,17 @@ class UploadManager:
|
|
|
354
338
|
unit_scale=True,
|
|
355
339
|
desc=f"Uploading file {file.name}",
|
|
356
340
|
disable=bool(DISABLE_TQDM),
|
|
357
|
-
)
|
|
341
|
+
):
|
|
358
342
|
with file.open("rb") as f:
|
|
359
|
-
# wrapped_file = CallbackIOWrapper(pbar.update, f, "read")
|
|
360
|
-
|
|
361
|
-
# if redirect:
|
|
362
|
-
# callback_response = requestor.request_raw(
|
|
363
|
-
# options=SeekrFlowRequest(
|
|
364
|
-
# method="PUT",
|
|
365
|
-
# url=redirect_url,
|
|
366
|
-
# params=wrapped_file,
|
|
367
|
-
# override_headers=True,
|
|
368
|
-
# ),
|
|
369
|
-
# absolute=True,
|
|
370
|
-
# remaining_retries=MAX_RETRIES,
|
|
371
|
-
# )
|
|
372
|
-
# else:
|
|
373
343
|
response, _, _ = requestor.request(
|
|
374
344
|
options=SeekrFlowRequest(
|
|
375
345
|
method="PUT",
|
|
376
346
|
url=url,
|
|
377
347
|
files={"files": f, "filename": file.name},
|
|
348
|
+
params={"purpose": purpose.value},
|
|
378
349
|
),
|
|
379
350
|
)
|
|
380
351
|
|
|
381
|
-
# if redirect:
|
|
382
|
-
# assert isinstance(callback_response, requests.Response)
|
|
383
|
-
#
|
|
384
|
-
# if not callback_response.status_code == 200:
|
|
385
|
-
# raise APIError(
|
|
386
|
-
# f"Error code: {callback_response.status_code} - Failed to process uploaded file"
|
|
387
|
-
# )
|
|
388
|
-
#
|
|
389
|
-
# response = self.callback(f"{url}/{file_id}/preprocess")
|
|
390
|
-
|
|
391
352
|
assert isinstance(response, SeekrFlowResponse)
|
|
392
353
|
|
|
393
354
|
return FileResponse(**response.data)
|
|
@@ -22,7 +22,7 @@ class ChatCompletions:
|
|
|
22
22
|
*,
|
|
23
23
|
messages: List[Dict[str, str]],
|
|
24
24
|
model: str,
|
|
25
|
-
max_tokens: int | None =
|
|
25
|
+
max_tokens: int | None = 512,
|
|
26
26
|
stop: List[str] | None = None,
|
|
27
27
|
temperature: float = 0.7,
|
|
28
28
|
top_p: float = 1,
|
|
@@ -113,7 +113,7 @@ class ChatCompletions:
|
|
|
113
113
|
response, _, _ = requestor.request(
|
|
114
114
|
options=SeekrFlowRequest(
|
|
115
115
|
method="POST",
|
|
116
|
-
url="chat/completions",
|
|
116
|
+
url="inference/chat/completions",
|
|
117
117
|
params=parameter_payload,
|
|
118
118
|
),
|
|
119
119
|
stream=stream,
|
|
@@ -136,19 +136,19 @@ class AsyncChatCompletions:
|
|
|
136
136
|
*,
|
|
137
137
|
messages: List[Dict[str, str]],
|
|
138
138
|
model: str,
|
|
139
|
-
max_tokens: int | None =
|
|
139
|
+
max_tokens: int | None = 512,
|
|
140
140
|
stop: List[str] | None = None,
|
|
141
|
-
temperature: float
|
|
142
|
-
top_p: float
|
|
143
|
-
top_k: int
|
|
144
|
-
repetition_penalty: float
|
|
141
|
+
temperature: float = 0.7,
|
|
142
|
+
top_p: float = 1,
|
|
143
|
+
top_k: int = 5,
|
|
144
|
+
repetition_penalty: float = 1,
|
|
145
145
|
stream: bool = False,
|
|
146
|
-
logprobs: int
|
|
147
|
-
echo: bool
|
|
148
|
-
n: int
|
|
146
|
+
logprobs: int = 0,
|
|
147
|
+
echo: bool = False,
|
|
148
|
+
n: int = 1,
|
|
149
149
|
safety_model: str | None = None,
|
|
150
|
-
response_format: Dict[str, Any] | None = None,
|
|
151
|
-
# tools: Dict[str, str | Dict[str,
|
|
150
|
+
response_format: Dict[str, str | Dict[str, Any]] | None = None,
|
|
151
|
+
# tools: Dict[str, str | Dict[str, Any]] | None = None,
|
|
152
152
|
# tool_choice: str | Dict[str, str | Dict[str, str]] | None = None,
|
|
153
153
|
) -> AsyncGenerator[ChatCompletionChunk, None] | ChatCompletionResponse:
|
|
154
154
|
"""
|
|
@@ -227,7 +227,7 @@ class AsyncChatCompletions:
|
|
|
227
227
|
response, _, _ = await requestor.arequest(
|
|
228
228
|
options=SeekrFlowRequest(
|
|
229
229
|
method="POST",
|
|
230
|
-
url="chat/completions",
|
|
230
|
+
url="inference/chat/completions",
|
|
231
231
|
params=parameter_payload,
|
|
232
232
|
),
|
|
233
233
|
stream=stream,
|
seekrai/resources/completions.py
CHANGED
|
@@ -71,7 +71,7 @@ class Completions:
|
|
|
71
71
|
CompletionResponse | Iterator[CompletionChunk]: Object containing the completions
|
|
72
72
|
or an iterator over completion chunks.
|
|
73
73
|
"""
|
|
74
|
-
|
|
74
|
+
raise NotImplementedError("function not yet implemented")
|
|
75
75
|
requestor = api_requestor.APIRequestor(
|
|
76
76
|
client=self._client,
|
|
77
77
|
)
|
|
@@ -95,7 +95,7 @@ class Completions:
|
|
|
95
95
|
response, _, _ = requestor.request(
|
|
96
96
|
options=SeekrFlowRequest(
|
|
97
97
|
method="POST",
|
|
98
|
-
url="completions",
|
|
98
|
+
url="inference/completions",
|
|
99
99
|
params=parameter_payload,
|
|
100
100
|
),
|
|
101
101
|
stream=stream,
|
|
@@ -167,7 +167,7 @@ class AsyncCompletions:
|
|
|
167
167
|
AsyncGenerator[CompletionChunk, None] | CompletionResponse: Object containing the completions
|
|
168
168
|
or an iterator over completion chunks.
|
|
169
169
|
"""
|
|
170
|
-
|
|
170
|
+
raise NotImplementedError("function not yet implemented")
|
|
171
171
|
requestor = api_requestor.APIRequestor(
|
|
172
172
|
client=self._client,
|
|
173
173
|
)
|
|
@@ -191,7 +191,7 @@ class AsyncCompletions:
|
|
|
191
191
|
response, _, _ = await requestor.arequest(
|
|
192
192
|
options=SeekrFlowRequest(
|
|
193
193
|
method="POST",
|
|
194
|
-
url="completions",
|
|
194
|
+
url="inference/completions",
|
|
195
195
|
params=parameter_payload,
|
|
196
196
|
),
|
|
197
197
|
stream=stream,
|
seekrai/resources/embeddings.py
CHANGED
|
@@ -32,6 +32,7 @@ class Embeddings:
|
|
|
32
32
|
Returns:
|
|
33
33
|
EmbeddingResponse: Object containing embeddings
|
|
34
34
|
"""
|
|
35
|
+
raise NotImplementedError("Function not implemented yet")
|
|
35
36
|
|
|
36
37
|
requestor = api_requestor.APIRequestor(
|
|
37
38
|
client=self._client,
|
|
@@ -45,7 +46,7 @@ class Embeddings:
|
|
|
45
46
|
response, _, _ = requestor.request(
|
|
46
47
|
options=SeekrFlowRequest(
|
|
47
48
|
method="POST",
|
|
48
|
-
url="embeddings",
|
|
49
|
+
url="inference/embeddings",
|
|
49
50
|
params=parameter_payload,
|
|
50
51
|
),
|
|
51
52
|
stream=False,
|
|
@@ -76,6 +77,7 @@ class AsyncEmbeddings:
|
|
|
76
77
|
Returns:
|
|
77
78
|
EmbeddingResponse: Object containing embeddings
|
|
78
79
|
"""
|
|
80
|
+
raise NotImplementedError("Function not implemented yet")
|
|
79
81
|
|
|
80
82
|
requestor = api_requestor.APIRequestor(
|
|
81
83
|
client=self._client,
|
|
@@ -89,7 +91,7 @@ class AsyncEmbeddings:
|
|
|
89
91
|
response, _, _ = await requestor.arequest(
|
|
90
92
|
options=SeekrFlowRequest(
|
|
91
93
|
method="POST",
|
|
92
|
-
url="embeddings",
|
|
94
|
+
url="inference/embeddings",
|
|
93
95
|
params=parameter_payload,
|
|
94
96
|
),
|
|
95
97
|
stream=False,
|
seekrai/resources/files.py
CHANGED
|
@@ -34,7 +34,7 @@ class Files:
|
|
|
34
34
|
|
|
35
35
|
assert isinstance(purpose, FilePurpose)
|
|
36
36
|
|
|
37
|
-
return upload_manager.upload("files", file, purpose=purpose, redirect=True)
|
|
37
|
+
return upload_manager.upload("flow/files", file, purpose=purpose, redirect=True)
|
|
38
38
|
|
|
39
39
|
def list(self) -> FileList:
|
|
40
40
|
requestor = api_requestor.APIRequestor(
|
|
@@ -44,13 +44,21 @@ class Files:
|
|
|
44
44
|
response, _, _ = requestor.request(
|
|
45
45
|
options=SeekrFlowRequest(
|
|
46
46
|
method="GET",
|
|
47
|
-
url="files",
|
|
47
|
+
url="flow/files",
|
|
48
48
|
),
|
|
49
49
|
stream=False,
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
assert isinstance(response, SeekrFlowResponse)
|
|
53
|
-
files = [
|
|
53
|
+
files = [
|
|
54
|
+
FileResponse(
|
|
55
|
+
id=file["id"],
|
|
56
|
+
filename=file["filename"],
|
|
57
|
+
created_at=file["created_at"],
|
|
58
|
+
object="file",
|
|
59
|
+
)
|
|
60
|
+
for file in response.data["data"]
|
|
61
|
+
]
|
|
54
62
|
return FileList(object="list", data=files)
|
|
55
63
|
|
|
56
64
|
def retrieve(self, id: str) -> FileResponse:
|
|
@@ -61,7 +69,7 @@ class Files:
|
|
|
61
69
|
response, _, _ = requestor.request(
|
|
62
70
|
options=SeekrFlowRequest(
|
|
63
71
|
method="GET",
|
|
64
|
-
url=f"files/{id}",
|
|
72
|
+
url=f"flow/files/{id}",
|
|
65
73
|
),
|
|
66
74
|
stream=False,
|
|
67
75
|
)
|
|
@@ -79,7 +87,7 @@ class Files:
|
|
|
79
87
|
output = Path(output)
|
|
80
88
|
|
|
81
89
|
downloaded_filename, file_size = download_manager.download(
|
|
82
|
-
f"files/{id}/content", output, normalize_key(f"{id}.jsonl")
|
|
90
|
+
f"flow/files/{id}/content", output, normalize_key(f"{id}.jsonl")
|
|
83
91
|
)
|
|
84
92
|
|
|
85
93
|
return FileObject(
|
|
@@ -97,7 +105,7 @@ class Files:
|
|
|
97
105
|
response, _, _ = requestor.request(
|
|
98
106
|
options=SeekrFlowRequest(
|
|
99
107
|
method="DELETE",
|
|
100
|
-
url=f"files/{id}",
|
|
108
|
+
url=f"flow/files/{id}",
|
|
101
109
|
),
|
|
102
110
|
stream=False,
|
|
103
111
|
)
|
|
@@ -124,7 +132,7 @@ class AsyncFiles:
|
|
|
124
132
|
response, _, _ = await requestor.arequest(
|
|
125
133
|
options=SeekrFlowRequest(
|
|
126
134
|
method="GET",
|
|
127
|
-
url="files",
|
|
135
|
+
url="flow/files",
|
|
128
136
|
),
|
|
129
137
|
stream=False,
|
|
130
138
|
)
|
|
@@ -141,7 +149,7 @@ class AsyncFiles:
|
|
|
141
149
|
response, _, _ = await requestor.arequest(
|
|
142
150
|
options=SeekrFlowRequest(
|
|
143
151
|
method="GET",
|
|
144
|
-
url=f"files/{id}",
|
|
152
|
+
url=f"flow/files/{id}",
|
|
145
153
|
),
|
|
146
154
|
stream=False,
|
|
147
155
|
)
|
|
@@ -163,7 +171,7 @@ class AsyncFiles:
|
|
|
163
171
|
response, _, _ = await requestor.arequest(
|
|
164
172
|
options=SeekrFlowRequest(
|
|
165
173
|
method="DELETE",
|
|
166
|
-
url=f"files/{id}",
|
|
174
|
+
url=f"flow/files/{id}",
|
|
167
175
|
),
|
|
168
176
|
stream=False,
|
|
169
177
|
)
|