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/legacy/files.py
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import warnings
|
|
5
|
-
from typing import Any, Dict, List
|
|
6
|
-
|
|
7
|
-
import seekrai
|
|
8
|
-
from seekrai.legacy.base import API_KEY_WARNING, deprecated
|
|
9
|
-
from seekrai.utils.files import check_file as check_json
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Files:
|
|
13
|
-
@classmethod
|
|
14
|
-
@deprecated # type: ignore
|
|
15
|
-
def list(
|
|
16
|
-
cls,
|
|
17
|
-
) -> Dict[str, Any]:
|
|
18
|
-
"""Legacy file list function."""
|
|
19
|
-
|
|
20
|
-
api_key = None
|
|
21
|
-
if seekrai.api_key:
|
|
22
|
-
warnings.warn(API_KEY_WARNING)
|
|
23
|
-
api_key = seekrai.api_key
|
|
24
|
-
|
|
25
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
26
|
-
|
|
27
|
-
return client.files.list().model_dump()
|
|
28
|
-
|
|
29
|
-
@classmethod
|
|
30
|
-
def check(self, file: str) -> Dict[str, object]:
|
|
31
|
-
return check_json(file)
|
|
32
|
-
|
|
33
|
-
@classmethod
|
|
34
|
-
@deprecated # type: ignore
|
|
35
|
-
def upload(
|
|
36
|
-
cls,
|
|
37
|
-
file: str,
|
|
38
|
-
check: bool = True,
|
|
39
|
-
) -> Dict[str, Any]:
|
|
40
|
-
"""Legacy file upload function."""
|
|
41
|
-
|
|
42
|
-
api_key = None
|
|
43
|
-
if seekrai.api_key:
|
|
44
|
-
warnings.warn(API_KEY_WARNING)
|
|
45
|
-
api_key = seekrai.api_key
|
|
46
|
-
|
|
47
|
-
if check:
|
|
48
|
-
report_dict = check_json(file)
|
|
49
|
-
if not report_dict["is_check_passed"]:
|
|
50
|
-
raise seekrai.error.FileTypeError(
|
|
51
|
-
f"Invalid file supplied. Failed to upload.\nReport:\n {report_dict}"
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
55
|
-
|
|
56
|
-
response = client.files.upload(file=file).model_dump()
|
|
57
|
-
|
|
58
|
-
response["report_dict"] = report_dict
|
|
59
|
-
|
|
60
|
-
return response
|
|
61
|
-
|
|
62
|
-
@classmethod
|
|
63
|
-
@deprecated # type: ignore
|
|
64
|
-
def delete(
|
|
65
|
-
cls,
|
|
66
|
-
file_id: str,
|
|
67
|
-
) -> Dict[str, Any]:
|
|
68
|
-
"""Legacy file delete function."""
|
|
69
|
-
|
|
70
|
-
api_key = None
|
|
71
|
-
if seekrai.api_key:
|
|
72
|
-
warnings.warn(API_KEY_WARNING)
|
|
73
|
-
api_key = seekrai.api_key
|
|
74
|
-
|
|
75
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
76
|
-
|
|
77
|
-
return client.files.delete(id=file_id).model_dump()
|
|
78
|
-
|
|
79
|
-
@classmethod
|
|
80
|
-
@deprecated # type: ignore
|
|
81
|
-
def retrieve(
|
|
82
|
-
cls,
|
|
83
|
-
file_id: str,
|
|
84
|
-
) -> Dict[str, Any]:
|
|
85
|
-
"""Legacy file retrieve function."""
|
|
86
|
-
|
|
87
|
-
api_key = None
|
|
88
|
-
if seekrai.api_key:
|
|
89
|
-
warnings.warn(API_KEY_WARNING)
|
|
90
|
-
api_key = seekrai.api_key
|
|
91
|
-
|
|
92
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
93
|
-
|
|
94
|
-
return client.files.retrieve(id=file_id).model_dump()
|
|
95
|
-
|
|
96
|
-
@classmethod
|
|
97
|
-
@deprecated # type: ignore
|
|
98
|
-
def retrieve_content(
|
|
99
|
-
cls,
|
|
100
|
-
file_id: str,
|
|
101
|
-
output: str | None = None,
|
|
102
|
-
) -> Dict[str, Any]:
|
|
103
|
-
"""Legacy file retrieve content function."""
|
|
104
|
-
|
|
105
|
-
api_key = None
|
|
106
|
-
if seekrai.api_key:
|
|
107
|
-
warnings.warn(API_KEY_WARNING)
|
|
108
|
-
api_key = seekrai.api_key
|
|
109
|
-
|
|
110
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
111
|
-
|
|
112
|
-
return client.files.retrieve_content(id=file_id, output=output).model_dump()
|
|
113
|
-
|
|
114
|
-
@classmethod
|
|
115
|
-
@deprecated # type: ignore
|
|
116
|
-
def save_jsonl(
|
|
117
|
-
self, data: Dict[str, str], output_path: str, append: bool = False
|
|
118
|
-
) -> None:
|
|
119
|
-
"""
|
|
120
|
-
Write list of objects to a JSON lines file.
|
|
121
|
-
"""
|
|
122
|
-
mode = "a+" if append else "w"
|
|
123
|
-
with open(output_path, mode, encoding="utf-8") as f:
|
|
124
|
-
for line in data:
|
|
125
|
-
json_record = json.dumps(line, ensure_ascii=False)
|
|
126
|
-
f.write(json_record + "\n")
|
|
127
|
-
print("Wrote {} records to {}".format(len(data), output_path))
|
|
128
|
-
|
|
129
|
-
@classmethod
|
|
130
|
-
@deprecated # type: ignore
|
|
131
|
-
def load_jsonl(self, input_path: str) -> List[Dict[str, str]]:
|
|
132
|
-
"""
|
|
133
|
-
Read list of objects from a JSON lines file.
|
|
134
|
-
"""
|
|
135
|
-
data = []
|
|
136
|
-
with open(input_path, "r", encoding="utf-8") as f:
|
|
137
|
-
for line in f:
|
|
138
|
-
data.append(json.loads(line.rstrip("\n|\r")))
|
|
139
|
-
print("Loaded {} records from {}".format(len(data), input_path))
|
|
140
|
-
return data
|
seekrai/legacy/finetune.py
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import warnings
|
|
4
|
-
from typing import Any, Dict, List
|
|
5
|
-
|
|
6
|
-
import seekrai
|
|
7
|
-
from seekrai.legacy.base import API_KEY_WARNING, deprecated
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Finetune:
|
|
11
|
-
@classmethod
|
|
12
|
-
@deprecated # type: ignore
|
|
13
|
-
def create(
|
|
14
|
-
cls,
|
|
15
|
-
training_file: str, # training file_id
|
|
16
|
-
model: str,
|
|
17
|
-
n_epochs: int = 1,
|
|
18
|
-
n_checkpoints: int | None = 1,
|
|
19
|
-
batch_size: int | None = 32,
|
|
20
|
-
learning_rate: float = 0.00001,
|
|
21
|
-
suffix: (
|
|
22
|
-
str | None
|
|
23
|
-
) = None, # resulting finetuned model name will include the suffix
|
|
24
|
-
estimate_price: bool = False,
|
|
25
|
-
wandb_api_key: str | None = None,
|
|
26
|
-
confirm_inputs: bool = False,
|
|
27
|
-
):
|
|
28
|
-
api_key = None
|
|
29
|
-
if seekrai.api_key:
|
|
30
|
-
warnings.warn(API_KEY_WARNING)
|
|
31
|
-
api_key = seekrai.api_key
|
|
32
|
-
|
|
33
|
-
if estimate_price:
|
|
34
|
-
raise ValueError("Price estimation is not supported in version >= 1.0.1")
|
|
35
|
-
|
|
36
|
-
if confirm_inputs:
|
|
37
|
-
raise ValueError("Input confirmation is not supported in version >= 1.0.1")
|
|
38
|
-
|
|
39
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
40
|
-
|
|
41
|
-
return client.fine_tuning.create(
|
|
42
|
-
training_file=training_file,
|
|
43
|
-
model=model,
|
|
44
|
-
n_epochs=n_epochs,
|
|
45
|
-
n_checkpoints=n_checkpoints,
|
|
46
|
-
batch_size=batch_size,
|
|
47
|
-
learning_rate=learning_rate,
|
|
48
|
-
suffix=suffix,
|
|
49
|
-
wandb_api_key=wandb_api_key,
|
|
50
|
-
).model_dump()
|
|
51
|
-
|
|
52
|
-
@classmethod
|
|
53
|
-
@deprecated # type: ignore
|
|
54
|
-
def list(
|
|
55
|
-
cls,
|
|
56
|
-
) -> Dict[str, Any]:
|
|
57
|
-
"""Legacy finetuning list function."""
|
|
58
|
-
|
|
59
|
-
api_key = None
|
|
60
|
-
if seekrai.api_key:
|
|
61
|
-
warnings.warn(API_KEY_WARNING)
|
|
62
|
-
api_key = seekrai.api_key
|
|
63
|
-
|
|
64
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
65
|
-
|
|
66
|
-
return client.fine_tuning.list().model_dump()
|
|
67
|
-
|
|
68
|
-
@classmethod
|
|
69
|
-
@deprecated # type: ignore
|
|
70
|
-
def retrieve(
|
|
71
|
-
cls,
|
|
72
|
-
fine_tune_id: str,
|
|
73
|
-
) -> Dict[str, Any]:
|
|
74
|
-
"""Legacy finetuning retrieve function."""
|
|
75
|
-
|
|
76
|
-
api_key = None
|
|
77
|
-
if seekrai.api_key:
|
|
78
|
-
warnings.warn(API_KEY_WARNING)
|
|
79
|
-
api_key = seekrai.api_key
|
|
80
|
-
|
|
81
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
82
|
-
|
|
83
|
-
return client.fine_tuning.retrieve(id=fine_tune_id).model_dump()
|
|
84
|
-
|
|
85
|
-
@classmethod
|
|
86
|
-
@deprecated # type: ignore
|
|
87
|
-
def cancel(
|
|
88
|
-
cls,
|
|
89
|
-
fine_tune_id: str,
|
|
90
|
-
) -> Dict[str, Any]:
|
|
91
|
-
"""Legacy finetuning cancel function."""
|
|
92
|
-
|
|
93
|
-
api_key = None
|
|
94
|
-
if seekrai.api_key:
|
|
95
|
-
warnings.warn(API_KEY_WARNING)
|
|
96
|
-
api_key = seekrai.api_key
|
|
97
|
-
|
|
98
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
99
|
-
|
|
100
|
-
return client.fine_tuning.cancel(id=fine_tune_id).model_dump()
|
|
101
|
-
|
|
102
|
-
@classmethod
|
|
103
|
-
@deprecated # type: ignore
|
|
104
|
-
def list_events(
|
|
105
|
-
cls,
|
|
106
|
-
fine_tune_id: str,
|
|
107
|
-
) -> Dict[str, Any]:
|
|
108
|
-
"""Legacy finetuning list events function."""
|
|
109
|
-
|
|
110
|
-
api_key = None
|
|
111
|
-
if seekrai.api_key:
|
|
112
|
-
warnings.warn(API_KEY_WARNING)
|
|
113
|
-
api_key = seekrai.api_key
|
|
114
|
-
|
|
115
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
116
|
-
|
|
117
|
-
return client.fine_tuning.list_events(id=fine_tune_id).model_dump()
|
|
118
|
-
|
|
119
|
-
@classmethod
|
|
120
|
-
@deprecated # type: ignore
|
|
121
|
-
def get_checkpoints(
|
|
122
|
-
cls,
|
|
123
|
-
fine_tune_id: str,
|
|
124
|
-
) -> List[Any]:
|
|
125
|
-
"""Legacy finetuning get checkpoints function."""
|
|
126
|
-
|
|
127
|
-
finetune_events = list(cls.retrieve(fine_tune_id=fine_tune_id)["events"])
|
|
128
|
-
|
|
129
|
-
saved_events = [i for i in finetune_events if i["type"] in ["CHECKPOINT_SAVE"]]
|
|
130
|
-
|
|
131
|
-
return saved_events
|
|
132
|
-
|
|
133
|
-
@classmethod
|
|
134
|
-
@deprecated # type: ignore
|
|
135
|
-
def get_job_status(cls, fine_tune_id: str) -> str:
|
|
136
|
-
"""Legacy finetuning get job status function."""
|
|
137
|
-
return str(cls.retrieve(fine_tune_id=fine_tune_id)["status"])
|
|
138
|
-
|
|
139
|
-
@classmethod
|
|
140
|
-
@deprecated # type: ignore
|
|
141
|
-
def is_final_model_available(cls, fine_tune_id: str) -> bool:
|
|
142
|
-
"""Legacy finetuning is final model available function."""
|
|
143
|
-
|
|
144
|
-
finetune_events = list(cls.retrieve(fine_tune_id=fine_tune_id)["events"])
|
|
145
|
-
|
|
146
|
-
for i in finetune_events:
|
|
147
|
-
if i["type"] in ["JOB_COMPLETE", "JOB_ERROR"]:
|
|
148
|
-
if i["checkpoint_path"] != "":
|
|
149
|
-
return False
|
|
150
|
-
else:
|
|
151
|
-
return True
|
|
152
|
-
return False
|
|
153
|
-
|
|
154
|
-
@classmethod
|
|
155
|
-
@deprecated # type: ignore
|
|
156
|
-
def download(
|
|
157
|
-
cls,
|
|
158
|
-
fine_tune_id: str,
|
|
159
|
-
output: str | None = None,
|
|
160
|
-
step: int = -1,
|
|
161
|
-
) -> Dict[str, Any]:
|
|
162
|
-
"""Legacy finetuning download function."""
|
|
163
|
-
|
|
164
|
-
api_key = None
|
|
165
|
-
if seekrai.api_key:
|
|
166
|
-
warnings.warn(API_KEY_WARNING)
|
|
167
|
-
api_key = seekrai.api_key
|
|
168
|
-
|
|
169
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
170
|
-
|
|
171
|
-
return client.fine_tuning.download(
|
|
172
|
-
id=fine_tune_id, output=output, checkpoint_step=step
|
|
173
|
-
).model_dump()
|
seekrai/legacy/images.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
from typing import Any, Dict
|
|
3
|
-
|
|
4
|
-
import seekrai
|
|
5
|
-
from seekrai.legacy.base import API_KEY_WARNING, deprecated
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Image:
|
|
9
|
-
@classmethod
|
|
10
|
-
@deprecated # type: ignore
|
|
11
|
-
def create(
|
|
12
|
-
cls,
|
|
13
|
-
prompt: str,
|
|
14
|
-
**kwargs,
|
|
15
|
-
) -> Dict[str, Any]:
|
|
16
|
-
"""Legacy image function."""
|
|
17
|
-
|
|
18
|
-
api_key = None
|
|
19
|
-
if seekrai.api_key:
|
|
20
|
-
warnings.warn(API_KEY_WARNING)
|
|
21
|
-
api_key = seekrai.api_key
|
|
22
|
-
|
|
23
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
24
|
-
|
|
25
|
-
return client.images.generate(prompt=prompt, **kwargs).model_dump()
|
seekrai/legacy/models.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
from typing import Any, Dict, List
|
|
3
|
-
|
|
4
|
-
import seekrai
|
|
5
|
-
from seekrai.legacy.base import API_KEY_WARNING, deprecated
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Models:
|
|
9
|
-
@classmethod
|
|
10
|
-
@deprecated # type: ignore
|
|
11
|
-
def list(
|
|
12
|
-
cls,
|
|
13
|
-
) -> List[Dict[str, Any]]:
|
|
14
|
-
"""Legacy model list function."""
|
|
15
|
-
|
|
16
|
-
api_key = None
|
|
17
|
-
if seekrai.api_key:
|
|
18
|
-
warnings.warn(API_KEY_WARNING)
|
|
19
|
-
api_key = seekrai.api_key
|
|
20
|
-
|
|
21
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
22
|
-
|
|
23
|
-
return [item.model_dump() for item in client.models.list()]
|
|
24
|
-
|
|
25
|
-
@classmethod
|
|
26
|
-
@deprecated # type: ignore
|
|
27
|
-
def info(
|
|
28
|
-
cls,
|
|
29
|
-
model: str,
|
|
30
|
-
) -> Dict[str, Any]:
|
|
31
|
-
"""Legacy model info function."""
|
|
32
|
-
|
|
33
|
-
api_key = None
|
|
34
|
-
if seekrai.api_key:
|
|
35
|
-
warnings.warn(API_KEY_WARNING)
|
|
36
|
-
api_key = seekrai.api_key
|
|
37
|
-
|
|
38
|
-
client = seekrai.SeekrFlow(api_key=api_key)
|
|
39
|
-
|
|
40
|
-
model_list = client.models.list()
|
|
41
|
-
|
|
42
|
-
for item in model_list:
|
|
43
|
-
if item.id == model:
|
|
44
|
-
return item.model_dump()
|