seekrai 0.5.2__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/abstract/response_parsing.py +2 -0
- seekrai/client.py +8 -0
- seekrai/resources/__init__.py +20 -2
- seekrai/resources/agents/__init__.py +12 -0
- seekrai/resources/agents/agent_inference.py +37 -10
- seekrai/resources/agents/agent_observability.py +135 -0
- seekrai/resources/agents/agents.py +51 -0
- seekrai/resources/agents/python_functions.py +295 -0
- seekrai/resources/alignment.py +460 -1
- seekrai/resources/chat/completions.py +17 -8
- seekrai/resources/embeddings.py +2 -2
- seekrai/resources/explainability.py +92 -0
- seekrai/resources/finetune.py +44 -0
- seekrai/resources/ingestion.py +5 -7
- seekrai/resources/models.py +0 -3
- seekrai/resources/vectordb.py +36 -2
- seekrai/types/__init__.py +30 -3
- seekrai/types/agents/__init__.py +25 -3
- seekrai/types/agents/agent.py +11 -0
- seekrai/types/agents/observability.py +34 -0
- seekrai/types/agents/python_functions.py +29 -0
- seekrai/types/agents/runs.py +51 -1
- seekrai/types/agents/tools/__init__.py +12 -2
- seekrai/types/agents/tools/schemas/__init__.py +8 -0
- seekrai/types/agents/tools/schemas/file_search.py +1 -1
- seekrai/types/agents/tools/schemas/file_search_env.py +0 -1
- seekrai/types/agents/tools/schemas/run_python.py +9 -0
- seekrai/types/agents/tools/schemas/run_python_env.py +8 -0
- seekrai/types/agents/tools/schemas/web_search.py +9 -0
- seekrai/types/agents/tools/schemas/web_search_env.py +7 -0
- seekrai/types/agents/tools/tool.py +9 -3
- seekrai/types/agents/tools/tool_types.py +4 -4
- seekrai/types/alignment.py +36 -0
- seekrai/types/chat_completions.py +1 -0
- seekrai/types/deployments.py +2 -0
- seekrai/types/explainability.py +26 -0
- seekrai/types/files.py +2 -1
- seekrai/types/finetune.py +40 -7
- seekrai/types/vectordb.py +6 -1
- {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/METADATA +3 -6
- seekrai-0.5.24.dist-info/RECORD +76 -0
- {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/WHEEL +1 -1
- seekrai/types/agents/tools/tool_env_types.py +0 -4
- seekrai-0.5.2.dist-info/RECORD +0 -67
- {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/LICENSE +0 -0
- {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/entry_points.txt +0 -0
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
|
|
@@ -22,6 +22,7 @@ class ChatCompletions:
|
|
|
22
22
|
*,
|
|
23
23
|
messages: List[Dict[str, str]],
|
|
24
24
|
model: str,
|
|
25
|
+
max_completion_tokens: int | None = None,
|
|
25
26
|
max_tokens: int | None = 512,
|
|
26
27
|
stop: List[str] | None = None,
|
|
27
28
|
temperature: float = 0.7,
|
|
@@ -36,7 +37,7 @@ class ChatCompletions:
|
|
|
36
37
|
safety_model: str | None = None,
|
|
37
38
|
response_format: Dict[str, str | Dict[str, Any]] | None = None,
|
|
38
39
|
tools: Dict[str, str | Dict[str, Any]] | None = None,
|
|
39
|
-
tool_choice: str | Dict[str, str | Dict[str, str]] | None =
|
|
40
|
+
tool_choice: str | Dict[str, str | Dict[str, str]] | None = None,
|
|
40
41
|
) -> ChatCompletionResponse | Iterator[ChatCompletionChunk]:
|
|
41
42
|
"""
|
|
42
43
|
Method to generate completions based on a given prompt using a specified model.
|
|
@@ -45,6 +46,7 @@ class ChatCompletions:
|
|
|
45
46
|
messages (List[Dict[str, str]]): A list of messages in the format
|
|
46
47
|
`[{"role": seekrai.types.chat_completions.MessageRole, "content": TEXT}, ...]`
|
|
47
48
|
model (str): The name of the model to query.
|
|
49
|
+
max_completion_tokens (int, optional): The maximum number of tokens the output can contain.
|
|
48
50
|
max_tokens (int, optional): The maximum number of tokens to generate.
|
|
49
51
|
Defaults to 512.
|
|
50
52
|
stop (List[str], optional): List of strings at which to stop generation.
|
|
@@ -99,6 +101,7 @@ class ChatCompletions:
|
|
|
99
101
|
top_p=top_p,
|
|
100
102
|
top_k=top_k,
|
|
101
103
|
temperature=temperature,
|
|
104
|
+
max_completion_tokens=max_completion_tokens,
|
|
102
105
|
max_tokens=max_tokens,
|
|
103
106
|
stop=stop,
|
|
104
107
|
repetition_penalty=repetition_penalty,
|
|
@@ -109,15 +112,16 @@ class ChatCompletions:
|
|
|
109
112
|
n=n,
|
|
110
113
|
safety_model=safety_model,
|
|
111
114
|
response_format=response_format,
|
|
112
|
-
tools=tools or
|
|
113
|
-
tool_choice=tool_choice,
|
|
115
|
+
tools=tools or None,
|
|
114
116
|
).model_dump()
|
|
115
|
-
|
|
117
|
+
if tool_choice is not None:
|
|
118
|
+
parameter_payload["tool_choice"] = tool_choice
|
|
116
119
|
response, _, _ = requestor.request(
|
|
117
120
|
options=SeekrFlowRequest(
|
|
118
121
|
method="POST",
|
|
119
122
|
url="inference/chat/completions",
|
|
120
123
|
params=parameter_payload,
|
|
124
|
+
headers={"content-type": "application/json"},
|
|
121
125
|
),
|
|
122
126
|
stream=stream,
|
|
123
127
|
)
|
|
@@ -139,6 +143,7 @@ class AsyncChatCompletions:
|
|
|
139
143
|
*,
|
|
140
144
|
messages: List[Dict[str, str]],
|
|
141
145
|
model: str,
|
|
146
|
+
max_completion_tokens: int | None = None,
|
|
142
147
|
max_tokens: int | None = 512,
|
|
143
148
|
stop: List[str] | None = None,
|
|
144
149
|
temperature: float = 0.7,
|
|
@@ -152,8 +157,8 @@ class AsyncChatCompletions:
|
|
|
152
157
|
n: int = 1,
|
|
153
158
|
safety_model: str | None = None,
|
|
154
159
|
response_format: Dict[str, str | Dict[str, Any]] | None = None,
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
tools: Dict[str, str | Dict[str, Any]] | None = None,
|
|
161
|
+
tool_choice: str | Dict[str, str | Dict[str, str]] | None = None,
|
|
157
162
|
) -> AsyncGenerator[ChatCompletionChunk, None] | ChatCompletionResponse:
|
|
158
163
|
"""
|
|
159
164
|
Async method to generate completions based on a given prompt using a specified model.
|
|
@@ -162,6 +167,7 @@ class AsyncChatCompletions:
|
|
|
162
167
|
messages (List[Dict[str, str]]): A list of messages in the format
|
|
163
168
|
`[{"role": seekrai.types.chat_completions.MessageRole, "content": TEXT}, ...]`
|
|
164
169
|
model (str): The name of the model to query.
|
|
170
|
+
max_completion_tokens (int, optional): The maximum number of tokens the output can contain.
|
|
165
171
|
max_tokens (int, optional): The maximum number of tokens to generate.
|
|
166
172
|
Defaults to 512.
|
|
167
173
|
stop (List[str], optional): List of strings at which to stop generation.
|
|
@@ -217,6 +223,7 @@ class AsyncChatCompletions:
|
|
|
217
223
|
top_p=top_p,
|
|
218
224
|
top_k=top_k,
|
|
219
225
|
temperature=temperature,
|
|
226
|
+
max_completion_tokens=max_completion_tokens,
|
|
220
227
|
max_tokens=max_tokens,
|
|
221
228
|
stop=stop,
|
|
222
229
|
repetition_penalty=repetition_penalty,
|
|
@@ -227,15 +234,17 @@ class AsyncChatCompletions:
|
|
|
227
234
|
n=n,
|
|
228
235
|
safety_model=safety_model,
|
|
229
236
|
response_format=response_format,
|
|
230
|
-
|
|
231
|
-
# tool_choice=tool_choice,
|
|
237
|
+
tools=tools or None,
|
|
232
238
|
).model_dump()
|
|
239
|
+
if tool_choice is not None:
|
|
240
|
+
parameter_payload["tool_choice"] = tool_choice
|
|
233
241
|
|
|
234
242
|
response, _, _ = await requestor.arequest(
|
|
235
243
|
options=SeekrFlowRequest(
|
|
236
244
|
method="POST",
|
|
237
245
|
url="inference/chat/completions",
|
|
238
246
|
params=parameter_payload,
|
|
247
|
+
headers={"content-type": "application/json"},
|
|
239
248
|
),
|
|
240
249
|
stream=stream,
|
|
241
250
|
)
|
seekrai/resources/embeddings.py
CHANGED
|
@@ -29,7 +29,6 @@ class Embeddings(ResourceBase):
|
|
|
29
29
|
Returns:
|
|
30
30
|
EmbeddingResponse: Object containing embeddings
|
|
31
31
|
"""
|
|
32
|
-
raise NotImplementedError("Function not implemented yet")
|
|
33
32
|
|
|
34
33
|
requestor = api_requestor.APIRequestor(
|
|
35
34
|
client=self._client,
|
|
@@ -45,6 +44,7 @@ class Embeddings(ResourceBase):
|
|
|
45
44
|
method="POST",
|
|
46
45
|
url="inference/embeddings",
|
|
47
46
|
params=parameter_payload,
|
|
47
|
+
headers={"content-type": "application/json"},
|
|
48
48
|
),
|
|
49
49
|
stream=False,
|
|
50
50
|
)
|
|
@@ -71,7 +71,6 @@ class AsyncEmbeddings(ResourceBase):
|
|
|
71
71
|
Returns:
|
|
72
72
|
EmbeddingResponse: Object containing embeddings
|
|
73
73
|
"""
|
|
74
|
-
raise NotImplementedError("Function not implemented yet")
|
|
75
74
|
|
|
76
75
|
requestor = api_requestor.APIRequestor(
|
|
77
76
|
client=self._client,
|
|
@@ -87,6 +86,7 @@ class AsyncEmbeddings(ResourceBase):
|
|
|
87
86
|
method="POST",
|
|
88
87
|
url="inference/embeddings",
|
|
89
88
|
params=parameter_payload,
|
|
89
|
+
headers={"content-type": "application/json"},
|
|
90
90
|
),
|
|
91
91
|
stream=False,
|
|
92
92
|
)
|