seekrai 0.0.1__tar.gz → 0.1.0__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.
Files changed (60) hide show
  1. seekrai-0.1.0/PKG-INFO +169 -0
  2. seekrai-0.1.0/README.md +135 -0
  3. {seekrai-0.0.1 → seekrai-0.1.0}/pyproject.toml +4 -5
  4. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/__init__.py +0 -15
  5. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/abstract/api_requestor.py +121 -297
  6. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/client.py +10 -11
  7. seekrai-0.1.0/src/seekrai/constants.py +52 -0
  8. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/error.py +1 -8
  9. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/filemanager.py +40 -79
  10. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/chat/completions.py +13 -13
  11. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/completions.py +4 -4
  12. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/embeddings.py +4 -2
  13. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/files.py +17 -9
  14. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/finetune.py +57 -82
  15. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/images.py +2 -2
  16. seekrai-0.1.0/src/seekrai/resources/models.py +175 -0
  17. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/__init__.py +5 -4
  18. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/common.py +1 -2
  19. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/files.py +23 -19
  20. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/finetune.py +20 -26
  21. seekrai-0.1.0/src/seekrai/types/models.py +49 -0
  22. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/utils/_log.py +3 -3
  23. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/utils/api_helpers.py +2 -2
  24. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/utils/tools.py +1 -1
  25. seekrai-0.0.1/PKG-INFO +0 -401
  26. seekrai-0.0.1/README.md +0 -365
  27. seekrai-0.0.1/src/seekrai/cli/__init__.py +0 -0
  28. seekrai-0.0.1/src/seekrai/cli/api/__init__.py +0 -0
  29. seekrai-0.0.1/src/seekrai/cli/api/chat.py +0 -245
  30. seekrai-0.0.1/src/seekrai/cli/api/completions.py +0 -107
  31. seekrai-0.0.1/src/seekrai/cli/api/files.py +0 -125
  32. seekrai-0.0.1/src/seekrai/cli/api/finetune.py +0 -175
  33. seekrai-0.0.1/src/seekrai/cli/api/images.py +0 -82
  34. seekrai-0.0.1/src/seekrai/cli/api/models.py +0 -42
  35. seekrai-0.0.1/src/seekrai/cli/cli.py +0 -77
  36. seekrai-0.0.1/src/seekrai/constants.py +0 -32
  37. seekrai-0.0.1/src/seekrai/legacy/__init__.py +0 -0
  38. seekrai-0.0.1/src/seekrai/legacy/base.py +0 -27
  39. seekrai-0.0.1/src/seekrai/legacy/complete.py +0 -91
  40. seekrai-0.0.1/src/seekrai/legacy/embeddings.py +0 -25
  41. seekrai-0.0.1/src/seekrai/legacy/files.py +0 -140
  42. seekrai-0.0.1/src/seekrai/legacy/finetune.py +0 -173
  43. seekrai-0.0.1/src/seekrai/legacy/images.py +0 -25
  44. seekrai-0.0.1/src/seekrai/legacy/models.py +0 -44
  45. seekrai-0.0.1/src/seekrai/resources/models.py +0 -75
  46. seekrai-0.0.1/src/seekrai/types/models.py +0 -43
  47. {seekrai-0.0.1 → seekrai-0.1.0}/LICENSE +0 -0
  48. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/abstract/__init__.py +0 -0
  49. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/__init__.py +0 -0
  50. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/resources/chat/__init__.py +0 -0
  51. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/seekrflow_response.py +0 -0
  52. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/abstract.py +0 -0
  53. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/chat_completions.py +0 -0
  54. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/completions.py +0 -0
  55. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/embeddings.py +0 -0
  56. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/error.py +0 -0
  57. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/types/images.py +0 -0
  58. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/utils/__init__.py +0 -0
  59. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/utils/files.py +0 -0
  60. {seekrai-0.0.1 → seekrai-0.1.0}/src/seekrai/version.py +0 -0
seekrai-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.1
2
+ Name: seekrai
3
+ Version: 0.1.0
4
+ Summary: Python client for SeekrAI
5
+ Home-page: https://gitlab.cb.ntent.com/ml/seekr-py
6
+ License: Apache-2.0
7
+ Author: SeekrFlow
8
+ Author-email: support@seekr.com
9
+ Requires-Python: >=3.9,<4.0
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Dist: click (>=8.1.7,<9.0.0)
18
+ Requires-Dist: eval-type-backport (>=0.1.3,<0.3.0)
19
+ Requires-Dist: filelock (>=3.13.1,<4.0.0)
20
+ Requires-Dist: httpx (>=0.27.0,<0.28.0)
21
+ Requires-Dist: numpy (>=1.23.5) ; python_version < "3.12"
22
+ Requires-Dist: numpy (>=1.26.0) ; python_version >= "3.12"
23
+ Requires-Dist: pillow (>=10.3.0,<11.0.0)
24
+ Requires-Dist: pyarrow (>=10.0.1)
25
+ Requires-Dist: pydantic (>=2.7,<3.0)
26
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
27
+ Requires-Dist: tabulate (>=0.9.0,<0.10.0)
28
+ Requires-Dist: tqdm (>=4.66.2,<5.0.0)
29
+ Requires-Dist: typer (>=0.9,<0.13)
30
+ Project-URL: Homepage, https://www.seekr.com/
31
+ Project-URL: Repository, https://gitlab.cb.ntent.com/ml/seekr-py
32
+ Description-Content-Type: text/markdown
33
+
34
+ The Seekr Python Library is the official Python client for SeekrFlow's API platform, providing a convenient way for interacting with the REST APIs and enables easy integrations with Python 3.8+ applications with easy to use synchronous and asynchronous clients.
35
+
36
+ # Installation
37
+
38
+ To install Seekr Python Library from PyPi, simply run:
39
+
40
+ ```shell Shell
41
+ pip install --upgrade seekrai
42
+ ```
43
+
44
+ ## Setting up API Key
45
+
46
+ > 🚧 You will need to create an account with [Seekr.com](https://seekr.com/) to obtain a SeekrFlow API Key.
47
+
48
+ ### Setting environment variable
49
+
50
+ ```shell
51
+ export SEEKR_API_KEY=xxxxx
52
+ ```
53
+
54
+ ### Using the client
55
+
56
+ ```python
57
+ from seekrai import SeekrFlow
58
+
59
+ client = SeekrFlow(api_key="xxxxx")
60
+ ```
61
+
62
+ This library contains both a python library and a CLI. We'll demonstrate how to use both below.
63
+
64
+ # Usage – Python Client
65
+
66
+ ## Chat Completions
67
+
68
+ ```python
69
+ import os
70
+ from seekrai import SeekrFlow
71
+
72
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
73
+
74
+ response = client.chat.completions.create(
75
+ model="meta-llama-3-8b-instruct",
76
+ messages=[{"role": "user", "content": "tell me about new york"}],
77
+ )
78
+ print(response.choices[0].message.content)
79
+ ```
80
+
81
+ ### Streaming
82
+
83
+ ```python
84
+ import os
85
+ from seekrai import SeekrFlow
86
+
87
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
88
+ stream = client.chat.completions.create(
89
+ model="meta-llama-3-8b-instruct",
90
+ messages=[{"role": "user", "content": "tell me about new york"}],
91
+ stream=True,
92
+ )
93
+
94
+ for chunk in stream:
95
+ print(chunk.choices[0].delta.content or "", end="", flush=True)
96
+ ```
97
+
98
+ ### Async usage
99
+
100
+ ```python
101
+ import os, asyncio
102
+ from seekrai import AsyncSeekrFlow
103
+
104
+ async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
105
+ messages = [
106
+ "What are the top things to do in San Francisco?",
107
+ "What country is Paris in?",
108
+ ]
109
+
110
+
111
+ async def async_chat_completion(messages):
112
+ async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
113
+ tasks = [
114
+ async_client.chat.completions.create(
115
+ model="meta-llama-3-8b-instruct",
116
+ messages=[{"role": "user", "content": message}],
117
+ )
118
+ for message in messages
119
+ ]
120
+ responses = await asyncio.gather(*tasks)
121
+
122
+ for response in responses:
123
+ print(response.choices[0].message.content)
124
+
125
+
126
+ asyncio.run(async_chat_completion(messages))
127
+ ```
128
+
129
+ ## Files
130
+
131
+ The files API is used for fine-tuning and allows developers to upload data to fine-tune on. It also has several methods to list all files, retrive files, and delete files. Please refer to our fine-tuning docs [here](https://docs.seekrflow.ai/docs/fine-tuning-python).
132
+
133
+ ```python
134
+ import os
135
+ from seekrai import SeekrFlow
136
+
137
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
138
+
139
+ client.files.upload(file="somedata.jsonl") # uploads a file
140
+ client.files.list() # lists all uploaded files
141
+ client.files.retrieve(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # retrieves a specific file
142
+ client.files.delete(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # deletes a file
143
+ ```
144
+
145
+ ## Fine-tunes
146
+
147
+ The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.seekrflow.ai/docs/fine-tuning-python).
148
+
149
+ ```python
150
+ import os
151
+ from seekrai import SeekrFlow
152
+
153
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
154
+
155
+ client.fine_tuning.create(
156
+ training_file='file-d0d318cb-b7d9-493a-bd70-1cfe089d3815',
157
+ model='meta-llama-3-8b-instruct',
158
+ n_epochs=3,
159
+ n_checkpoints=1,
160
+ batch_size=4,
161
+ learning_rate=1e-5,
162
+ suffix='my-demo-finetune',
163
+ wandb_api_key='1a2b3c4d5e.......',
164
+ )
165
+ client.fine_tuning.list() # lists all fine-tuned jobs
166
+ client.fine_tuning.retrieve(id="ft-c66a5c18-1d6d-43c9-94bd-32d756425b4b") # retrieves information on finetune event
167
+ client.fine_tuning.list_events(id="ft-c66a5c18-1d6d-43c9-94bd-32d756425b4b") # Lists events of a fine-tune job
168
+ ```
169
+
@@ -0,0 +1,135 @@
1
+ The Seekr Python Library is the official Python client for SeekrFlow's API platform, providing a convenient way for interacting with the REST APIs and enables easy integrations with Python 3.8+ applications with easy to use synchronous and asynchronous clients.
2
+
3
+ # Installation
4
+
5
+ To install Seekr Python Library from PyPi, simply run:
6
+
7
+ ```shell Shell
8
+ pip install --upgrade seekrai
9
+ ```
10
+
11
+ ## Setting up API Key
12
+
13
+ > 🚧 You will need to create an account with [Seekr.com](https://seekr.com/) to obtain a SeekrFlow API Key.
14
+
15
+ ### Setting environment variable
16
+
17
+ ```shell
18
+ export SEEKR_API_KEY=xxxxx
19
+ ```
20
+
21
+ ### Using the client
22
+
23
+ ```python
24
+ from seekrai import SeekrFlow
25
+
26
+ client = SeekrFlow(api_key="xxxxx")
27
+ ```
28
+
29
+ This library contains both a python library and a CLI. We'll demonstrate how to use both below.
30
+
31
+ # Usage – Python Client
32
+
33
+ ## Chat Completions
34
+
35
+ ```python
36
+ import os
37
+ from seekrai import SeekrFlow
38
+
39
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
40
+
41
+ response = client.chat.completions.create(
42
+ model="meta-llama-3-8b-instruct",
43
+ messages=[{"role": "user", "content": "tell me about new york"}],
44
+ )
45
+ print(response.choices[0].message.content)
46
+ ```
47
+
48
+ ### Streaming
49
+
50
+ ```python
51
+ import os
52
+ from seekrai import SeekrFlow
53
+
54
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
55
+ stream = client.chat.completions.create(
56
+ model="meta-llama-3-8b-instruct",
57
+ messages=[{"role": "user", "content": "tell me about new york"}],
58
+ stream=True,
59
+ )
60
+
61
+ for chunk in stream:
62
+ print(chunk.choices[0].delta.content or "", end="", flush=True)
63
+ ```
64
+
65
+ ### Async usage
66
+
67
+ ```python
68
+ import os, asyncio
69
+ from seekrai import AsyncSeekrFlow
70
+
71
+ async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
72
+ messages = [
73
+ "What are the top things to do in San Francisco?",
74
+ "What country is Paris in?",
75
+ ]
76
+
77
+
78
+ async def async_chat_completion(messages):
79
+ async_client = AsyncSeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
80
+ tasks = [
81
+ async_client.chat.completions.create(
82
+ model="meta-llama-3-8b-instruct",
83
+ messages=[{"role": "user", "content": message}],
84
+ )
85
+ for message in messages
86
+ ]
87
+ responses = await asyncio.gather(*tasks)
88
+
89
+ for response in responses:
90
+ print(response.choices[0].message.content)
91
+
92
+
93
+ asyncio.run(async_chat_completion(messages))
94
+ ```
95
+
96
+ ## Files
97
+
98
+ The files API is used for fine-tuning and allows developers to upload data to fine-tune on. It also has several methods to list all files, retrive files, and delete files. Please refer to our fine-tuning docs [here](https://docs.seekrflow.ai/docs/fine-tuning-python).
99
+
100
+ ```python
101
+ import os
102
+ from seekrai import SeekrFlow
103
+
104
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
105
+
106
+ client.files.upload(file="somedata.jsonl") # uploads a file
107
+ client.files.list() # lists all uploaded files
108
+ client.files.retrieve(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # retrieves a specific file
109
+ client.files.delete(id="file-d0d318cb-b7d9-493a-bd70-1cfe089d3815") # deletes a file
110
+ ```
111
+
112
+ ## Fine-tunes
113
+
114
+ The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs [here](https://docs.seekrflow.ai/docs/fine-tuning-python).
115
+
116
+ ```python
117
+ import os
118
+ from seekrai import SeekrFlow
119
+
120
+ client = SeekrFlow(api_key=os.environ.get("SEEKR_API_KEY"))
121
+
122
+ client.fine_tuning.create(
123
+ training_file='file-d0d318cb-b7d9-493a-bd70-1cfe089d3815',
124
+ model='meta-llama-3-8b-instruct',
125
+ n_epochs=3,
126
+ n_checkpoints=1,
127
+ batch_size=4,
128
+ learning_rate=1e-5,
129
+ suffix='my-demo-finetune',
130
+ wandb_api_key='1a2b3c4d5e.......',
131
+ )
132
+ client.fine_tuning.list() # lists all fine-tuned jobs
133
+ client.fine_tuning.retrieve(id="ft-c66a5c18-1d6d-43c9-94bd-32d756425b4b") # retrieves information on finetune event
134
+ client.fine_tuning.list_events(id="ft-c66a5c18-1d6d-43c9-94bd-32d756425b4b") # Lists events of a fine-tune job
135
+ ```
@@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"
14
14
 
15
15
  [tool.poetry]
16
16
  name = "seekrai"
17
- version = "0.0.1"
17
+ version = "0.1.0"
18
18
  authors = [
19
19
  "SeekrFlow <support@seekr.com>"
20
20
  ]
@@ -31,13 +31,12 @@ homepage = "https://gitlab.cb.ntent.com/ml/seekr-py"
31
31
 
32
32
 
33
33
  [tool.poetry.dependencies]
34
- python = "^3.8"
34
+ python = "^3.9"
35
35
  typer = ">=0.9,<0.13"
36
36
  requests = "^2.31.0"
37
37
  tqdm = "^4.66.2"
38
38
  tabulate = "^0.9.0"
39
39
  pydantic = "^2.7"
40
- aiohttp = "^3.9.3"
41
40
  filelock = "^3.13.1"
42
41
  eval-type-backport = ">=0.1.3,<0.3.0"
43
42
  click = "^8.1.7"
@@ -47,7 +46,7 @@ numpy = [
47
46
  { version = ">=1.23.5", python = "<3.12" },
48
47
  { version = ">=1.26.0", python = ">=3.12" },
49
48
  ]
50
- openai = "^1.25.0"
49
+ httpx = "^0.27.0"
51
50
 
52
51
  [tool.poetry.group.quality]
53
52
  optional = true
@@ -57,7 +56,6 @@ black = ">=23.1,<25.0"
57
56
  ruff = ">=0.3.2,<0.5.0"
58
57
  types-tqdm = "^4.65.0.0"
59
58
  types-tabulate = "^0.9.0.3"
60
- pre-commit = "3.5.0"
61
59
  types-requests = "^2.31.0.20240218"
62
60
  pyarrow-stubs = "^10.0.1.7"
63
61
  mypy = "^1.9.0"
@@ -74,6 +72,7 @@ tox = "^4.14.1"
74
72
 
75
73
  [tool.poetry.group.dev.dependencies]
76
74
  ipdb = "^0.13.13"
75
+ pre-commit = "^3.7.1"
77
76
 
78
77
  [tool.poetry.urls]
79
78
  "Homepage" = "https://www.seekr.com/"
@@ -23,30 +23,15 @@ log: str | None = None # Set to either 'debug' or 'info', controls console logg
23
23
 
24
24
  if TYPE_CHECKING:
25
25
  import requests
26
- from aiohttp import ClientSession
27
26
 
28
27
  requestssession: "requests.Session" | Callable[[], "requests.Session"] | None = None
29
28
 
30
- aiosession: ContextVar["ClientSession" | None] = ContextVar(
31
- "aiohttp-session", default=None
32
- )
33
-
34
29
  from seekrai.client import AsyncClient, AsyncSeekrFlow, Client, SeekrFlow
35
30
 
36
31
 
37
32
  api_key: str | None = None # To be deprecated in the next major release
38
33
 
39
- # Legacy functions
40
- from seekrai.legacy.complete import AsyncComplete, Complete, Completion
41
- from seekrai.legacy.embeddings import Embeddings
42
- from seekrai.legacy.files import Files
43
- from seekrai.legacy.finetune import Finetune
44
- from seekrai.legacy.images import Image
45
- from seekrai.legacy.models import Models
46
-
47
-
48
34
  __all__ = [
49
- "aiosession",
50
35
  "constants",
51
36
  "version",
52
37
  "SeekrFlow",