seekrai 0.4.2__py3-none-any.whl → 0.5.0__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.
Files changed (48) hide show
  1. seekrai/__init__.py +0 -1
  2. seekrai/abstract/api_requestor.py +108 -251
  3. seekrai/abstract/response_parsing.py +99 -0
  4. seekrai/client.py +12 -0
  5. seekrai/filemanager.py +181 -3
  6. seekrai/resources/__init__.py +10 -0
  7. seekrai/resources/agents/__init__.py +13 -0
  8. seekrai/resources/agents/agent_inference.py +277 -0
  9. seekrai/resources/agents/agents.py +272 -0
  10. seekrai/resources/agents/threads.py +454 -0
  11. seekrai/resources/alignment.py +3 -9
  12. seekrai/resources/completions.py +3 -9
  13. seekrai/resources/deployments.py +4 -9
  14. seekrai/resources/embeddings.py +3 -9
  15. seekrai/resources/files.py +163 -48
  16. seekrai/resources/finetune.py +3 -9
  17. seekrai/resources/images.py +3 -5
  18. seekrai/resources/ingestion.py +173 -0
  19. seekrai/resources/models.py +35 -124
  20. seekrai/resources/projects.py +4 -9
  21. seekrai/resources/resource_base.py +10 -0
  22. seekrai/resources/vectordb.py +482 -0
  23. seekrai/types/__init__.py +87 -0
  24. seekrai/types/agents/__init__.py +89 -0
  25. seekrai/types/agents/agent.py +42 -0
  26. seekrai/types/agents/runs.py +117 -0
  27. seekrai/types/agents/threads.py +265 -0
  28. seekrai/types/agents/tools/__init__.py +16 -0
  29. seekrai/types/agents/tools/env_model_config.py +7 -0
  30. seekrai/types/agents/tools/schemas/__init__.py +8 -0
  31. seekrai/types/agents/tools/schemas/file_search.py +9 -0
  32. seekrai/types/agents/tools/schemas/file_search_env.py +11 -0
  33. seekrai/types/agents/tools/tool.py +14 -0
  34. seekrai/types/agents/tools/tool_env_types.py +4 -0
  35. seekrai/types/agents/tools/tool_types.py +10 -0
  36. seekrai/types/alignment.py +6 -2
  37. seekrai/types/common.py +7 -2
  38. seekrai/types/files.py +5 -0
  39. seekrai/types/finetune.py +1 -0
  40. seekrai/types/ingestion.py +29 -0
  41. seekrai/types/models.py +3 -0
  42. seekrai/types/vectordb.py +78 -0
  43. {seekrai-0.4.2.dist-info → seekrai-0.5.0.dist-info}/METADATA +3 -3
  44. seekrai-0.5.0.dist-info/RECORD +67 -0
  45. {seekrai-0.4.2.dist-info → seekrai-0.5.0.dist-info}/WHEEL +1 -1
  46. seekrai-0.4.2.dist-info/RECORD +0 -46
  47. {seekrai-0.4.2.dist-info → seekrai-0.5.0.dist-info}/LICENSE +0 -0
  48. {seekrai-0.4.2.dist-info → seekrai-0.5.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,454 @@
1
+ from typing import Any, Optional
2
+
3
+ from seekrai.abstract import api_requestor
4
+ from seekrai.seekrflow_response import SeekrFlowResponse
5
+ from seekrai.types import (
6
+ MessageUpdateRequest,
7
+ SeekrFlowRequest,
8
+ Thread,
9
+ ThreadCreateRequest,
10
+ ThreadMessage,
11
+ ThreadMessageContentType,
12
+ )
13
+
14
+
15
+ class AgentThreads:
16
+ def __init__(self, client: Any) -> None:
17
+ self._client = client
18
+ self._requestor = api_requestor.APIRequestor(client=self._client)
19
+
20
+ def create_message(
21
+ self,
22
+ thread_id: str,
23
+ role: str,
24
+ content: ThreadMessageContentType,
25
+ **meta_data: Any,
26
+ ) -> ThreadMessage:
27
+ """Creates a new message within a Thread.
28
+
29
+ Args:
30
+ thread_id: Identifier for the Thread to append to.
31
+ role: The name of the message writer.
32
+ content: The contents of the newly written message.
33
+ meta_data: Additional information attached to the new message.
34
+
35
+ Returns:
36
+ A ThreadMessage that matches the provided arguments.
37
+ """
38
+ payload = ThreadMessage(
39
+ thread_id=thread_id,
40
+ role=role,
41
+ content=content,
42
+ meta_data=meta_data,
43
+ ).model_dump()
44
+
45
+ response, _, _ = self._requestor.request(
46
+ options=SeekrFlowRequest(
47
+ method="POST",
48
+ url=f"threads/{thread_id}/messages",
49
+ params=payload,
50
+ )
51
+ )
52
+
53
+ assert isinstance(response, SeekrFlowResponse)
54
+ return ThreadMessage(**response.data)
55
+
56
+ def retrieve_message(self, thread_id: str, message_id: str) -> ThreadMessage:
57
+ """Retrieves a referenced ThreadMessage.
58
+
59
+ Args:
60
+ thread_id: Identifier for the Thread the message belongs to.
61
+ message_id: Identifier for the ThreadMessage to retrieve.
62
+
63
+ Returns:
64
+ The ThreadMessage whose identity matches the arguments.
65
+ """
66
+ response, _, _ = self._requestor.request(
67
+ options=SeekrFlowRequest(
68
+ method="GET",
69
+ url=f"threads/{thread_id}/messages/{message_id}",
70
+ )
71
+ )
72
+
73
+ assert isinstance(response, SeekrFlowResponse)
74
+ return ThreadMessage(**response.data)
75
+
76
+ def list_messages(
77
+ self, thread_id: str, limit: int = 20, order: str = "desc"
78
+ ) -> list[ThreadMessage]:
79
+ """Retrieves a list of messages from a referenced Thread.
80
+
81
+ Args:
82
+ thread_id: Identifier of the Thread.
83
+ limit: The max number of ThreadMessages to retrieve.
84
+ order: The order in which ThreadMessages are retrieved. Either 'desc' or 'asc'.
85
+
86
+ Returns:
87
+ A list of ThreadMessages, all from the Thread whose id matches thread_id.
88
+ """
89
+ response, _, _ = self._requestor.request(
90
+ options=SeekrFlowRequest(
91
+ method="GET",
92
+ url=f"threads/{thread_id}/messages",
93
+ params={"limit": limit, "order": order},
94
+ )
95
+ )
96
+
97
+ assert isinstance(response, SeekrFlowResponse)
98
+ return [ThreadMessage(**message) for message in response.data] # type: ignore
99
+
100
+ def update_message(
101
+ self,
102
+ thread_id: str,
103
+ message_id: str,
104
+ content: Optional[str] = None,
105
+ **meta_data: Any,
106
+ ) -> ThreadMessage:
107
+ """Updates a ThreadMessage to have new attributes.
108
+
109
+ Args:
110
+ thread_id: Identifier of the Thread that contains the message to update.
111
+ message_id: Identifier of the ThreadMessage to be updated.
112
+ content: The new content of the message.
113
+ meta_data: Any other attributes to be updated on the ThreadMessage.
114
+
115
+ Returns:
116
+ The referenced ThreadMessage, but with updated attributes.
117
+ """
118
+ payload = MessageUpdateRequest(
119
+ content=content,
120
+ meta_data=meta_data,
121
+ ).model_dump()
122
+
123
+ response, _, _ = self._requestor.request(
124
+ options=SeekrFlowRequest(
125
+ method="PATCH",
126
+ url=f"threads/{thread_id}/messages/{message_id}",
127
+ params=payload,
128
+ )
129
+ )
130
+
131
+ assert isinstance(response, SeekrFlowResponse)
132
+ return ThreadMessage(**response.data)
133
+
134
+ def delete_message(self, thread_id: str, message_id: str) -> dict[str, Any]:
135
+ """Deletes a referenced ThreadMessage.
136
+
137
+ Args:
138
+ thread_id: Identifier of the Thread from which a message should be deleted.
139
+ message_id: Identifier of the ThreadMessage to delete.
140
+
141
+ Returns:
142
+ {"deleted": True} on success.
143
+ """
144
+ response, _, _ = self._requestor.request(
145
+ options=SeekrFlowRequest(
146
+ method="DELETE",
147
+ url=f"threads/{thread_id}/messages/{message_id}",
148
+ )
149
+ )
150
+
151
+ assert isinstance(response, SeekrFlowResponse)
152
+ return response.data
153
+
154
+ def create(self, **meta_data: Any) -> Thread:
155
+ """Creates a new Thread.
156
+
157
+ Args:
158
+ meta_data: Any special attributes to be attached to the new Thread.
159
+
160
+ Returns:
161
+ A newly created Thread with the specified attributes.
162
+ """
163
+ payload = ThreadCreateRequest(meta_data=meta_data).model_dump()
164
+
165
+ response, _, _ = self._requestor.request(
166
+ options=SeekrFlowRequest(
167
+ method="POST",
168
+ url="threads/",
169
+ params=payload,
170
+ )
171
+ )
172
+
173
+ assert isinstance(response, SeekrFlowResponse)
174
+ return Thread(**response.data)
175
+
176
+ def retrieve(self, thread_id: str) -> Thread:
177
+ """Retrieves a referenced Thread.
178
+
179
+ Args:
180
+ thread_id: Identifier of the Thread to retrieve.
181
+
182
+ Returns:
183
+ A Thread whose id matches thread_id.
184
+ """
185
+ response, _, _ = self._requestor.request(
186
+ options=SeekrFlowRequest(
187
+ method="GET",
188
+ url=f"threads/{thread_id}",
189
+ )
190
+ )
191
+
192
+ assert isinstance(response, SeekrFlowResponse)
193
+ return Thread(**response.data)
194
+
195
+ def list(self, limit: int = 20, order: str = "desc") -> list[Thread]:
196
+ """Retrieve a list of Threads.
197
+
198
+ Args:
199
+ limit: The maximum number of Threads to retrieve.
200
+ order: The order in which retrieved Threads are listed. Either 'desc' or 'asc'.
201
+
202
+ Returns:
203
+ A list of known Threads.
204
+ """
205
+ response, _, _ = self._requestor.request(
206
+ options=SeekrFlowRequest(
207
+ method="GET",
208
+ url="threads/",
209
+ params={"limit": limit, "order": order},
210
+ )
211
+ )
212
+
213
+ assert isinstance(response, SeekrFlowResponse)
214
+ return [Thread(**thread) for thread in response.data] # type: ignore
215
+
216
+ def delete(self, thread_id: str) -> dict[str, Any]:
217
+ """Deletes a Thread.
218
+
219
+ Args:
220
+ thread_id: Identifier of the Thread to be deleted.
221
+
222
+ Returns:
223
+ {"deleted": True} on success.
224
+ """
225
+ response, _, _ = self._requestor.request(
226
+ options=SeekrFlowRequest(
227
+ method="DELETE",
228
+ url=f"threads/{thread_id}",
229
+ )
230
+ )
231
+
232
+ assert isinstance(response, SeekrFlowResponse)
233
+ return response.data
234
+
235
+
236
+ class AsyncAgentThreads:
237
+ def __init__(self, client: Any) -> None:
238
+ self._client = client
239
+ self._requestor = api_requestor.APIRequestor(client=self._client)
240
+
241
+ async def create_message(
242
+ self,
243
+ thread_id: str,
244
+ role: str,
245
+ content: ThreadMessageContentType,
246
+ **meta_data: Any,
247
+ ) -> ThreadMessage:
248
+ """Creates a new message within a Thread.
249
+
250
+ Args:
251
+ thread_id: Identifier for the Thread to append to.
252
+ role: The name of the message writer.
253
+ content: The contents of the newly written message.
254
+ meta_data: Additional information attached to the new message.
255
+
256
+ Returns:
257
+ A ThreadMessage that matches the provided arguments.
258
+ """
259
+ payload = ThreadMessage(
260
+ thread_id=thread_id,
261
+ role=role,
262
+ content=content,
263
+ meta_data=meta_data,
264
+ ).model_dump()
265
+
266
+ response, _, _ = await self._requestor.arequest(
267
+ options=SeekrFlowRequest(
268
+ method="POST",
269
+ url=f"threads/{thread_id}/messages",
270
+ params=payload,
271
+ )
272
+ )
273
+
274
+ assert isinstance(response, SeekrFlowResponse)
275
+ return ThreadMessage(**response.data)
276
+
277
+ async def retrieve_message(self, thread_id: str, message_id: str) -> ThreadMessage:
278
+ """Retrieves a referenced ThreadMessage.
279
+
280
+ Args:
281
+ thread_id: Identifier for the Thread the message belongs to.
282
+ message_id: Identifier for the ThreadMessage to retrieve.
283
+
284
+ Returns:
285
+ The ThreadMessage whose identity matches the arguments.
286
+ """
287
+ response, _, _ = await self._requestor.arequest(
288
+ options=SeekrFlowRequest(
289
+ method="GET",
290
+ url=f"threads/{thread_id}/messages/{message_id}",
291
+ )
292
+ )
293
+
294
+ assert isinstance(response, SeekrFlowResponse)
295
+ return ThreadMessage(**response.data)
296
+
297
+ async def list_messages(
298
+ self, thread_id: str, limit: int = 20, order: str = "desc"
299
+ ) -> list[ThreadMessage]:
300
+ """Retrieves a list of messages from a referenced Thread.
301
+
302
+ Args:
303
+ thread_id: Identifier of the Thread.
304
+ limit: The max number of ThreadMessages to retrieve.
305
+ order: The order in which ThreadMessages are retrieved. Either 'desc' or 'asc'.
306
+
307
+ Returns:
308
+ A list of ThreadMessages, all from the Thread whose id matches thread_id.
309
+ """
310
+ response, _, _ = await self._requestor.arequest(
311
+ options=SeekrFlowRequest(
312
+ method="GET",
313
+ url=f"threads/{thread_id}/messages",
314
+ params={"limit": limit, "order": order},
315
+ )
316
+ )
317
+
318
+ assert isinstance(response, SeekrFlowResponse)
319
+ return [ThreadMessage(**message) for message in response.data] # type: ignore
320
+
321
+ async def update_message(
322
+ self,
323
+ thread_id: str,
324
+ message_id: str,
325
+ content: Optional[str] = None,
326
+ **meta_data: Any,
327
+ ) -> ThreadMessage:
328
+ """Updates a ThreadMessage to have new attributes.
329
+
330
+ Args:
331
+ thread_id: Identifier of the Thread that contains the message to update.
332
+ message_id: Identifier of the ThreadMessage to be updated.
333
+ content: The new content of the message.
334
+ meta_data: Any other attributes to be updated on the ThreadMessage.
335
+
336
+ Returns:
337
+ The referenced ThreadMessage, but with updated attributes.
338
+ """
339
+ payload = MessageUpdateRequest(
340
+ content=content,
341
+ meta_data=meta_data,
342
+ ).model_dump()
343
+
344
+ response, _, _ = await self._requestor.arequest(
345
+ options=SeekrFlowRequest(
346
+ method="PATCH",
347
+ url=f"threads/{thread_id}/messages/{message_id}",
348
+ params=payload,
349
+ )
350
+ )
351
+
352
+ assert isinstance(response, SeekrFlowResponse)
353
+ return ThreadMessage(**response.data)
354
+
355
+ async def delete_message(self, thread_id: str, message_id: str) -> dict[str, Any]:
356
+ """Deletes a referenced ThreadMessage.
357
+
358
+ Args:
359
+ thread_id: Identifier of the Thread from which a message should be deleted.
360
+ message_id: Identifier of the ThreadMessage to delete.
361
+
362
+ Returns:
363
+ {"deleted": True} on success.
364
+ """
365
+ response, _, _ = await self._requestor.arequest(
366
+ options=SeekrFlowRequest(
367
+ method="DELETE",
368
+ url=f"threads/{thread_id}/messages/{message_id}",
369
+ )
370
+ )
371
+
372
+ assert isinstance(response, SeekrFlowResponse)
373
+ return response.data
374
+
375
+ async def create(self, **meta_data: Any) -> Thread:
376
+ """Creates a new Thread.
377
+
378
+ Args:
379
+ meta_data: Any special attributes to be attached to the new Thread.
380
+
381
+ Returns:
382
+ A newly created Thread with the specified attributes.
383
+ """
384
+ payload = ThreadCreateRequest(meta_data=meta_data).model_dump()
385
+
386
+ response, _, _ = await self._requestor.arequest(
387
+ options=SeekrFlowRequest(
388
+ method="POST",
389
+ url="threads/",
390
+ params=payload,
391
+ )
392
+ )
393
+
394
+ assert isinstance(response, SeekrFlowResponse)
395
+ return Thread(**response.data)
396
+
397
+ async def retrieve(self, thread_id: str) -> Thread:
398
+ """Retrieves a referenced Thread.
399
+
400
+ Args:
401
+ thread_id: Identifier of the Thread to retrieve.
402
+
403
+ Returns:
404
+ A Thread whose id matches thread_id.
405
+ """
406
+ response, _, _ = await self._requestor.arequest(
407
+ options=SeekrFlowRequest(
408
+ method="GET",
409
+ url=f"threads/{thread_id}",
410
+ )
411
+ )
412
+
413
+ assert isinstance(response, SeekrFlowResponse)
414
+ return Thread(**response.data)
415
+
416
+ async def list(self, limit: int = 20, order: str = "desc") -> list[Thread]:
417
+ """Retrieve a list of Threads.
418
+
419
+ Args:
420
+ limit: The maximum number of Threads to retrieve.
421
+ order: The order in which retrieved Threads are listed. Either 'desc' or 'asc'.
422
+
423
+ Returns:
424
+ A list of known Threads.
425
+ """
426
+ response, _, _ = await self._requestor.arequest(
427
+ options=SeekrFlowRequest(
428
+ method="GET",
429
+ url="threads/",
430
+ params={"limit": limit, "order": order},
431
+ )
432
+ )
433
+
434
+ assert isinstance(response, SeekrFlowResponse)
435
+ return [Thread(**thread) for thread in response.data] # type: ignore
436
+
437
+ async def delete(self, thread_id: str) -> dict[str, Any]:
438
+ """Deletes a Thread.
439
+
440
+ Args:
441
+ thread_id: Identifier of the Thread to be deleted.
442
+
443
+ Returns:
444
+ {"deleted": True} on success.
445
+ """
446
+ response, _, _ = await self._requestor.arequest(
447
+ options=SeekrFlowRequest(
448
+ method="DELETE",
449
+ url=f"threads/{thread_id}",
450
+ )
451
+ )
452
+
453
+ assert isinstance(response, SeekrFlowResponse)
454
+ return response.data
@@ -1,6 +1,7 @@
1
1
  from typing import List
2
2
 
3
3
  from seekrai.abstract import api_requestor
4
+ from seekrai.resources.resource_base import ResourceBase
4
5
  from seekrai.seekrflow_response import SeekrFlowResponse
5
6
  from seekrai.types import (
6
7
  AlignmentEstimationRequest,
@@ -9,15 +10,11 @@ from seekrai.types import (
9
10
  AlignmentRequest,
10
11
  AlignmentResponse,
11
12
  AlignmentType,
12
- SeekrFlowClient,
13
13
  SeekrFlowRequest,
14
14
  )
15
15
 
16
16
 
17
- class Alignment:
18
- def __init__(self, client: SeekrFlowClient) -> None:
19
- self._client = client
20
-
17
+ class Alignment(ResourceBase):
21
18
  def generate(
22
19
  self,
23
20
  instructions: str,
@@ -117,10 +114,7 @@ class Alignment:
117
114
  return AlignmentEstimationResponse(**response.data)
118
115
 
119
116
 
120
- class AsyncAlignment:
121
- def __init__(self, client: SeekrFlowClient) -> None:
122
- self._client = client
123
-
117
+ class AsyncAlignment(ResourceBase):
124
118
  async def generate(
125
119
  self,
126
120
  instructions: str,
@@ -3,20 +3,17 @@ from __future__ import annotations
3
3
  from typing import AsyncGenerator, Iterator, List
4
4
 
5
5
  from seekrai.abstract import api_requestor
6
+ from seekrai.resources.resource_base import ResourceBase
6
7
  from seekrai.seekrflow_response import SeekrFlowResponse
7
8
  from seekrai.types import (
8
9
  CompletionChunk,
9
10
  CompletionRequest,
10
11
  CompletionResponse,
11
- SeekrFlowClient,
12
12
  SeekrFlowRequest,
13
13
  )
14
14
 
15
15
 
16
- class Completions:
17
- def __init__(self, client: SeekrFlowClient) -> None:
18
- self._client = client
19
-
16
+ class Completions(ResourceBase):
20
17
  def create(
21
18
  self,
22
19
  *,
@@ -109,10 +106,7 @@ class Completions:
109
106
  return CompletionResponse(**response.data)
110
107
 
111
108
 
112
- class AsyncCompletions:
113
- def __init__(self, client: SeekrFlowClient) -> None:
114
- self._client = client
115
-
109
+ class AsyncCompletions(ResourceBase):
116
110
  async def create(
117
111
  self,
118
112
  *,
@@ -1,14 +1,12 @@
1
1
  from seekrai.abstract import api_requestor
2
+ from seekrai.resources.resource_base import ResourceBase
2
3
  from seekrai.seekrflow_response import SeekrFlowResponse
3
- from seekrai.types import SeekrFlowClient, SeekrFlowRequest
4
+ from seekrai.types import SeekrFlowRequest
4
5
  from seekrai.types.deployments import Deployment as DeploymentSchema
5
6
  from seekrai.types.deployments import GetDeploymentsResponse
6
7
 
7
8
 
8
- class Deployments:
9
- def __init__(self, client: SeekrFlowClient) -> None:
10
- self._client = client
11
-
9
+ class Deployments(ResourceBase):
12
10
  def list(self) -> GetDeploymentsResponse:
13
11
  requestor = api_requestor.APIRequestor(
14
12
  client=self._client,
@@ -104,10 +102,7 @@ class Deployments:
104
102
  return DeploymentSchema(**response.data)
105
103
 
106
104
 
107
- class AsyncDeployments:
108
- def __init__(self, client: SeekrFlowClient) -> None:
109
- self._client = client
110
-
105
+ class AsyncDeployments(ResourceBase):
111
106
  async def list(self) -> GetDeploymentsResponse:
112
107
  requestor = api_requestor.APIRequestor(
113
108
  client=self._client,
@@ -3,19 +3,16 @@ from __future__ import annotations
3
3
  from typing import List
4
4
 
5
5
  from seekrai.abstract import api_requestor
6
+ from seekrai.resources.resource_base import ResourceBase
6
7
  from seekrai.seekrflow_response import SeekrFlowResponse
7
8
  from seekrai.types import (
8
9
  EmbeddingRequest,
9
10
  EmbeddingResponse,
10
- SeekrFlowClient,
11
11
  SeekrFlowRequest,
12
12
  )
13
13
 
14
14
 
15
- class Embeddings:
16
- def __init__(self, client: SeekrFlowClient) -> None:
17
- self._client = client
18
-
15
+ class Embeddings(ResourceBase):
19
16
  def create(
20
17
  self,
21
18
  *,
@@ -57,10 +54,7 @@ class Embeddings:
57
54
  return EmbeddingResponse(**response.data)
58
55
 
59
56
 
60
- class AsyncEmbeddings:
61
- def __init__(self, client: SeekrFlowClient) -> None:
62
- self._client = client
63
-
57
+ class AsyncEmbeddings(ResourceBase):
64
58
  async def create(
65
59
  self,
66
60
  *,