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.
Files changed (46) hide show
  1. seekrai/abstract/response_parsing.py +2 -0
  2. seekrai/client.py +8 -0
  3. seekrai/resources/__init__.py +20 -2
  4. seekrai/resources/agents/__init__.py +12 -0
  5. seekrai/resources/agents/agent_inference.py +37 -10
  6. seekrai/resources/agents/agent_observability.py +135 -0
  7. seekrai/resources/agents/agents.py +51 -0
  8. seekrai/resources/agents/python_functions.py +295 -0
  9. seekrai/resources/alignment.py +460 -1
  10. seekrai/resources/chat/completions.py +17 -8
  11. seekrai/resources/embeddings.py +2 -2
  12. seekrai/resources/explainability.py +92 -0
  13. seekrai/resources/finetune.py +44 -0
  14. seekrai/resources/ingestion.py +5 -7
  15. seekrai/resources/models.py +0 -3
  16. seekrai/resources/vectordb.py +36 -2
  17. seekrai/types/__init__.py +30 -3
  18. seekrai/types/agents/__init__.py +25 -3
  19. seekrai/types/agents/agent.py +11 -0
  20. seekrai/types/agents/observability.py +34 -0
  21. seekrai/types/agents/python_functions.py +29 -0
  22. seekrai/types/agents/runs.py +51 -1
  23. seekrai/types/agents/tools/__init__.py +12 -2
  24. seekrai/types/agents/tools/schemas/__init__.py +8 -0
  25. seekrai/types/agents/tools/schemas/file_search.py +1 -1
  26. seekrai/types/agents/tools/schemas/file_search_env.py +0 -1
  27. seekrai/types/agents/tools/schemas/run_python.py +9 -0
  28. seekrai/types/agents/tools/schemas/run_python_env.py +8 -0
  29. seekrai/types/agents/tools/schemas/web_search.py +9 -0
  30. seekrai/types/agents/tools/schemas/web_search_env.py +7 -0
  31. seekrai/types/agents/tools/tool.py +9 -3
  32. seekrai/types/agents/tools/tool_types.py +4 -4
  33. seekrai/types/alignment.py +36 -0
  34. seekrai/types/chat_completions.py +1 -0
  35. seekrai/types/deployments.py +2 -0
  36. seekrai/types/explainability.py +26 -0
  37. seekrai/types/files.py +2 -1
  38. seekrai/types/finetune.py +40 -7
  39. seekrai/types/vectordb.py +6 -1
  40. {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/METADATA +3 -6
  41. seekrai-0.5.24.dist-info/RECORD +76 -0
  42. {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/WHEEL +1 -1
  43. seekrai/types/agents/tools/tool_env_types.py +0 -4
  44. seekrai-0.5.2.dist-info/RECORD +0 -67
  45. {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/LICENSE +0 -0
  46. {seekrai-0.5.2.dist-info → seekrai-0.5.24.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,295 @@
1
+ from pathlib import Path
2
+ from typing import Union
3
+
4
+ from seekrai.abstract import api_requestor
5
+ from seekrai.seekrflow_response import SeekrFlowResponse
6
+ from seekrai.types import SeekrFlowClient, SeekrFlowRequest
7
+ from seekrai.types.agents.python_functions import (
8
+ DeletePythonFunctionResponse,
9
+ PythonFunctionResponse,
10
+ )
11
+
12
+
13
+ class CustomFunctions:
14
+ def __init__(self, client: SeekrFlowClient) -> None:
15
+ self._client = client
16
+ self._requestor = api_requestor.APIRequestor(
17
+ client=self._client,
18
+ )
19
+
20
+ def create(self, file_path: Union[str, Path]) -> PythonFunctionResponse:
21
+ """
22
+ Upload a new Python function for the user.
23
+
24
+ Args:
25
+ file_path: Path to the Python function file to upload (can be relative or absolute).
26
+
27
+ Returns:
28
+ The newly created Python function.
29
+ """
30
+ # Convert string to Path if needed
31
+ if isinstance(file_path, str):
32
+ file_path = Path(file_path)
33
+
34
+ # Read the file contents
35
+ with file_path.open("rb") as f:
36
+ file_content = f.read()
37
+
38
+ # Prepare multipart form data
39
+ files = {"file": (file_path.name, file_content, "text/plain")}
40
+
41
+ response, _, _ = self._requestor.request(
42
+ options=SeekrFlowRequest(
43
+ method="POST",
44
+ url="functions/",
45
+ files=files,
46
+ ),
47
+ )
48
+
49
+ assert isinstance(response, SeekrFlowResponse)
50
+ return PythonFunctionResponse(**response.data)
51
+
52
+ def retrieve(self, function_id: str) -> PythonFunctionResponse:
53
+ """
54
+ Retrieve a Python function by its ID.
55
+
56
+ Args:
57
+ function_id: The ID of the Python function to retrieve.
58
+
59
+ Returns:
60
+ The Python function.
61
+ """
62
+ response, _, _ = self._requestor.request(
63
+ options=SeekrFlowRequest(
64
+ method="GET",
65
+ url=f"functions/{function_id}",
66
+ ),
67
+ )
68
+
69
+ assert isinstance(response, SeekrFlowResponse)
70
+ return PythonFunctionResponse(**response.data)
71
+
72
+ def list_functions(
73
+ self, limit: int = 20, offset: int = 0, order: str = "desc"
74
+ ) -> list[PythonFunctionResponse]:
75
+ """
76
+ List all Python functions for the user.
77
+
78
+ Args:
79
+ limit: Maximum number of functions to return (default: 20).
80
+ offset: Number of functions to skip (default: 0).
81
+ order: Sort order, 'asc' or 'desc' (default: 'desc').
82
+
83
+ Returns:
84
+ A list of Python functions.
85
+ """
86
+ response, _, _ = self._requestor.request(
87
+ options=SeekrFlowRequest(
88
+ method="GET",
89
+ url="functions/",
90
+ params={"limit": limit, "offset": offset, "order": order},
91
+ ),
92
+ )
93
+
94
+ assert isinstance(response, SeekrFlowResponse)
95
+ functions = [PythonFunctionResponse(**func) for func in response.data] # type: ignore
96
+ return functions
97
+
98
+ def update(
99
+ self, function_id: str, file_path: Union[str, Path]
100
+ ) -> PythonFunctionResponse:
101
+ """
102
+ Update an existing Python function.
103
+
104
+ Args:
105
+ function_id: The ID of the Python function to update.
106
+ file_path: Optional path to a new Python function file (can be relative or absolute).
107
+ description: Optional new description for the function.
108
+
109
+ Returns:
110
+ The updated Python function.
111
+ """
112
+ # Convert string to Path if needed
113
+ if isinstance(file_path, str):
114
+ file_path = Path(file_path)
115
+
116
+ # Read the file contents
117
+ with file_path.open("rb") as f:
118
+ file_content = f.read()
119
+
120
+ # Prepare multipart form data
121
+ files = {"file": (file_path.name, file_content, "text/plain")}
122
+
123
+ response, _, _ = self._requestor.request(
124
+ options=SeekrFlowRequest(
125
+ method="PATCH",
126
+ url=f"functions/{function_id}",
127
+ files=files,
128
+ ),
129
+ )
130
+
131
+ assert isinstance(response, SeekrFlowResponse)
132
+ return PythonFunctionResponse(**response.data)
133
+
134
+ def delete(self, function_id: str) -> DeletePythonFunctionResponse:
135
+ """
136
+ Delete a Python function by its ID.
137
+
138
+ Args:
139
+ function_id: The ID of the Python function to delete.
140
+
141
+ Returns:
142
+ A response indicating whether the delete operation was successful.
143
+ """
144
+ response, _, _ = self._requestor.request(
145
+ options=SeekrFlowRequest(
146
+ method="DELETE",
147
+ url=f"functions/{function_id}",
148
+ ),
149
+ )
150
+
151
+ assert isinstance(response, SeekrFlowResponse)
152
+ return DeletePythonFunctionResponse(**response.data)
153
+
154
+
155
+ class AsyncCustomFunctions:
156
+ def __init__(self, client: SeekrFlowClient) -> None:
157
+ self._client = client
158
+ self._requestor = api_requestor.APIRequestor(
159
+ client=self._client,
160
+ )
161
+
162
+ async def create(self, file_path: Union[str, Path]) -> PythonFunctionResponse:
163
+ """
164
+ Upload a new Python function for the user.
165
+
166
+ Args:
167
+ file_path: Path to the Python function file to upload (can be relative or absolute).
168
+
169
+ Returns:
170
+ The newly created Python function.
171
+ """
172
+ # Convert string to Path if needed
173
+ if isinstance(file_path, str):
174
+ file_path = Path(file_path)
175
+
176
+ # Read the file contents
177
+ with file_path.open("rb") as f:
178
+ file_content = f.read()
179
+
180
+ # Prepare multipart form data
181
+ files = {"file": (file_path.name, file_content, "text/plain")}
182
+
183
+ response, _, _ = await self._requestor.arequest(
184
+ options=SeekrFlowRequest(
185
+ method="POST",
186
+ url="functions/",
187
+ files=files,
188
+ ),
189
+ )
190
+
191
+ assert isinstance(response, SeekrFlowResponse)
192
+ return PythonFunctionResponse(**response.data)
193
+
194
+ async def retrieve(self, function_id: str) -> PythonFunctionResponse:
195
+ """
196
+ Retrieve a Python function by its ID.
197
+
198
+ Args:
199
+ function_id: The ID of the Python function to retrieve.
200
+
201
+ Returns:
202
+ The Python function.
203
+ """
204
+ response, _, _ = await self._requestor.arequest(
205
+ options=SeekrFlowRequest(
206
+ method="GET",
207
+ url=f"functions/{function_id}",
208
+ ),
209
+ )
210
+
211
+ assert isinstance(response, SeekrFlowResponse)
212
+ return PythonFunctionResponse(**response.data)
213
+
214
+ async def list_functions(
215
+ self, limit: int = 20, offset: int = 0, order: str = "desc"
216
+ ) -> list[PythonFunctionResponse]:
217
+ """
218
+ List all Python functions for the user.
219
+
220
+ Args:
221
+ limit: Maximum number of functions to return (default: 20).
222
+ offset: Number of functions to skip (default: 0).
223
+ order: Sort order, 'asc' or 'desc' (default: 'desc').
224
+
225
+ Returns:
226
+ A list of Python functions.
227
+ """
228
+ response, _, _ = await self._requestor.arequest(
229
+ options=SeekrFlowRequest(
230
+ method="GET",
231
+ url="functions/",
232
+ params={"limit": limit, "offset": offset, "order": order},
233
+ ),
234
+ )
235
+
236
+ assert isinstance(response, SeekrFlowResponse)
237
+ functions = [PythonFunctionResponse(**func) for func in response.data] # type: ignore
238
+ return functions
239
+
240
+ async def update(
241
+ self,
242
+ function_id: str,
243
+ file_path: Union[str, Path],
244
+ ) -> PythonFunctionResponse:
245
+ """
246
+ Update an existing Python function.
247
+
248
+ Args:
249
+ function_id: The ID of the Python function to update.
250
+ file_path: Path to a new Python function file (can be relative or absolute).
251
+
252
+ Returns:
253
+ The updated Python function.
254
+ """
255
+ # Convert string to Path if needed
256
+ if isinstance(file_path, str):
257
+ file_path = Path(file_path)
258
+
259
+ # Read the file contents
260
+ with file_path.open("rb") as f:
261
+ file_content = f.read()
262
+
263
+ # Prepare multipart form data
264
+ files = {"file": (file_path.name, file_content, "text/plain")}
265
+
266
+ response, _, _ = await self._requestor.arequest(
267
+ options=SeekrFlowRequest(
268
+ method="PATCH",
269
+ url=f"functions/{function_id}",
270
+ files=files,
271
+ ),
272
+ )
273
+
274
+ assert isinstance(response, SeekrFlowResponse)
275
+ return PythonFunctionResponse(**response.data)
276
+
277
+ async def delete(self, function_id: str) -> DeletePythonFunctionResponse:
278
+ """
279
+ Delete a Python function by its ID.
280
+
281
+ Args:
282
+ function_id: The ID of the Python function to delete.
283
+
284
+ Returns:
285
+ A response indicating whether the delete operation was successful.
286
+ """
287
+ response, _, _ = await self._requestor.arequest(
288
+ options=SeekrFlowRequest(
289
+ method="DELETE",
290
+ url=f"functions/{function_id}",
291
+ ),
292
+ )
293
+
294
+ assert isinstance(response, SeekrFlowResponse)
295
+ return DeletePythonFunctionResponse(**response.data)