seekrai 0.5.16__py3-none-any.whl → 0.5.24__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/client.py +4 -0
- seekrai/resources/__init__.py +8 -1
- seekrai/resources/alignment.py +460 -1
- seekrai/resources/explainability.py +19 -11
- seekrai/resources/finetune.py +44 -0
- seekrai/resources/ingestion.py +5 -7
- seekrai/resources/vectordb.py +36 -2
- seekrai/types/__init__.py +10 -0
- seekrai/types/alignment.py +36 -0
- seekrai/types/deployments.py +1 -0
- seekrai/types/explainability.py +12 -43
- seekrai/types/files.py +1 -1
- seekrai/types/finetune.py +23 -6
- seekrai/types/vectordb.py +6 -1
- {seekrai-0.5.16.dist-info → seekrai-0.5.24.dist-info}/METADATA +3 -6
- {seekrai-0.5.16.dist-info → seekrai-0.5.24.dist-info}/RECORD +19 -19
- {seekrai-0.5.16.dist-info → seekrai-0.5.24.dist-info}/WHEEL +1 -1
- {seekrai-0.5.16.dist-info → seekrai-0.5.24.dist-info}/LICENSE +0 -0
- {seekrai-0.5.16.dist-info → seekrai-0.5.24.dist-info}/entry_points.txt +0 -0
seekrai/client.py
CHANGED
|
@@ -25,6 +25,7 @@ class SeekrFlow:
|
|
|
25
25
|
vector_database: resources.VectorDatabase
|
|
26
26
|
agents: resources.Agents
|
|
27
27
|
observability: resources.AgentObservability
|
|
28
|
+
explainability: resources.Explainability
|
|
28
29
|
|
|
29
30
|
# client options
|
|
30
31
|
client: SeekrFlowClient
|
|
@@ -91,6 +92,7 @@ class SeekrFlow:
|
|
|
91
92
|
self.vector_database = resources.VectorDatabase(self.client)
|
|
92
93
|
self.agents = resources.Agents(self.client)
|
|
93
94
|
self.observability = resources.AgentObservability(self.client)
|
|
95
|
+
self.explainability = resources.Explainability(self.client)
|
|
94
96
|
|
|
95
97
|
|
|
96
98
|
class AsyncSeekrFlow:
|
|
@@ -108,6 +110,7 @@ class AsyncSeekrFlow:
|
|
|
108
110
|
vector_database: resources.AsyncVectorDatabase
|
|
109
111
|
agents: resources.AsyncAgents
|
|
110
112
|
observability: resources.AsyncAgentObservability
|
|
113
|
+
explainability: resources.AsyncExplainability
|
|
111
114
|
|
|
112
115
|
# client options
|
|
113
116
|
client: SeekrFlowClient
|
|
@@ -174,6 +177,7 @@ class AsyncSeekrFlow:
|
|
|
174
177
|
self.vector_database = resources.AsyncVectorDatabase(self.client)
|
|
175
178
|
self.agents = resources.AsyncAgents(self.client)
|
|
176
179
|
self.observability = resources.AsyncAgentObservability(self.client)
|
|
180
|
+
self.explainability = resources.AsyncExplainability(self.client)
|
|
177
181
|
|
|
178
182
|
|
|
179
183
|
Client = SeekrFlow
|
seekrai/resources/__init__.py
CHANGED
|
@@ -5,7 +5,12 @@ from seekrai.resources.agents import (
|
|
|
5
5
|
AsyncAgentObservability,
|
|
6
6
|
AsyncAgents,
|
|
7
7
|
)
|
|
8
|
-
from seekrai.resources.alignment import
|
|
8
|
+
from seekrai.resources.alignment import (
|
|
9
|
+
Alignment,
|
|
10
|
+
AsyncAlignment,
|
|
11
|
+
AsyncSystemPromptResource,
|
|
12
|
+
SystemPromptResource,
|
|
13
|
+
)
|
|
9
14
|
from seekrai.resources.chat import AsyncChat, Chat
|
|
10
15
|
from seekrai.resources.completions import AsyncCompletions, Completions
|
|
11
16
|
from seekrai.resources.deployments import AsyncDeployments, Deployments
|
|
@@ -23,6 +28,8 @@ from seekrai.resources.vectordb import AsyncVectorDatabase, VectorDatabase
|
|
|
23
28
|
__all__ = [
|
|
24
29
|
"AsyncAlignment",
|
|
25
30
|
"Alignment",
|
|
31
|
+
"AsyncSystemPromptResource",
|
|
32
|
+
"SystemPromptResource",
|
|
26
33
|
"AsyncCompletions",
|
|
27
34
|
"Completions",
|
|
28
35
|
"AsyncChat",
|
seekrai/resources/alignment.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
2
|
|
|
3
3
|
from seekrai.abstract import api_requestor
|
|
4
4
|
from seekrai.resources.resource_base import ResourceBase
|
|
@@ -7,14 +7,23 @@ from seekrai.types import (
|
|
|
7
7
|
AlignmentEstimationRequest,
|
|
8
8
|
AlignmentEstimationResponse,
|
|
9
9
|
AlignmentList,
|
|
10
|
+
AlignmentOutput,
|
|
10
11
|
AlignmentRequest,
|
|
11
12
|
AlignmentResponse,
|
|
12
13
|
AlignmentType,
|
|
13
14
|
SeekrFlowRequest,
|
|
15
|
+
SystemPrompt,
|
|
16
|
+
SystemPromptCreateRequest,
|
|
17
|
+
SystemPromptUpdateRequest,
|
|
14
18
|
)
|
|
19
|
+
from seekrai.types.abstract import SeekrFlowClient
|
|
15
20
|
|
|
16
21
|
|
|
17
22
|
class Alignment(ResourceBase):
|
|
23
|
+
def __init__(self, client: SeekrFlowClient) -> None:
|
|
24
|
+
super().__init__(client)
|
|
25
|
+
self.system_prompt = SystemPromptResource(client)
|
|
26
|
+
|
|
18
27
|
def generate(
|
|
19
28
|
self,
|
|
20
29
|
instructions: str,
|
|
@@ -92,6 +101,86 @@ class Alignment(ResourceBase):
|
|
|
92
101
|
|
|
93
102
|
return AlignmentResponse(**response.data)
|
|
94
103
|
|
|
104
|
+
def outputs(self, id: str) -> List[AlignmentOutput]:
|
|
105
|
+
"""
|
|
106
|
+
Retrieves output files for an alignment job.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
id (str): Alignment job ID whose outputs to fetch.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
list[AlignmentOutput]: Collection of alignment output metadata.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
requestor = api_requestor.APIRequestor(
|
|
116
|
+
client=self._client,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
response, _, _ = requestor.request(
|
|
120
|
+
options=SeekrFlowRequest(
|
|
121
|
+
method="GET",
|
|
122
|
+
url=f"flow/alignment/{id}/outputs",
|
|
123
|
+
),
|
|
124
|
+
stream=False,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
128
|
+
|
|
129
|
+
return [AlignmentOutput(**output) for output in response.data] # type: ignore[arg-type]
|
|
130
|
+
|
|
131
|
+
def delete(self, id: str) -> None:
|
|
132
|
+
"""
|
|
133
|
+
Deletes an alignment job.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
id (str): Alignment job ID to delete.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
None
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
requestor = api_requestor.APIRequestor(
|
|
143
|
+
client=self._client,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
response, _, _ = requestor.request(
|
|
147
|
+
options=SeekrFlowRequest(
|
|
148
|
+
method="DELETE",
|
|
149
|
+
url=f"flow/alignment/{id}",
|
|
150
|
+
),
|
|
151
|
+
stream=False,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# Endpoint returns 204 No Content
|
|
155
|
+
return None
|
|
156
|
+
|
|
157
|
+
def cancel(self, id: str) -> AlignmentResponse:
|
|
158
|
+
"""
|
|
159
|
+
Method to cancel a running alignment job
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
id (str): Alignment job ID to cancel. A string that starts with `al-`.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
AlignmentResponse: Object containing information about cancelled alignment job.
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
requestor = api_requestor.APIRequestor(
|
|
169
|
+
client=self._client,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
response, _, _ = requestor.request(
|
|
173
|
+
options=SeekrFlowRequest(
|
|
174
|
+
method="POST",
|
|
175
|
+
url=f"flow/alignment/{id}/cancel",
|
|
176
|
+
),
|
|
177
|
+
stream=False,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
181
|
+
|
|
182
|
+
return AlignmentResponse(**response.data)
|
|
183
|
+
|
|
95
184
|
def estimate(self, files: List[str]) -> AlignmentEstimationResponse:
|
|
96
185
|
requestor = api_requestor.APIRequestor(
|
|
97
186
|
client=self._client,
|
|
@@ -115,6 +204,10 @@ class Alignment(ResourceBase):
|
|
|
115
204
|
|
|
116
205
|
|
|
117
206
|
class AsyncAlignment(ResourceBase):
|
|
207
|
+
def __init__(self, client: SeekrFlowClient) -> None:
|
|
208
|
+
super().__init__(client)
|
|
209
|
+
self.system_prompt = AsyncSystemPromptResource(client)
|
|
210
|
+
|
|
118
211
|
async def generate(
|
|
119
212
|
self,
|
|
120
213
|
instructions: str,
|
|
@@ -192,6 +285,86 @@ class AsyncAlignment(ResourceBase):
|
|
|
192
285
|
|
|
193
286
|
return AlignmentResponse(**response.data)
|
|
194
287
|
|
|
288
|
+
async def outputs(self, id: str) -> List[AlignmentOutput]:
|
|
289
|
+
"""
|
|
290
|
+
Retrieves output files for an alignment job asynchronously.
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
id (str): Alignment job ID whose outputs to fetch.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
list[AlignmentOutput]: Collection of alignment output metadata.
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
requestor = api_requestor.APIRequestor(
|
|
300
|
+
client=self._client,
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
response, _, _ = await requestor.arequest(
|
|
304
|
+
options=SeekrFlowRequest(
|
|
305
|
+
method="GET",
|
|
306
|
+
url=f"flow/alignment/{id}/outputs",
|
|
307
|
+
),
|
|
308
|
+
stream=False,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
312
|
+
|
|
313
|
+
return [AlignmentOutput(**output) for output in response.data] # type: ignore[arg-type]
|
|
314
|
+
|
|
315
|
+
async def delete(self, id: str) -> None:
|
|
316
|
+
"""
|
|
317
|
+
Deletes an alignment job asynchronously.
|
|
318
|
+
|
|
319
|
+
Args:
|
|
320
|
+
id (str): Alignment job ID to delete.
|
|
321
|
+
|
|
322
|
+
Returns:
|
|
323
|
+
None
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
requestor = api_requestor.APIRequestor(
|
|
327
|
+
client=self._client,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
response, _, _ = await requestor.arequest(
|
|
331
|
+
options=SeekrFlowRequest(
|
|
332
|
+
method="DELETE",
|
|
333
|
+
url=f"flow/alignment/{id}",
|
|
334
|
+
),
|
|
335
|
+
stream=False,
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
# Endpoint returns 204 No Content
|
|
339
|
+
return None
|
|
340
|
+
|
|
341
|
+
async def cancel(self, id: str) -> AlignmentResponse:
|
|
342
|
+
"""
|
|
343
|
+
Async method to cancel a running alignment job
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
id (str): Alignment job ID to cancel. A string that starts with `al-`.
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
AlignmentResponse: Object containing information about cancelled alignment job.
|
|
350
|
+
"""
|
|
351
|
+
|
|
352
|
+
requestor = api_requestor.APIRequestor(
|
|
353
|
+
client=self._client,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
response, _, _ = await requestor.arequest(
|
|
357
|
+
options=SeekrFlowRequest(
|
|
358
|
+
method="POST",
|
|
359
|
+
url=f"flow/alignment/{id}/cancel",
|
|
360
|
+
),
|
|
361
|
+
stream=False,
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
365
|
+
|
|
366
|
+
return AlignmentResponse(**response.data)
|
|
367
|
+
|
|
195
368
|
async def estimate(self, files: List[str]) -> AlignmentEstimationResponse:
|
|
196
369
|
requestor = api_requestor.APIRequestor(
|
|
197
370
|
client=self._client,
|
|
@@ -212,3 +385,289 @@ class AsyncAlignment(ResourceBase):
|
|
|
212
385
|
|
|
213
386
|
assert isinstance(response, SeekrFlowResponse)
|
|
214
387
|
return AlignmentEstimationResponse(**response.data)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
class SystemPromptResource(ResourceBase):
|
|
391
|
+
def create(self, source_id: str, instructions: str) -> SystemPrompt:
|
|
392
|
+
"""
|
|
393
|
+
Creates a new AI-generated system prompt for the given source_id.
|
|
394
|
+
|
|
395
|
+
Args:
|
|
396
|
+
source_id (str): The ID of the source to create the system prompt for
|
|
397
|
+
instructions (str): Instructions for generating the system prompt
|
|
398
|
+
|
|
399
|
+
Returns:
|
|
400
|
+
SystemPrompt: The created system prompt
|
|
401
|
+
"""
|
|
402
|
+
requestor = api_requestor.APIRequestor(
|
|
403
|
+
client=self._client,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
parameter_payload = SystemPromptCreateRequest(
|
|
407
|
+
instructions=instructions
|
|
408
|
+
).model_dump()
|
|
409
|
+
|
|
410
|
+
response, _, _ = requestor.request(
|
|
411
|
+
options=SeekrFlowRequest(
|
|
412
|
+
method="POST",
|
|
413
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
414
|
+
params=parameter_payload,
|
|
415
|
+
),
|
|
416
|
+
stream=False,
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
420
|
+
return SystemPrompt(**response.data)
|
|
421
|
+
|
|
422
|
+
def get(self, source_id: str) -> SystemPrompt:
|
|
423
|
+
"""
|
|
424
|
+
Retrieves the system prompt for the given source_id.
|
|
425
|
+
|
|
426
|
+
Args:
|
|
427
|
+
source_id (str): The ID of the source to retrieve the system prompt for
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
SystemPrompt: The retrieved system prompt
|
|
431
|
+
"""
|
|
432
|
+
requestor = api_requestor.APIRequestor(
|
|
433
|
+
client=self._client,
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
response, _, _ = requestor.request(
|
|
437
|
+
options=SeekrFlowRequest(
|
|
438
|
+
method="GET",
|
|
439
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
440
|
+
),
|
|
441
|
+
stream=False,
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
445
|
+
return SystemPrompt(**response.data)
|
|
446
|
+
|
|
447
|
+
def regenerate(self, source_id: str, instructions: str) -> SystemPrompt:
|
|
448
|
+
"""
|
|
449
|
+
Regenerates the AI-generated system prompt for the given source_id.
|
|
450
|
+
|
|
451
|
+
Args:
|
|
452
|
+
source_id (str): The ID of the source to regenerate the system prompt for
|
|
453
|
+
instructions (str): Instructions for regenerating the system prompt
|
|
454
|
+
|
|
455
|
+
Returns:
|
|
456
|
+
SystemPrompt: The regenerated system prompt
|
|
457
|
+
"""
|
|
458
|
+
requestor = api_requestor.APIRequestor(
|
|
459
|
+
client=self._client,
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
parameter_payload = SystemPromptCreateRequest(
|
|
463
|
+
instructions=instructions
|
|
464
|
+
).model_dump()
|
|
465
|
+
|
|
466
|
+
response, _, _ = requestor.request(
|
|
467
|
+
options=SeekrFlowRequest(
|
|
468
|
+
method="POST",
|
|
469
|
+
url=f"flow/alignment/system_prompt/{source_id}/regenerate",
|
|
470
|
+
params=parameter_payload,
|
|
471
|
+
),
|
|
472
|
+
stream=False,
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
476
|
+
return SystemPrompt(**response.data)
|
|
477
|
+
|
|
478
|
+
def update(self, source_id: str, content: str) -> SystemPrompt:
|
|
479
|
+
"""
|
|
480
|
+
Updates the system prompt for the given source_id with custom content.
|
|
481
|
+
|
|
482
|
+
Args:
|
|
483
|
+
source_id (str): The ID of the source to update the system prompt for
|
|
484
|
+
content (str): The custom content for the system prompt
|
|
485
|
+
|
|
486
|
+
Returns:
|
|
487
|
+
SystemPrompt: The updated system prompt
|
|
488
|
+
"""
|
|
489
|
+
requestor = api_requestor.APIRequestor(
|
|
490
|
+
client=self._client,
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
parameter_payload = SystemPromptUpdateRequest(content=content).model_dump()
|
|
494
|
+
|
|
495
|
+
response, _, _ = requestor.request(
|
|
496
|
+
options=SeekrFlowRequest(
|
|
497
|
+
method="PUT",
|
|
498
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
499
|
+
params=parameter_payload,
|
|
500
|
+
),
|
|
501
|
+
stream=False,
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
505
|
+
return SystemPrompt(**response.data)
|
|
506
|
+
|
|
507
|
+
def delete(self, source_id: str) -> Dict[str, Any]:
|
|
508
|
+
"""
|
|
509
|
+
Deletes the system prompt for the given source_id.
|
|
510
|
+
|
|
511
|
+
Args:
|
|
512
|
+
source_id (str): The ID of the source to delete the system prompt for
|
|
513
|
+
|
|
514
|
+
Returns:
|
|
515
|
+
dict: A dictionary with the deletion result
|
|
516
|
+
"""
|
|
517
|
+
requestor = api_requestor.APIRequestor(
|
|
518
|
+
client=self._client,
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
response, _, _ = requestor.request(
|
|
522
|
+
options=SeekrFlowRequest(
|
|
523
|
+
method="DELETE",
|
|
524
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
525
|
+
),
|
|
526
|
+
stream=False,
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
530
|
+
return response.data
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
class AsyncSystemPromptResource(ResourceBase):
|
|
534
|
+
async def create(self, source_id: str, instructions: str) -> SystemPrompt:
|
|
535
|
+
"""
|
|
536
|
+
Asynchronously creates a new AI-generated system prompt for the given source_id.
|
|
537
|
+
|
|
538
|
+
Args:
|
|
539
|
+
source_id (str): The ID of the source to create the system prompt for
|
|
540
|
+
instructions (str): Instructions for generating the system prompt
|
|
541
|
+
|
|
542
|
+
Returns:
|
|
543
|
+
SystemPrompt: The created system prompt
|
|
544
|
+
"""
|
|
545
|
+
requestor = api_requestor.APIRequestor(
|
|
546
|
+
client=self._client,
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
parameter_payload = SystemPromptCreateRequest(
|
|
550
|
+
instructions=instructions
|
|
551
|
+
).model_dump()
|
|
552
|
+
|
|
553
|
+
response, _, _ = await requestor.arequest(
|
|
554
|
+
options=SeekrFlowRequest(
|
|
555
|
+
method="POST",
|
|
556
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
557
|
+
params=parameter_payload,
|
|
558
|
+
),
|
|
559
|
+
stream=False,
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
563
|
+
return SystemPrompt(**response.data)
|
|
564
|
+
|
|
565
|
+
async def get(self, source_id: str) -> SystemPrompt:
|
|
566
|
+
"""
|
|
567
|
+
Asynchronously retrieves the system prompt for the given source_id.
|
|
568
|
+
|
|
569
|
+
Args:
|
|
570
|
+
source_id (str): The ID of the source to retrieve the system prompt for
|
|
571
|
+
|
|
572
|
+
Returns:
|
|
573
|
+
SystemPrompt: The retrieved system prompt
|
|
574
|
+
"""
|
|
575
|
+
requestor = api_requestor.APIRequestor(
|
|
576
|
+
client=self._client,
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
response, _, _ = await requestor.arequest(
|
|
580
|
+
options=SeekrFlowRequest(
|
|
581
|
+
method="GET",
|
|
582
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
583
|
+
),
|
|
584
|
+
stream=False,
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
588
|
+
return SystemPrompt(**response.data)
|
|
589
|
+
|
|
590
|
+
async def regenerate(self, source_id: str, instructions: str) -> SystemPrompt:
|
|
591
|
+
"""
|
|
592
|
+
Asynchronously regenerates the AI-generated system prompt for the given source_id.
|
|
593
|
+
|
|
594
|
+
Args:
|
|
595
|
+
source_id (str): The ID of the source to regenerate the system prompt for
|
|
596
|
+
instructions (str): Instructions for regenerating the system prompt
|
|
597
|
+
|
|
598
|
+
Returns:
|
|
599
|
+
SystemPrompt: The regenerated system prompt
|
|
600
|
+
"""
|
|
601
|
+
requestor = api_requestor.APIRequestor(
|
|
602
|
+
client=self._client,
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
parameter_payload = SystemPromptCreateRequest(
|
|
606
|
+
instructions=instructions
|
|
607
|
+
).model_dump()
|
|
608
|
+
|
|
609
|
+
response, _, _ = await requestor.arequest(
|
|
610
|
+
options=SeekrFlowRequest(
|
|
611
|
+
method="POST",
|
|
612
|
+
url=f"flow/alignment/system_prompt/{source_id}/regenerate",
|
|
613
|
+
params=parameter_payload,
|
|
614
|
+
),
|
|
615
|
+
stream=False,
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
619
|
+
return SystemPrompt(**response.data)
|
|
620
|
+
|
|
621
|
+
async def update(self, source_id: str, content: str) -> SystemPrompt:
|
|
622
|
+
"""
|
|
623
|
+
Asynchronously updates the system prompt for the given source_id with custom content.
|
|
624
|
+
|
|
625
|
+
Args:
|
|
626
|
+
source_id (str): The ID of the source to update the system prompt for
|
|
627
|
+
content (str): The custom content for the system prompt
|
|
628
|
+
|
|
629
|
+
Returns:
|
|
630
|
+
SystemPrompt: The updated system prompt
|
|
631
|
+
"""
|
|
632
|
+
requestor = api_requestor.APIRequestor(
|
|
633
|
+
client=self._client,
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
parameter_payload = SystemPromptUpdateRequest(content=content).model_dump()
|
|
637
|
+
|
|
638
|
+
response, _, _ = await requestor.arequest(
|
|
639
|
+
options=SeekrFlowRequest(
|
|
640
|
+
method="PUT",
|
|
641
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
642
|
+
params=parameter_payload,
|
|
643
|
+
),
|
|
644
|
+
stream=False,
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
648
|
+
return SystemPrompt(**response.data)
|
|
649
|
+
|
|
650
|
+
async def delete(self, source_id: str) -> Dict[str, Any]:
|
|
651
|
+
"""
|
|
652
|
+
Asynchronously deletes the system prompt for the given source_id.
|
|
653
|
+
|
|
654
|
+
Args:
|
|
655
|
+
source_id (str): The ID of the source to delete the system prompt for
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
dict: A dictionary with the deletion result
|
|
659
|
+
"""
|
|
660
|
+
requestor = api_requestor.APIRequestor(
|
|
661
|
+
client=self._client,
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
response, _, _ = await requestor.arequest(
|
|
665
|
+
options=SeekrFlowRequest(
|
|
666
|
+
method="DELETE",
|
|
667
|
+
url=f"flow/alignment/system_prompt/{source_id}",
|
|
668
|
+
),
|
|
669
|
+
stream=False,
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
assert isinstance(response, SeekrFlowResponse)
|
|
673
|
+
return response.data
|
|
@@ -2,7 +2,6 @@ from typing import Optional
|
|
|
2
2
|
|
|
3
3
|
from seekrai.abstract import api_requestor
|
|
4
4
|
from seekrai.resources.resource_base import ResourceBase
|
|
5
|
-
from seekrai.seekrflow_response import SeekrFlowResponse
|
|
6
5
|
from seekrai.types import (
|
|
7
6
|
SeekrFlowRequest,
|
|
8
7
|
)
|
|
@@ -14,15 +13,19 @@ from seekrai.types.explainability import (
|
|
|
14
13
|
|
|
15
14
|
class Explainability(ResourceBase):
|
|
16
15
|
def get_influential_finetuning_data(
|
|
17
|
-
self,
|
|
16
|
+
self,
|
|
17
|
+
model_id: str,
|
|
18
|
+
question: str,
|
|
19
|
+
system_prompt: Optional[str] = None,
|
|
20
|
+
answer: Optional[str] = None,
|
|
18
21
|
) -> InfluentialFinetuningDataResponse:
|
|
19
22
|
"""
|
|
20
23
|
Retrieve influential QA pair fine tuning data for a specific model.
|
|
21
24
|
Args:
|
|
22
25
|
- model_id (str): ID of the model to explain.
|
|
23
26
|
- question (str): question from user,
|
|
27
|
+
- system_prompt (str | None): System prompt for the user's question.
|
|
24
28
|
- answer (str | None): answer of the finetuned model to the question; if None, the answer is retrieved from the finetuned model specified by model_id,
|
|
25
|
-
- k (int): the number of results to be retrieved (5 by default)
|
|
26
29
|
Returns:
|
|
27
30
|
InfluentialFinetuningDataResponse: Object containing the influential fine tuning data.
|
|
28
31
|
"""
|
|
@@ -31,7 +34,7 @@ class Explainability(ResourceBase):
|
|
|
31
34
|
)
|
|
32
35
|
# Create query parameters dictionary
|
|
33
36
|
parameter_payload = InfluentialFinetuningDataRequest(
|
|
34
|
-
question=question,
|
|
37
|
+
question=question, system_prompt=system_prompt, answer=answer
|
|
35
38
|
).model_dump()
|
|
36
39
|
|
|
37
40
|
# if limit is not None:
|
|
@@ -41,26 +44,29 @@ class Explainability(ResourceBase):
|
|
|
41
44
|
response, _, _ = requestor.request(
|
|
42
45
|
options=SeekrFlowRequest(
|
|
43
46
|
method="GET",
|
|
44
|
-
url=f"
|
|
47
|
+
url=f"flow/explain/models/{model_id}/influential-finetuning-data",
|
|
45
48
|
params=parameter_payload,
|
|
46
49
|
),
|
|
47
50
|
stream=False,
|
|
48
51
|
)
|
|
49
|
-
assert isinstance(response, SeekrFlowResponse)
|
|
50
52
|
return InfluentialFinetuningDataResponse(**response.data)
|
|
51
53
|
|
|
52
54
|
|
|
53
55
|
class AsyncExplainability(ResourceBase):
|
|
54
56
|
async def get_influential_finetuning_data(
|
|
55
|
-
self,
|
|
57
|
+
self,
|
|
58
|
+
model_id: str,
|
|
59
|
+
question: str,
|
|
60
|
+
system_prompt: Optional[str] = None,
|
|
61
|
+
answer: Optional[str] = None,
|
|
56
62
|
) -> InfluentialFinetuningDataResponse:
|
|
57
63
|
"""
|
|
58
64
|
Retrieve influential QA pair finetuning data for a specific model asynchronously.
|
|
59
65
|
Args:
|
|
60
66
|
- model_id (str): ID of the model to explain.
|
|
61
67
|
- question (str): question from user,
|
|
68
|
+
- system_prompt (str | None): System prompt for the user's question.
|
|
62
69
|
- answer (str | None): answer of the finetuned model to the question; if None, the answer is retrieved from the finetuned model specified by model_id,
|
|
63
|
-
- k (int): the number of results to be retrieved (5 by default),
|
|
64
70
|
Returns:
|
|
65
71
|
InfluentialFinetuningDataResponse: Object containing the influential finetuning data.
|
|
66
72
|
"""
|
|
@@ -69,16 +75,18 @@ class AsyncExplainability(ResourceBase):
|
|
|
69
75
|
)
|
|
70
76
|
# Create query parameters dictionary
|
|
71
77
|
parameter_payload = InfluentialFinetuningDataRequest(
|
|
72
|
-
model_id=model_id,
|
|
78
|
+
model_id=model_id,
|
|
79
|
+
question=question,
|
|
80
|
+
system_prompt=system_prompt,
|
|
81
|
+
answer=answer,
|
|
73
82
|
).model_dump()
|
|
74
83
|
|
|
75
84
|
response, _, _ = await requestor.arequest(
|
|
76
85
|
options=SeekrFlowRequest(
|
|
77
86
|
method="GET",
|
|
78
|
-
url=f"
|
|
87
|
+
url=f"flow/explain/models/{model_id}/influential-finetuning-data",
|
|
79
88
|
params=parameter_payload,
|
|
80
89
|
),
|
|
81
90
|
stream=False,
|
|
82
91
|
)
|
|
83
|
-
assert isinstance(response, SeekrFlowResponse)
|
|
84
92
|
return InfluentialFinetuningDataResponse(**response.data)
|
seekrai/resources/finetune.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
from seekrai.abstract import api_requestor
|
|
6
|
+
from seekrai.error import InvalidRequestError
|
|
6
7
|
from seekrai.resources.resource_base import ResourceBase
|
|
7
8
|
from seekrai.seekrflow_response import SeekrFlowResponse
|
|
8
9
|
from seekrai.types import (
|
|
@@ -17,6 +18,29 @@ from seekrai.types import (
|
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
21
|
+
def validate_lora_support(
|
|
22
|
+
models_response: SeekrFlowResponse, training_config: TrainingConfig
|
|
23
|
+
) -> None:
|
|
24
|
+
assert isinstance(models_response, SeekrFlowResponse)
|
|
25
|
+
model_entry = None
|
|
26
|
+
for model in models_response.data.get("data", []):
|
|
27
|
+
model_id = str(model.get("id")) if model.get("id") is not None else None
|
|
28
|
+
if (
|
|
29
|
+
model_id == training_config.model
|
|
30
|
+
or model.get("name") == training_config.model
|
|
31
|
+
):
|
|
32
|
+
model_entry = model
|
|
33
|
+
break
|
|
34
|
+
if not model_entry:
|
|
35
|
+
raise InvalidRequestError(
|
|
36
|
+
f"Model '{training_config.model}' not found; cannot enable LoRA."
|
|
37
|
+
)
|
|
38
|
+
if not model_entry.get("supports_lora", False):
|
|
39
|
+
raise InvalidRequestError(
|
|
40
|
+
f"Model '{training_config.model}' does not support LoRA fine-tuning."
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
20
44
|
class FineTuning(ResourceBase):
|
|
21
45
|
def create(
|
|
22
46
|
self,
|
|
@@ -39,6 +63,16 @@ class FineTuning(ResourceBase):
|
|
|
39
63
|
client=self._client,
|
|
40
64
|
)
|
|
41
65
|
|
|
66
|
+
if training_config.lora_config is not None:
|
|
67
|
+
models_response, _, _ = requestor.request(
|
|
68
|
+
options=SeekrFlowRequest(
|
|
69
|
+
method="GET",
|
|
70
|
+
url="flow/models",
|
|
71
|
+
),
|
|
72
|
+
stream=False,
|
|
73
|
+
)
|
|
74
|
+
validate_lora_support(models_response, training_config)
|
|
75
|
+
|
|
42
76
|
parameter_payload = FinetuneRequest(
|
|
43
77
|
project_id=project_id,
|
|
44
78
|
training_config=training_config,
|
|
@@ -263,6 +297,16 @@ class AsyncFineTuning(ResourceBase):
|
|
|
263
297
|
client=self._client,
|
|
264
298
|
)
|
|
265
299
|
|
|
300
|
+
if training_config.lora_config is not None:
|
|
301
|
+
models_response, _, _ = await requestor.arequest(
|
|
302
|
+
options=SeekrFlowRequest(
|
|
303
|
+
method="GET",
|
|
304
|
+
url="flow/models",
|
|
305
|
+
),
|
|
306
|
+
stream=False,
|
|
307
|
+
)
|
|
308
|
+
validate_lora_support(models_response, training_config)
|
|
309
|
+
|
|
266
310
|
parameter_payload = FinetuneRequest(
|
|
267
311
|
project_id=project_id,
|
|
268
312
|
training_config=training_config,
|
seekrai/resources/ingestion.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import List, Optional
|
|
2
2
|
|
|
3
3
|
from seekrai.abstract import api_requestor
|
|
4
4
|
from seekrai.resources.resource_base import ResourceBase
|
|
@@ -13,6 +13,7 @@ class Ingestion(ResourceBase):
|
|
|
13
13
|
def ingest(
|
|
14
14
|
self,
|
|
15
15
|
files: List[str],
|
|
16
|
+
method: Optional[str] = "accuracy-optimized",
|
|
16
17
|
) -> IngestionResponse:
|
|
17
18
|
"""
|
|
18
19
|
Start an ingestion job for the specified files.
|
|
@@ -27,9 +28,7 @@ class Ingestion(ResourceBase):
|
|
|
27
28
|
client=self._client,
|
|
28
29
|
)
|
|
29
30
|
|
|
30
|
-
parameter_payload = IngestionRequest(
|
|
31
|
-
files=files,
|
|
32
|
-
).model_dump()
|
|
31
|
+
parameter_payload = IngestionRequest(files=files, method=method).model_dump()
|
|
33
32
|
|
|
34
33
|
response, _, _ = requestor.request(
|
|
35
34
|
options=SeekrFlowRequest(
|
|
@@ -95,6 +94,7 @@ class AsyncIngestion(ResourceBase):
|
|
|
95
94
|
async def ingest(
|
|
96
95
|
self,
|
|
97
96
|
files: List[str],
|
|
97
|
+
method: Optional[str] = "accuracy-optimized",
|
|
98
98
|
) -> IngestionResponse:
|
|
99
99
|
"""
|
|
100
100
|
Start an ingestion job for the specified files asynchronously.
|
|
@@ -109,9 +109,7 @@ class AsyncIngestion(ResourceBase):
|
|
|
109
109
|
client=self._client,
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
parameter_payload = IngestionRequest(
|
|
113
|
-
files=files,
|
|
114
|
-
).model_dump()
|
|
112
|
+
parameter_payload = IngestionRequest(files=files, method=method).model_dump()
|
|
115
113
|
|
|
116
114
|
response, _, _ = await requestor.arequest(
|
|
117
115
|
options=SeekrFlowRequest(
|
seekrai/resources/vectordb.py
CHANGED
|
@@ -107,7 +107,8 @@ class VectorDatabase(ResourceBase):
|
|
|
107
107
|
self,
|
|
108
108
|
database_id: str,
|
|
109
109
|
files: List[str],
|
|
110
|
-
method: str,
|
|
110
|
+
method: Optional[str] = "accuracy-optimized",
|
|
111
|
+
chunking_method: Optional[str] = "markdown",
|
|
111
112
|
token_count: int = 800,
|
|
112
113
|
overlap_tokens: int = 100,
|
|
113
114
|
) -> VectorDatabaseIngestionResponse:
|
|
@@ -129,6 +130,7 @@ class VectorDatabase(ResourceBase):
|
|
|
129
130
|
parameter_payload = VectorDatabaseIngestionRequest(
|
|
130
131
|
file_ids=files,
|
|
131
132
|
method=method,
|
|
133
|
+
chunking_method=chunking_method,
|
|
132
134
|
token_count=token_count,
|
|
133
135
|
overlap_tokens=overlap_tokens,
|
|
134
136
|
).model_dump()
|
|
@@ -248,6 +250,21 @@ class VectorDatabase(ResourceBase):
|
|
|
248
250
|
# The endpoint returns 204 No Content
|
|
249
251
|
return None
|
|
250
252
|
|
|
253
|
+
def delete_file(self, database_id: str, file_id: str) -> None:
|
|
254
|
+
"""Delete a file from a vector database."""
|
|
255
|
+
requestor = api_requestor.APIRequestor(client=self._client)
|
|
256
|
+
|
|
257
|
+
response, _, _ = requestor.request(
|
|
258
|
+
options=SeekrFlowRequest(
|
|
259
|
+
method="DELETE",
|
|
260
|
+
url=f"flow/vectordb/{database_id}/files/{file_id}",
|
|
261
|
+
),
|
|
262
|
+
stream=False,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
# The endpoint returns 204 No Content
|
|
266
|
+
return None
|
|
267
|
+
|
|
251
268
|
|
|
252
269
|
class AsyncVectorDatabase(ResourceBase):
|
|
253
270
|
async def create(
|
|
@@ -338,7 +355,8 @@ class AsyncVectorDatabase(ResourceBase):
|
|
|
338
355
|
self,
|
|
339
356
|
database_id: str,
|
|
340
357
|
files: List[str],
|
|
341
|
-
method: str,
|
|
358
|
+
method: Optional[str] = "accuracy-optimized",
|
|
359
|
+
chunking_method: Optional[str] = "markdown",
|
|
342
360
|
token_count: int = 800,
|
|
343
361
|
overlap_tokens: int = 100,
|
|
344
362
|
) -> VectorDatabaseIngestionResponse:
|
|
@@ -360,6 +378,7 @@ class AsyncVectorDatabase(ResourceBase):
|
|
|
360
378
|
parameter_payload = VectorDatabaseIngestionRequest(
|
|
361
379
|
file_ids=files,
|
|
362
380
|
method=method,
|
|
381
|
+
chunking_method=chunking_method,
|
|
363
382
|
token_count=token_count,
|
|
364
383
|
overlap_tokens=overlap_tokens,
|
|
365
384
|
).model_dump()
|
|
@@ -480,3 +499,18 @@ class AsyncVectorDatabase(ResourceBase):
|
|
|
480
499
|
|
|
481
500
|
# The endpoint returns 204 No Content
|
|
482
501
|
return None
|
|
502
|
+
|
|
503
|
+
async def delete_file(self, database_id: str, file_id: str) -> None:
|
|
504
|
+
"""Delete a file from a vector database asynchronously."""
|
|
505
|
+
requestor = api_requestor.APIRequestor(client=self._client)
|
|
506
|
+
|
|
507
|
+
response, _, _ = await requestor.arequest(
|
|
508
|
+
options=SeekrFlowRequest(
|
|
509
|
+
method="DELETE",
|
|
510
|
+
url=f"flow/vectordb/{database_id}/files/{file_id}",
|
|
511
|
+
),
|
|
512
|
+
stream=False,
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
# The endpoint returns 204 No Content
|
|
516
|
+
return None
|
seekrai/types/__init__.py
CHANGED
|
@@ -61,9 +61,13 @@ from seekrai.types.alignment import (
|
|
|
61
61
|
AlignmentEstimationResponse,
|
|
62
62
|
AlignmentJobStatus,
|
|
63
63
|
AlignmentList,
|
|
64
|
+
AlignmentOutput,
|
|
64
65
|
AlignmentRequest,
|
|
65
66
|
AlignmentResponse,
|
|
66
67
|
AlignmentType,
|
|
68
|
+
SystemPrompt,
|
|
69
|
+
SystemPromptCreateRequest,
|
|
70
|
+
SystemPromptUpdateRequest,
|
|
67
71
|
)
|
|
68
72
|
from seekrai.types.chat_completions import (
|
|
69
73
|
ChatCompletionChunk,
|
|
@@ -102,6 +106,7 @@ from seekrai.types.finetune import (
|
|
|
102
106
|
FinetuneRequest,
|
|
103
107
|
FinetuneResponse,
|
|
104
108
|
InfrastructureConfig,
|
|
109
|
+
LoRAConfig,
|
|
105
110
|
TrainingConfig,
|
|
106
111
|
)
|
|
107
112
|
from seekrai.types.images import (
|
|
@@ -135,6 +140,7 @@ __all__ = [
|
|
|
135
140
|
"FinetuneDownloadResult",
|
|
136
141
|
"InfrastructureConfig",
|
|
137
142
|
"TrainingConfig",
|
|
143
|
+
"LoRAConfig",
|
|
138
144
|
"FileRequest",
|
|
139
145
|
"FileResponse",
|
|
140
146
|
"FileList",
|
|
@@ -151,8 +157,12 @@ __all__ = [
|
|
|
151
157
|
"AlignmentEstimationResponse",
|
|
152
158
|
"AlignmentResponse",
|
|
153
159
|
"AlignmentJobStatus",
|
|
160
|
+
"AlignmentOutput",
|
|
154
161
|
"AlignmentList",
|
|
155
162
|
"AlignmentType",
|
|
163
|
+
"SystemPrompt",
|
|
164
|
+
"SystemPromptCreateRequest",
|
|
165
|
+
"SystemPromptUpdateRequest",
|
|
156
166
|
"Project",
|
|
157
167
|
"ProjectWithRuns",
|
|
158
168
|
"GetProjectsResponse",
|
seekrai/types/alignment.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import List, Literal, Optional
|
|
|
7
7
|
from pydantic import Field
|
|
8
8
|
|
|
9
9
|
from seekrai.types.abstract import BaseModel
|
|
10
|
+
from seekrai.types.files import FilePurpose, FileType
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class AlignmentType(str, Enum):
|
|
@@ -16,6 +17,28 @@ class AlignmentType(str, Enum):
|
|
|
16
17
|
CONTEXT_DATA = "context_data"
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
class SystemPrompt(BaseModel):
|
|
21
|
+
id: str
|
|
22
|
+
source_id: str
|
|
23
|
+
content: str
|
|
24
|
+
is_custom: bool
|
|
25
|
+
created_at: datetime | None = None
|
|
26
|
+
updated_at: datetime | None = None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SystemPromptRequest(BaseModel):
|
|
30
|
+
instructions: str | None = None
|
|
31
|
+
content: str | None = None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class SystemPromptCreateRequest(BaseModel):
|
|
35
|
+
instructions: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SystemPromptUpdateRequest(BaseModel):
|
|
39
|
+
content: str
|
|
40
|
+
|
|
41
|
+
|
|
19
42
|
class AlignmentRequest(BaseModel):
|
|
20
43
|
instructions: str = Field(
|
|
21
44
|
default=..., description="Task description/instructions for the alignment task"
|
|
@@ -27,6 +50,10 @@ class AlignmentRequest(BaseModel):
|
|
|
27
50
|
default=AlignmentType.PRINCIPLE,
|
|
28
51
|
description="Type of alignment task (principle, chain_of_thought, or context_data)",
|
|
29
52
|
)
|
|
53
|
+
vector_database_id: str | None = Field(
|
|
54
|
+
default=None,
|
|
55
|
+
description="Optional vector database id to use for context retrieval during context_data alignment",
|
|
56
|
+
)
|
|
30
57
|
|
|
31
58
|
|
|
32
59
|
class AlignmentEstimationRequest(BaseModel):
|
|
@@ -66,6 +93,15 @@ class AlignmentResponse(BaseModel):
|
|
|
66
93
|
progress: str | None = None
|
|
67
94
|
|
|
68
95
|
|
|
96
|
+
class AlignmentOutput(BaseModel):
|
|
97
|
+
id: str
|
|
98
|
+
filename: str
|
|
99
|
+
bytes: int | None = None
|
|
100
|
+
created_at: datetime | None = None
|
|
101
|
+
file_type: FileType | None = None
|
|
102
|
+
purpose: FilePurpose | None = None
|
|
103
|
+
|
|
104
|
+
|
|
69
105
|
class AlignmentList(BaseModel):
|
|
70
106
|
# object type
|
|
71
107
|
object: Literal["list"] | None = None
|
seekrai/types/deployments.py
CHANGED
seekrai/types/explainability.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from enum import Enum
|
|
5
|
-
from typing import Any, Dict, List, Literal
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
6
4
|
|
|
7
5
|
from pydantic import Field
|
|
8
6
|
|
|
@@ -10,48 +8,19 @@ from seekrai.types.abstract import BaseModel
|
|
|
10
8
|
|
|
11
9
|
|
|
12
10
|
class InfluentialFinetuningDataResponse(BaseModel):
|
|
13
|
-
results: List[Dict[str, Any]]
|
|
14
|
-
|
|
11
|
+
results: List[Dict[str, Any]] = Field(
|
|
12
|
+
..., description="List of influential training data results"
|
|
13
|
+
)
|
|
14
|
+
version: str = Field(..., description="Version of the explainability service")
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class InfluentialFinetuningDataRequest(BaseModel):
|
|
18
|
-
question: str
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
description="
|
|
18
|
+
question: str = Field(..., description="Question from user")
|
|
19
|
+
system_prompt: Optional[str] = Field(
|
|
20
|
+
None,
|
|
21
|
+
description="System prompt for the user's question.",
|
|
22
22
|
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class ExplainabilityJobStatus(Enum):
|
|
27
|
-
QUEUED = "queued"
|
|
28
|
-
RUNNING = "running"
|
|
29
|
-
COMPLETED = "completed"
|
|
30
|
-
FAILED = "failed"
|
|
31
|
-
|
|
32
|
-
# TODO should titles along the following get added:
|
|
33
|
-
# create_index
|
|
34
|
-
# populate_index
|
|
35
|
-
# delete_index
|
|
36
|
-
# influential-finetuning-data
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ExplainabilityRequest(BaseModel):
|
|
40
|
-
files: List[str] = Field(
|
|
41
|
-
default=..., description="List of file ids to use for fine tuning"
|
|
23
|
+
answer: Optional[str] = Field(
|
|
24
|
+
None,
|
|
25
|
+
description="Answer of the finetuned model to the question; if None, the answer is retrieved from the finetuned model",
|
|
42
26
|
)
|
|
43
|
-
method: str = Field(default="best", description="Method to use for explainability")
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class ExplainabilityResponse(BaseModel):
|
|
47
|
-
id: str = Field(default=..., description="Explainability job ID")
|
|
48
|
-
created_at: datetime
|
|
49
|
-
status: ExplainabilityJobStatus
|
|
50
|
-
output_files: List[str]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class ExplainabilityList(BaseModel):
|
|
54
|
-
# object type
|
|
55
|
-
object: Literal["list"] | None = None
|
|
56
|
-
# list of fine-tune job objects
|
|
57
|
-
data: List[ExplainabilityResponse] | None = None
|
seekrai/types/files.py
CHANGED
seekrai/types/finetune.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from enum import Enum
|
|
5
|
-
from typing import List, Literal, Optional
|
|
5
|
+
from typing import Any, Dict, List, Literal, Optional
|
|
6
6
|
|
|
7
7
|
from pydantic import Field
|
|
8
8
|
|
|
@@ -95,6 +95,22 @@ class FinetuneEvent(BaseModel):
|
|
|
95
95
|
epoch: float | None = None
|
|
96
96
|
|
|
97
97
|
|
|
98
|
+
class LoRAConfig(BaseModel):
|
|
99
|
+
r: int = Field(8, gt=0, description="Rank of the update matrices.")
|
|
100
|
+
alpha: int = Field(32, gt=0, description="Scaling factor applied to LoRA updates.")
|
|
101
|
+
dropout: float = Field(
|
|
102
|
+
0.1,
|
|
103
|
+
ge=0.0,
|
|
104
|
+
le=1.0,
|
|
105
|
+
description="Fraction of LoRA neurons dropped during training.",
|
|
106
|
+
)
|
|
107
|
+
bias: Literal["none", "all", "lora_only"] = Field(
|
|
108
|
+
"none",
|
|
109
|
+
description="Bias terms to train; choose from 'none', 'all', or 'lora_only'.",
|
|
110
|
+
)
|
|
111
|
+
extras: Dict[str, Any] = Field(default_factory=dict)
|
|
112
|
+
|
|
113
|
+
|
|
98
114
|
class TrainingConfig(BaseModel):
|
|
99
115
|
# training file ID
|
|
100
116
|
training_files: List[str]
|
|
@@ -118,6 +134,8 @@ class TrainingConfig(BaseModel):
|
|
|
118
134
|
pre_train: bool = False
|
|
119
135
|
# fine-tune type
|
|
120
136
|
fine_tune_type: FineTuneType = FineTuneType.STANDARD
|
|
137
|
+
# LoRA config
|
|
138
|
+
lora_config: Optional[LoRAConfig] = None
|
|
121
139
|
|
|
122
140
|
|
|
123
141
|
class AcceleratorType(str, Enum):
|
|
@@ -132,6 +150,7 @@ class AcceleratorType(str, Enum):
|
|
|
132
150
|
class InfrastructureConfig(BaseModel):
|
|
133
151
|
accel_type: AcceleratorType
|
|
134
152
|
n_accel: int
|
|
153
|
+
n_node: int = 1
|
|
135
154
|
|
|
136
155
|
|
|
137
156
|
class FinetuneRequest(BaseModel):
|
|
@@ -161,6 +180,7 @@ class FinetuneResponse(BaseModel):
|
|
|
161
180
|
model: str | None = None
|
|
162
181
|
accel_type: AcceleratorType
|
|
163
182
|
n_accel: int
|
|
183
|
+
n_node: int | None = None
|
|
164
184
|
# number of epochs
|
|
165
185
|
n_epochs: int | None = None
|
|
166
186
|
# number of checkpoints to save
|
|
@@ -169,13 +189,10 @@ class FinetuneResponse(BaseModel):
|
|
|
169
189
|
batch_size: int | None = None
|
|
170
190
|
# training learning rate
|
|
171
191
|
learning_rate: float | None = None
|
|
192
|
+
# LoRA configuration returned when LoRA fine-tuning is enabled
|
|
193
|
+
lora_config: Optional[LoRAConfig] = None
|
|
172
194
|
# number of steps between evals
|
|
173
195
|
# eval_steps: int | None = None TODO
|
|
174
|
-
# is LoRA finetune boolean
|
|
175
|
-
# lora: bool | None = None
|
|
176
|
-
# lora_r: int | None = None
|
|
177
|
-
# lora_alpha: int | None = None
|
|
178
|
-
# lora_dropout: int | None = None
|
|
179
196
|
# created/updated datetime stamps
|
|
180
197
|
created_at: datetime | None = None
|
|
181
198
|
# updated_at: str | None = None
|
seekrai/types/vectordb.py
CHANGED
|
@@ -37,7 +37,12 @@ class VectorDatabaseIngestionRequest(BaseModel):
|
|
|
37
37
|
"""Request model for creating a new vector database ingestion job."""
|
|
38
38
|
|
|
39
39
|
file_ids: List[str] = Field(..., description="List of file IDs to ingest")
|
|
40
|
-
method: str = Field(
|
|
40
|
+
method: Optional[str] = Field(
|
|
41
|
+
default="accuracy-optimized", description="Method to use for ingestion"
|
|
42
|
+
)
|
|
43
|
+
chunking_method: Optional[str] = Field(
|
|
44
|
+
default="markdown", description="Configure how your content will be segmented"
|
|
45
|
+
)
|
|
41
46
|
token_count: int = Field(default=800, description="Token count for ingestion")
|
|
42
47
|
overlap_tokens: int = Field(default=100, description="Overlap tokens for ingestion")
|
|
43
48
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: seekrai
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.24
|
|
4
4
|
Summary: Python client for SeekrAI
|
|
5
|
+
Home-page: https://www.seekr.com
|
|
5
6
|
License: Apache-2.0
|
|
6
7
|
Author: SeekrFlow
|
|
7
8
|
Author-email: support@seekr.com
|
|
@@ -12,8 +13,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
16
|
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
18
17
|
Requires-Dist: eval-type-backport (>=0.1.3,<0.3.0)
|
|
19
18
|
Requires-Dist: filelock (>=3.13.1,<4.0.0)
|
|
@@ -27,8 +26,6 @@ Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
|
27
26
|
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
28
27
|
Requires-Dist: tqdm (>=4.66.2,<5.0.0)
|
|
29
28
|
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
29
|
Description-Content-Type: text/markdown
|
|
33
30
|
|
|
34
31
|
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.9+ applications with easy to use synchronous and asynchronous clients.
|
|
@@ -2,34 +2,34 @@ seekrai/__init__.py,sha256=b3kBCTm-FoxCrNJ4hDieNBNN3Cj2xvevMUXEJQbntiE,900
|
|
|
2
2
|
seekrai/abstract/__init__.py,sha256=wNiOTW9TJpUgfCJCG-wAbhhWWH2PtoVpAuL3nxvQGps,56
|
|
3
3
|
seekrai/abstract/api_requestor.py,sha256=MfAEHsmjzjHM3Vr3BrNu2Oy_4YmDC5pHeYPFrtd9yAs,13582
|
|
4
4
|
seekrai/abstract/response_parsing.py,sha256=saREmIuJAPMkrzypR8zzFNAQwdF6wXn6VkXfFSQ_Ots,2931
|
|
5
|
-
seekrai/client.py,sha256=
|
|
5
|
+
seekrai/client.py,sha256=draieBBL6sp5VP5BRZiTudTIvVhhUHE_WhxP48CV5VU,6468
|
|
6
6
|
seekrai/constants.py,sha256=hoR2iF5te5Ydjt_lxIOSGID4vESIakG4F-3xAWdwxaU,1854
|
|
7
7
|
seekrai/error.py,sha256=rAYL8qEd8INwYMMKvhS-HKeC3QkWL4Wq-zfazFU-zBg,4861
|
|
8
8
|
seekrai/filemanager.py,sha256=bO2OvjZ9Cx5r2vr3Ocpd_0qVc3owRDT2LCU4Zmp2uDY,15489
|
|
9
|
-
seekrai/resources/__init__.py,sha256=
|
|
9
|
+
seekrai/resources/__init__.py,sha256=wEZO13NvzzRAZ67oYUaXWxfp-PhECRL-EpltmJubS5w,1759
|
|
10
10
|
seekrai/resources/agents/__init__.py,sha256=8zQIr2LEJyuaVwbU6WmItGu0F8VWTa7eYrquyHUY1QY,700
|
|
11
11
|
seekrai/resources/agents/agent_inference.py,sha256=KIxdEV9qMA7tscrVGp4-Fe1H_iBqdY7Oh7rkpPDNfjo,10568
|
|
12
12
|
seekrai/resources/agents/agent_observability.py,sha256=VC_iyJnTwZ6PdQPp0T9XzipXOruh8P7h_UCwLjbY1Sk,4253
|
|
13
13
|
seekrai/resources/agents/agents.py,sha256=frmLHvrqeUxnMkE9Xn4w1ugChM14S9ik4MwWyklPMWI,9607
|
|
14
14
|
seekrai/resources/agents/python_functions.py,sha256=VL1JSsPP5nN1m8I0Ihe3AYlb8TMRg2n9-FWsWeNZH2s,9277
|
|
15
15
|
seekrai/resources/agents/threads.py,sha256=BwZ2_6wlezsb12PQjEw1fgdJh5S83SPgD6qZQoGvyIM,14544
|
|
16
|
-
seekrai/resources/alignment.py,sha256=
|
|
16
|
+
seekrai/resources/alignment.py,sha256=htpwu41NPOb_3aAM6fCilVBcEXlzIYF_req-Cf6OrpI,19627
|
|
17
17
|
seekrai/resources/chat/__init__.py,sha256=KmtPupgECtEN80NyvcnSmieTAFXhwmVxhMHP0qhspA4,618
|
|
18
18
|
seekrai/resources/chat/completions.py,sha256=-nFk5aL1ejZ9WUi_ksDHqCnEnT2CjPX-RaigT3N35gA,12317
|
|
19
19
|
seekrai/resources/completions.py,sha256=JhTN_lW2mblfHHONFmPC7QZei3wo5vx6GliMs9FkbOY,8452
|
|
20
20
|
seekrai/resources/deployments.py,sha256=DY7IN7QgqDduCHGNuHENSVwrE5PXFL88jWgh8SES7Qk,5970
|
|
21
21
|
seekrai/resources/embeddings.py,sha256=7G-VisYrT9J35-hcKB8cXhs8BSi93IfveQKfVSC7diA,2585
|
|
22
|
-
seekrai/resources/explainability.py,sha256=
|
|
22
|
+
seekrai/resources/explainability.py,sha256=Z0JllD5ruvrMu7fbgVlKuUOHkMIO1x9FWbFRao2TLm8,3546
|
|
23
23
|
seekrai/resources/files.py,sha256=bEn4jfYWfsI2OqKRGCUpnefIN-udNnafItgT2A7m-e4,15329
|
|
24
|
-
seekrai/resources/finetune.py,sha256=
|
|
24
|
+
seekrai/resources/finetune.py,sha256=BFtNE0nq_jQ6B3RLPCI2ytPGrkxebO2TKsq3J4hAo3E,12898
|
|
25
25
|
seekrai/resources/images.py,sha256=VjZiU2cxq2uNrJzm-EwNpOW3rBIgFyRHss8_DF1OuVE,4799
|
|
26
|
-
seekrai/resources/ingestion.py,sha256=
|
|
26
|
+
seekrai/resources/ingestion.py,sha256=RPnUWbHJCXRwVT4BUhmdE5nH4xD8JQBiR2zYrMJsywY,4956
|
|
27
27
|
seekrai/resources/models.py,sha256=q_lW0yzumasl4xTMg5jEDcyaycWe8Gm9C_ibRHWVxZM,2246
|
|
28
28
|
seekrai/resources/projects.py,sha256=Nmuh0_BwWoAO89r-p0ZEM8p4NHIH1EUeP83ivRoW5hw,3682
|
|
29
29
|
seekrai/resources/resource_base.py,sha256=rFIHFeqKPiAEbMYcMiIGHIym7qxwmh-EGsWiZcMDHdk,224
|
|
30
|
-
seekrai/resources/vectordb.py,sha256=
|
|
30
|
+
seekrai/resources/vectordb.py,sha256=1uUsyCUJdVAVUnua9RJWqf-j0HDD74EPeERUBjqVvmg,15797
|
|
31
31
|
seekrai/seekrflow_response.py,sha256=5RFEQzamDy7sTSDkxSsZQThZ3biNmeCPeHWdrFId5Go,1320
|
|
32
|
-
seekrai/types/__init__.py,sha256=
|
|
32
|
+
seekrai/types/__init__.py,sha256=042qPXVpS5DZe8ZWV67cBu1PD2JB3IPi6_1O2G0MOQE,4909
|
|
33
33
|
seekrai/types/abstract.py,sha256=TqWFQV_6bPblywfCH-r8FCkXWvPkc9KlJ4QVgyrnaMc,642
|
|
34
34
|
seekrai/types/agents/__init__.py,sha256=STRQlgnapxFT5egAP_i3yZSh9gauGmJBHTzdvH8tbdk,2395
|
|
35
35
|
seekrai/types/agents/agent.py,sha256=85D4GeHF-bYYnPirJSi1MbFg_2uFE2fSEmAHV9LxZfQ,1132
|
|
@@ -48,29 +48,29 @@ seekrai/types/agents/tools/schemas/web_search.py,sha256=HrcVIC-SQGlBIXvJ0MxXYVQe
|
|
|
48
48
|
seekrai/types/agents/tools/schemas/web_search_env.py,sha256=aHaricIcXaWz9N4G_gEipstANPbJPf41F9VZC5LwPog,182
|
|
49
49
|
seekrai/types/agents/tools/tool.py,sha256=rX-SoN-XgweiHQIKRhNxBWK4ClNjEiXv-YaLdejpgmc,397
|
|
50
50
|
seekrai/types/agents/tools/tool_types.py,sha256=1tF_kE6Z_zzuZpOAK1HrHsHkXFPEoK0PdYv-pbTLfkY,360
|
|
51
|
-
seekrai/types/alignment.py,sha256=
|
|
51
|
+
seekrai/types/alignment.py,sha256=nWcc4kQLs40-T0_HC3MnGkLd-StwBvwCXQrjUVJ5dEI,2973
|
|
52
52
|
seekrai/types/chat_completions.py,sha256=Z7H1MkMgb4O0O5LDMKotQqhjGVCYk5eBeZ8n--RJpf8,3736
|
|
53
53
|
seekrai/types/common.py,sha256=YI1pE-i_lDLU2o6FjoINdIhPXsV9lUl2MeAg2aRtT-M,2062
|
|
54
54
|
seekrai/types/completions.py,sha256=lm9AFdZR3Xg5AHPkV-qETHikkwMJmkHrLGr5GG-YR-M,2171
|
|
55
|
-
seekrai/types/deployments.py,sha256=
|
|
55
|
+
seekrai/types/deployments.py,sha256=a0zew1DuB9vPQXcBT2R4Tdn_8z5qleh6V6i4T4xyYZo,1798
|
|
56
56
|
seekrai/types/embeddings.py,sha256=OANoLNOs0aceS8NppVvvcNYQbF7-pAOAmcr30pw64OU,749
|
|
57
57
|
seekrai/types/error.py,sha256=uTKISs9aRC4_6zwirtNkanxepN8KY-SqCq0kNbfZylQ,370
|
|
58
|
-
seekrai/types/explainability.py,sha256=
|
|
59
|
-
seekrai/types/files.py,sha256=
|
|
60
|
-
seekrai/types/finetune.py,sha256=
|
|
58
|
+
seekrai/types/explainability.py,sha256=Ih-8hCm5r22EMMtr83cDy8vePo7_Ik7UdUcXhsj5Zm0,835
|
|
59
|
+
seekrai/types/files.py,sha256=EMlkjQQdQlBfYefJcf8eyKqFddafjTcOPCP9k7ZXDh0,2760
|
|
60
|
+
seekrai/types/finetune.py,sha256=ZhmLTw9rLIqJUib0CObKXJxdb_nYxv94IQrrvF9vFXQ,7204
|
|
61
61
|
seekrai/types/images.py,sha256=Fusj8OhVYFsT8kz636lRGGivLbPXo_ZNgakKwmzJi3U,914
|
|
62
62
|
seekrai/types/ingestion.py,sha256=uUdKOR4xqSfAXWQOR1UOltSlOnuyAwKVA1Q2a6Yslk8,919
|
|
63
63
|
seekrai/types/models.py,sha256=9Z0nvLdlAfpF8mNRW5-IqBdDHoE-3qQ5przmIDJgwLo,1345
|
|
64
64
|
seekrai/types/projects.py,sha256=JFgpZdovia8Orcnhp6QkIEAXzyPCfKT_bUiwjxUaHHQ,670
|
|
65
|
-
seekrai/types/vectordb.py,sha256=
|
|
65
|
+
seekrai/types/vectordb.py,sha256=Fw3ZrEvWU5OHzXNIUXtD24JVG7pCULfudX_WDOazJnk,2454
|
|
66
66
|
seekrai/utils/__init__.py,sha256=dfbiYEc47EBVRkq6C4O9y6tTGuPuV3LbV3__v01Mbds,658
|
|
67
67
|
seekrai/utils/_log.py,sha256=Cayw5B394H2WGVTXPXS2AN8znQdxsgrLqADXgqmokvU,1649
|
|
68
68
|
seekrai/utils/api_helpers.py,sha256=0Y8BblNIr9h_R12zdmhkxgTlxgoRkbq84QNi4nNWGu8,2385
|
|
69
69
|
seekrai/utils/files.py,sha256=7ixn_hgV-6pEhYqLyOp-EN0o8c1CzUwJzX9n3PQ5oqo,7164
|
|
70
70
|
seekrai/utils/tools.py,sha256=jgJTL-dOIouDbEJLdQpQfpXhqaz_poQYS52adyUtBjo,1781
|
|
71
71
|
seekrai/version.py,sha256=q6iGQVFor8zXiPP5F-3vy9TndOxKv5JXbaNJ2kdOQws,125
|
|
72
|
-
seekrai-0.5.
|
|
73
|
-
seekrai-0.5.
|
|
74
|
-
seekrai-0.5.
|
|
75
|
-
seekrai-0.5.
|
|
76
|
-
seekrai-0.5.
|
|
72
|
+
seekrai-0.5.24.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
73
|
+
seekrai-0.5.24.dist-info/METADATA,sha256=c8xRXd2zpQouHVnpTEXs-an-vibbjsZmxELTBxU-1ZA,4601
|
|
74
|
+
seekrai-0.5.24.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
|
|
75
|
+
seekrai-0.5.24.dist-info/entry_points.txt,sha256=N49yOEGi1sK7Xr13F_rkkcOxQ88suyiMoOmRhUHTZ_U,48
|
|
76
|
+
seekrai-0.5.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|