dataiku-api-client 14.5.0__tar.gz → 14.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/HISTORY.txt +12 -1
- {dataiku_api_client-14.5.0/dataiku_api_client.egg-info → dataiku_api_client-14.5.2}/PKG-INFO +14 -3
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2/dataiku_api_client.egg-info}/PKG-INFO +14 -3
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/agent.py +30 -11
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/agent_tool.py +22 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/document_extractor.py +176 -4
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/tool.py +4 -7
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/llm.py +4 -32
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/llm_utils/__init__.py +57 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/project.py +35 -7
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/recipe.py +28 -1
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dssclient.py +7 -2
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/setup.py +1 -1
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/LICENSE.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/MANIFEST.in +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/README +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataiku_api_client.egg-info/SOURCES.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataiku_api_client.egg-info/dependency_links.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataiku_api_client.egg-info/requires.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataiku_api_client.egg-info/top_level.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/apinode_admin/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/apinode_admin/auth.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/apinode_admin/service.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/apinode_admin_client.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/apinode_client.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/auth.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/base_client.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/admin.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/agent_review.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/analysis.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/apideployer.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/apiservice.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/app.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/businessapp.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/codestudio.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/continuousactivity.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/dashboard.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/data_collection.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/data_directories_footprint.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/data_quality.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/dataset.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/discussion.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/drift.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/enterprise_asset_library.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/evaluationcomparison.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/evaluationstore.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/feature_store.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/flow.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/future.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/insight.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/job.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/jupyternotebook.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/knowledgebank.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/labeling_task.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/embeddings.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/knowledge_bank.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/llm.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/langchain/utils.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/llm_tracing/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/local_model.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/macro.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/managedfolder.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/meaning.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/messaging_channel.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/metrics.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/ml.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/mlflow.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/modelcomparison.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/modelevaluationstore.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/notebook.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/plugin.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/project_standards.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/projectdeployer.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/projectfolder.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/projectlibrary.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/retrieval_augmented_llm.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/savedmodel.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/scenario.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/semantic_model.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/sqlnotebook.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/sqlquery.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/statistics.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/streaming_endpoint.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/tools/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/tools/codegen.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/tools/langchain.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/unifiedmonitoring.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/utils.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/webapp.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/wiki.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/workspace.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss_plugin_mlflow/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss_plugin_mlflow/artifact_repository.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss_plugin_mlflow/header_provider.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss_plugin_mlflow/utils.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/cloudaccounts.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/future.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/instances.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/instancesettingstemplates.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/loadbalancers.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/tenant.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fm/virtualnetworks.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/fmclient.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/admin.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/admin_blueprint_designer.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/admin_custom_pages_handler.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/admin_roles_permissions_handler.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/artifact.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/artifact_search.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/blueprint.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/custom_page.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/future.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/time_series.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/uploaded_file.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern/users_container.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/govern_client.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/iam/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/iam/settings.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/__init__.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/exceptions.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/group.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/node.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/profile.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/response.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/task.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad/user.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/launchpad_client.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/utils.py +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/requirements.txt +0 -0
- {dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/setup.cfg +0 -0
|
@@ -3,7 +3,18 @@ Changelog
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
14.5.
|
|
6
|
+
14.5.2 (2026-05-25)
|
|
7
|
+
-------------------
|
|
8
|
+
|
|
9
|
+
* Initial release for DSS 14.5.2
|
|
10
|
+
|
|
11
|
+
14.5.1 (2026-04-27)
|
|
12
|
+
-------------------
|
|
13
|
+
|
|
14
|
+
* Initial release for DSS 14.5.1
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
14.5.0 (2026-04-17)
|
|
7
18
|
-------------------
|
|
8
19
|
|
|
9
20
|
* Initial release for DSS 14.5.0
|
{dataiku_api_client-14.5.0/dataiku_api_client.egg-info → dataiku_api_client-14.5.2}/PKG-INFO
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataiku-api-client
|
|
3
|
-
Version: 14.5.
|
|
3
|
+
Version: 14.5.2
|
|
4
4
|
Summary: Python API client for Dataiku APIs
|
|
5
5
|
Home-page: https://www.dataiku.com
|
|
6
|
-
Download-URL: https://github.com/dataiku/dataiku-api-client-python/tarball/14.5.
|
|
6
|
+
Download-URL: https://github.com/dataiku/dataiku-api-client-python/tarball/14.5.2
|
|
7
7
|
Author: Dataiku
|
|
8
8
|
Author-email: support@dataiku.com
|
|
9
9
|
License: Apache Software License
|
|
@@ -37,7 +37,18 @@ Changelog
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
14.5.
|
|
40
|
+
14.5.2 (2026-05-25)
|
|
41
|
+
-------------------
|
|
42
|
+
|
|
43
|
+
* Initial release for DSS 14.5.2
|
|
44
|
+
|
|
45
|
+
14.5.1 (2026-04-27)
|
|
46
|
+
-------------------
|
|
47
|
+
|
|
48
|
+
* Initial release for DSS 14.5.1
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
14.5.0 (2026-04-17)
|
|
41
52
|
-------------------
|
|
42
53
|
|
|
43
54
|
* Initial release for DSS 14.5.0
|
{dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2/dataiku_api_client.egg-info}/PKG-INFO
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataiku-api-client
|
|
3
|
-
Version: 14.5.
|
|
3
|
+
Version: 14.5.2
|
|
4
4
|
Summary: Python API client for Dataiku APIs
|
|
5
5
|
Home-page: https://www.dataiku.com
|
|
6
|
-
Download-URL: https://github.com/dataiku/dataiku-api-client-python/tarball/14.5.
|
|
6
|
+
Download-URL: https://github.com/dataiku/dataiku-api-client-python/tarball/14.5.2
|
|
7
7
|
Author: Dataiku
|
|
8
8
|
Author-email: support@dataiku.com
|
|
9
9
|
License: Apache Software License
|
|
@@ -37,7 +37,18 @@ Changelog
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
14.5.
|
|
40
|
+
14.5.2 (2026-05-25)
|
|
41
|
+
-------------------
|
|
42
|
+
|
|
43
|
+
* Initial release for DSS 14.5.2
|
|
44
|
+
|
|
45
|
+
14.5.1 (2026-04-27)
|
|
46
|
+
-------------------
|
|
47
|
+
|
|
48
|
+
* Initial release for DSS 14.5.1
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
14.5.0 (2026-04-17)
|
|
41
52
|
-------------------
|
|
42
53
|
|
|
43
54
|
* Initial release for DSS 14.5.0
|
|
@@ -241,7 +241,7 @@ class DSSAgentListItem(DSSTaggableObjectListItem):
|
|
|
241
241
|
@property
|
|
242
242
|
def project_key(self):
|
|
243
243
|
"""
|
|
244
|
-
:returns: The project
|
|
244
|
+
:returns: The project
|
|
245
245
|
:rtype: string
|
|
246
246
|
"""
|
|
247
247
|
return self._data["projectKey"]
|
|
@@ -263,7 +263,10 @@ class DSSAgentListItem(DSSTaggableObjectListItem):
|
|
|
263
263
|
return self._data["name"]
|
|
264
264
|
|
|
265
265
|
def as_llm(self):
|
|
266
|
-
"""
|
|
266
|
+
"""
|
|
267
|
+
:returns: this agent as a usable :class:`dataikuapi.dss.llm.DSSLLM` for querying
|
|
268
|
+
:rtype: dataikuapi.dss.llm.DSSLLM
|
|
269
|
+
"""
|
|
267
270
|
return self.client.get_project(self.project_key).get_llm("agent:%s" % self.id)
|
|
268
271
|
|
|
269
272
|
|
|
@@ -285,14 +288,15 @@ class DSSAgent(object):
|
|
|
285
288
|
return self._id
|
|
286
289
|
|
|
287
290
|
def as_llm(self):
|
|
288
|
-
"""
|
|
291
|
+
"""
|
|
292
|
+
:returns: this agent as a usable :class:`dataikuapi.dss.llm.DSSLLM` for querying
|
|
293
|
+
:rtype: dataikuapi.dss.llm.DSSLLM
|
|
294
|
+
"""
|
|
289
295
|
return self.client.get_project(self.project_key).get_llm("agent:%s" % self.id)
|
|
290
296
|
|
|
291
297
|
def get_settings(self):
|
|
292
298
|
"""
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
:return: a handle on the agent definition
|
|
299
|
+
:return: a handle on the agent's definition
|
|
296
300
|
:rtype: :class:`dataikuapi.dss.agent.DSSAgentSettings`
|
|
297
301
|
"""
|
|
298
302
|
settings = self.client._perform_json(
|
|
@@ -362,15 +366,26 @@ class DSSAgentSettings(DSSTaggableObjectSettings):
|
|
|
362
366
|
self._settings = settings
|
|
363
367
|
|
|
364
368
|
def get_version_ids(self):
|
|
369
|
+
"""
|
|
370
|
+
List the ids of each version of this agent
|
|
371
|
+
|
|
372
|
+
:rtype: list[str]
|
|
373
|
+
"""
|
|
365
374
|
return [v["versionId"] for v in self._settings["versions"]]
|
|
366
375
|
|
|
367
376
|
@property
|
|
368
377
|
def active_version(self):
|
|
369
|
-
"""
|
|
378
|
+
"""
|
|
379
|
+
:returns: the active version of this agent, or None if no version is declared as active
|
|
380
|
+
:rtype: str | None
|
|
381
|
+
"""
|
|
370
382
|
return self._settings.get("activeVersion")
|
|
371
383
|
|
|
372
384
|
def get_version_settings(self, version_id):
|
|
373
|
-
|
|
385
|
+
"""
|
|
386
|
+
:returns: the settings of the given version of this agent
|
|
387
|
+
:rtype: DSSAgentVersionSettings
|
|
388
|
+
"""
|
|
374
389
|
version_settings = None
|
|
375
390
|
for vs in self._settings["versions"]:
|
|
376
391
|
if vs["versionId"] == version_id:
|
|
@@ -387,8 +402,7 @@ class DSSAgentSettings(DSSTaggableObjectSettings):
|
|
|
387
402
|
|
|
388
403
|
def get_raw(self):
|
|
389
404
|
"""
|
|
390
|
-
|
|
391
|
-
:return: the raw settings of the agent
|
|
405
|
+
:returns: the raw settings of this agent
|
|
392
406
|
:rtype: dict
|
|
393
407
|
"""
|
|
394
408
|
return self._settings
|
|
@@ -406,13 +420,18 @@ class DSSAgentVersionSettings(object):
|
|
|
406
420
|
self._version_settings = version_settings
|
|
407
421
|
|
|
408
422
|
def get_raw(self):
|
|
423
|
+
"""
|
|
424
|
+
:returns: the raw settings of this agent version
|
|
425
|
+
:rtype: dict
|
|
426
|
+
"""
|
|
409
427
|
return self._version_settings
|
|
410
428
|
|
|
411
429
|
@property
|
|
412
430
|
def llm_id(self):
|
|
413
431
|
"""
|
|
414
432
|
Only for Visual Agents
|
|
415
|
-
|
|
433
|
+
|
|
434
|
+
:rtype: str
|
|
416
435
|
"""
|
|
417
436
|
if not self._agent_settings.type == "TOOLS_USING_AGENT":
|
|
418
437
|
raise ValueError("Only valid for Simple Visual Agents")
|
|
@@ -98,12 +98,22 @@ class DSSAgentTool(object):
|
|
|
98
98
|
return self.client._perform_empty("DELETE", "/projects/%s/agents/tools/%s" % (self.project_key, self.id))
|
|
99
99
|
|
|
100
100
|
def as_langchain_structured_tool(self, context = None):
|
|
101
|
+
"""
|
|
102
|
+
:returns: this tool as a LangChain StructuredTool
|
|
103
|
+
:rtype: langchain_core.tools.StructuredTool
|
|
104
|
+
"""
|
|
101
105
|
from dataikuapi.dss.langchain.tool import convert_to_langchain_structured_tool
|
|
102
106
|
return convert_to_langchain_structured_tool(self, context)
|
|
103
107
|
|
|
104
108
|
def run(self, input, context=None, subtool_name=None, memory_fragment=None, tool_validation_responses=None, tool_validation_requests=None):
|
|
105
109
|
"""
|
|
106
110
|
Execute a tool call
|
|
111
|
+
|
|
112
|
+
:param str input: Text input
|
|
113
|
+
:param dict context: Additional request context
|
|
114
|
+
:param str subtool_name: Name of the sub-tool, if applicable (e.g., for a MCP tool)
|
|
115
|
+
:rtype: dict
|
|
116
|
+
:returns: The result of running this tool
|
|
107
117
|
"""
|
|
108
118
|
|
|
109
119
|
invocation = {
|
|
@@ -201,6 +211,10 @@ class DSSAgentToolSettings(DSSTaggableObjectSettings):
|
|
|
201
211
|
self._settings = settings
|
|
202
212
|
|
|
203
213
|
def get_raw(self):
|
|
214
|
+
"""
|
|
215
|
+
:returns: the raw settings dict for this agent tool
|
|
216
|
+
:rtype: dict
|
|
217
|
+
"""
|
|
204
218
|
return self._settings
|
|
205
219
|
|
|
206
220
|
@property
|
|
@@ -237,6 +251,10 @@ class DSSVectorStoreSearchAgentToolCreator(DSSAgentToolCreator):
|
|
|
237
251
|
DSSAgentToolCreator.__init__(self, project, type, name, id)
|
|
238
252
|
|
|
239
253
|
def with_knowledge_bank(self, kb):
|
|
254
|
+
"""
|
|
255
|
+
:param kb: Knowledge Bank (object, list item, or identifier) to use in this tool
|
|
256
|
+
:type kb: DSSKnowledgeBank | DSSKnowledgeBankListItem | str
|
|
257
|
+
"""
|
|
240
258
|
loc = _kb_to_loc(self.project.project_key, kb)
|
|
241
259
|
self.proto["creationParams"]["knowledgeBankRef"] = loc.to_ref(self.project.project_key)
|
|
242
260
|
return self
|
|
@@ -246,5 +264,9 @@ class DSSVectorStoreSearchAgentToolSettings(DSSAgentToolSettings):
|
|
|
246
264
|
DSSAgentToolSettings.__init__(self, agent_tool, settings)
|
|
247
265
|
|
|
248
266
|
def set_knowledge_bank(self, kb):
|
|
267
|
+
"""
|
|
268
|
+
:param kb: Knowledge Bank (object, list item, or identifier) to use in this tool
|
|
269
|
+
:type kb: DSSKnowledgeBank | DSSKnowledgeBankListItem | str
|
|
270
|
+
"""
|
|
249
271
|
loc = _kb_to_loc(self.project.project_key, kb)
|
|
250
272
|
self.settings["params"]["knowledgeBankRef"] = loc.to_ref(self.agent_tool.project_key)
|
{dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/document_extractor.py
RENAMED
|
@@ -3,6 +3,8 @@ import copy
|
|
|
3
3
|
import json
|
|
4
4
|
import warnings
|
|
5
5
|
|
|
6
|
+
from dataikuapi.dss.llm_utils import get_json_schema_and_parser
|
|
7
|
+
from dataikuapi.dss.recipe import DSSRecipe
|
|
6
8
|
from dataikuapi.utils import _write_response_content_to_file
|
|
7
9
|
|
|
8
10
|
|
|
@@ -70,6 +72,89 @@ class DocumentExtractor(object):
|
|
|
70
72
|
body=extractor_request)
|
|
71
73
|
return VlmExtractorResponse(ret)
|
|
72
74
|
|
|
75
|
+
|
|
76
|
+
def vlm_extract_fields(self, images, schema=None, llm_id=None, llm_prompt=None, from_recipe=None, strict=None, compatible=None):
|
|
77
|
+
"""
|
|
78
|
+
Extract specific fields (structured data) from images (typically screenshots of a document's pages) using a vision LLM.
|
|
79
|
+
Describe expected fields in ``extraction_schema``, or specify an Extract Fields recipe to use its settings.
|
|
80
|
+
|
|
81
|
+
:param images: screenshots of the document's pages from which to extract the fields
|
|
82
|
+
:type images: iterable(:class:`InlineImageRef`) | iterable(:class:`ManagedFolderImageRef`)
|
|
83
|
+
:param schema: a JSON schema or a Pydantic model class describing the fields to extract.
|
|
84
|
+
JSON schema definitions or Pydantic models referencing other models are unsupported.
|
|
85
|
+
:type schema: str | dict | pydantic.BaseModel class or Python type hint.
|
|
86
|
+
:param llm_id: Identifier of a vision LLM
|
|
87
|
+
:type llm_id: str
|
|
88
|
+
:param llm_prompt: Custom prompt to extract fields from the images
|
|
89
|
+
:type llm_prompt: str
|
|
90
|
+
:param from_recipe: Name of a recipe from which to read the other arguments.
|
|
91
|
+
Arguments provided explicitly take precedence.
|
|
92
|
+
:type from_recipe: str
|
|
93
|
+
:param strict: Whether to strictly enforce the schema. Support varies across models/providers.
|
|
94
|
+
:type strict: bool
|
|
95
|
+
:param compatible: Allow DSS to modify the schema in order to increase compatibility, depending on known limitations of the model/provider. Defaults to automatic.
|
|
96
|
+
:type compatible: bool
|
|
97
|
+
|
|
98
|
+
:returns: Extracted fields from images
|
|
99
|
+
:rtype: :class:`FieldsVlmExtractorResponse`
|
|
100
|
+
"""
|
|
101
|
+
if from_recipe is not None and (schema is None or llm_id is None or llm_prompt is None or strict is None or compatible is None):
|
|
102
|
+
recipe_settings = DSSRecipe(self.client, self.project_key, from_recipe).get_settings()
|
|
103
|
+
recipe_params = recipe_settings.raw_params
|
|
104
|
+
|
|
105
|
+
if schema is None:
|
|
106
|
+
schema = recipe_params.get("extractionSchema")
|
|
107
|
+
if llm_id is None:
|
|
108
|
+
llm_id = recipe_params.get("vlmId")
|
|
109
|
+
if llm_prompt is None:
|
|
110
|
+
llm_prompt = recipe_params.get("extractionPrompt")
|
|
111
|
+
if strict is None:
|
|
112
|
+
strict = recipe_params.get("valueErrorHandling") == "BLANK_VALUE"
|
|
113
|
+
if compatible is None:
|
|
114
|
+
compatible = True
|
|
115
|
+
dku_properties = recipe_settings.get_recipe_raw_definition().get("dkuProperties") or []
|
|
116
|
+
for prop in dku_properties:
|
|
117
|
+
if isinstance(prop, dict) and prop.get("name") == "dku.extractFields.schemaCompatibilityEnhancer" and isinstance(prop.get("value"), bool):
|
|
118
|
+
compatible = prop.get("value")
|
|
119
|
+
break
|
|
120
|
+
|
|
121
|
+
json_schema, parser_method = get_json_schema_and_parser(schema)
|
|
122
|
+
|
|
123
|
+
extractor_request = {
|
|
124
|
+
"settings": {
|
|
125
|
+
"llmId": llm_id,
|
|
126
|
+
"llmPrompt": llm_prompt,
|
|
127
|
+
"extractionSchema" : json.loads(json_schema),
|
|
128
|
+
"strictSchemaAdherence": strict,
|
|
129
|
+
"schemaCompatibilityEnhancer": compatible
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
images = list(images)
|
|
134
|
+
if not images:
|
|
135
|
+
raise ValueError("No images provided")
|
|
136
|
+
if all(isinstance(ir, InlineImageRef) for ir in images):
|
|
137
|
+
extractor_request["inputs"] = {
|
|
138
|
+
"imagesRef": {
|
|
139
|
+
"type": images[0].type,
|
|
140
|
+
"inlineImages": [ir.as_dict() for ir in images]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
elif all(isinstance(ir, ManagedFolderImageRef) for ir in images):
|
|
144
|
+
extractor_request["inputs"] = {
|
|
145
|
+
"imagesRef": {
|
|
146
|
+
"type": images[0].type,
|
|
147
|
+
"managedFolderRef": images[0].managed_folder_ref,
|
|
148
|
+
"imagesPaths": [ir.image_path for ir in images]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else:
|
|
152
|
+
raise ValueError("Unsupported mix of image types: %s" % set([ir.type for ir in images]))
|
|
153
|
+
|
|
154
|
+
ret = self.client._perform_json("POST", "/projects/%s/document-extractors/fields/vlm" % self.project_key,
|
|
155
|
+
body=extractor_request)
|
|
156
|
+
return FieldsVlmExtractorResponse(ret, parser_method)
|
|
157
|
+
|
|
73
158
|
def structured_extract(self, document, max_section_depth=6, image_handling_mode='IGNORE', ocr_engine='AUTO', languages="en", llm_id=None, llm_prompt=None,
|
|
74
159
|
output_managed_folder=None, image_validation=True):
|
|
75
160
|
"""
|
|
@@ -191,7 +276,8 @@ class DocumentExtractor(object):
|
|
|
191
276
|
|
|
192
277
|
return TextExtractorResponse(ret)
|
|
193
278
|
|
|
194
|
-
def generate_pages_screenshots(self, document, output_managed_folder=None, offset=0, fetch_size=10, keep_fetched=True
|
|
279
|
+
def generate_pages_screenshots(self, document, output_managed_folder=None, offset=0, fetch_size=10, keep_fetched=True,
|
|
280
|
+
page_dpi=None, max_memory_per_document=None):
|
|
195
281
|
"""
|
|
196
282
|
Generate per-page screenshots of a document, returning an iterable over the screenshots.
|
|
197
283
|
|
|
@@ -232,12 +318,24 @@ class DocumentExtractor(object):
|
|
|
232
318
|
:type fetch_size: int
|
|
233
319
|
:param keep_fetched: whether to keep previous screenshots requests within this response object when fetching next ones.
|
|
234
320
|
:type keep_fetched: boolean
|
|
321
|
+
:param page_dpi: DPI used to render pages if memory allows.
|
|
322
|
+
:type page_dpi: int
|
|
323
|
+
:param max_memory_per_document: maximum memory budget in MB used while rendering a document.
|
|
324
|
+
The effective DPI may be reduced to fit this limit depending on page dimensions.
|
|
325
|
+
:type max_memory_per_document: int
|
|
235
326
|
|
|
236
327
|
:returns: An iterable over the result screenshots
|
|
237
328
|
:rtype: :class:`ScreenshotterResponse`
|
|
238
329
|
"""
|
|
239
330
|
|
|
240
|
-
screenshotter_request = ScreenshotterRequest(
|
|
331
|
+
screenshotter_request = ScreenshotterRequest(
|
|
332
|
+
document,
|
|
333
|
+
output_managed_folder,
|
|
334
|
+
offset,
|
|
335
|
+
fetch_size,
|
|
336
|
+
page_dpi,
|
|
337
|
+
max_memory_per_document
|
|
338
|
+
)
|
|
241
339
|
return ScreenshotterResponse(self.client, self.project_key, screenshotter_request, keep_fetched)
|
|
242
340
|
|
|
243
341
|
|
|
@@ -269,11 +367,13 @@ class ScreenshotterRequest(object):
|
|
|
269
367
|
|
|
270
368
|
"""
|
|
271
369
|
|
|
272
|
-
def __init__(self, document, output_managed_folder, offset, fetch_size):
|
|
370
|
+
def __init__(self, document, output_managed_folder, offset, fetch_size, page_dpi=None, max_memory_per_document=None):
|
|
273
371
|
self.document = document
|
|
274
372
|
self.output_managed_folder = output_managed_folder
|
|
275
373
|
self.offset = offset
|
|
276
374
|
self.fetch_size = fetch_size
|
|
375
|
+
self.page_dpi = page_dpi
|
|
376
|
+
self.max_memory_per_document = max_memory_per_document # MB
|
|
277
377
|
|
|
278
378
|
def as_json(self):
|
|
279
379
|
"""
|
|
@@ -302,6 +402,8 @@ class ScreenshotterRequest(object):
|
|
|
302
402
|
"outputManagedFolderRef": self.output_managed_folder,
|
|
303
403
|
"paginationOffset": self.offset,
|
|
304
404
|
"paginationSize": self.fetch_size,
|
|
405
|
+
"pageDPI": self.page_dpi,
|
|
406
|
+
"maxMemoryPerDocMB": self.max_memory_per_document,
|
|
305
407
|
}
|
|
306
408
|
}
|
|
307
409
|
|
|
@@ -683,7 +785,6 @@ class VlmExtractorResponse(object):
|
|
|
683
785
|
@property
|
|
684
786
|
def success(self):
|
|
685
787
|
"""
|
|
686
|
-
:returns: The outcome of the extractor request.
|
|
687
788
|
:rtype: bool
|
|
688
789
|
"""
|
|
689
790
|
return self._data.get("ok")
|
|
@@ -706,6 +807,77 @@ class VlmExtractorResponse(object):
|
|
|
706
807
|
)
|
|
707
808
|
raise Exception(error_message)
|
|
708
809
|
|
|
810
|
+
class FieldsVlmExtractorResponse(object):
|
|
811
|
+
"""
|
|
812
|
+
A handle to interact with a VLM fields extraction result.
|
|
813
|
+
|
|
814
|
+
.. important::
|
|
815
|
+
Do not create this class directly; use :meth:`~DocumentExtractor.vlm_extract_fields`
|
|
816
|
+
"""
|
|
817
|
+
|
|
818
|
+
def __init__(self, data, response_parser=None):
|
|
819
|
+
self._data = data
|
|
820
|
+
self._response_parser = response_parser
|
|
821
|
+
self._parsed_fields = None
|
|
822
|
+
|
|
823
|
+
def get_raw(self):
|
|
824
|
+
return self._data
|
|
825
|
+
|
|
826
|
+
@property
|
|
827
|
+
def success(self):
|
|
828
|
+
"""
|
|
829
|
+
:rtype: bool
|
|
830
|
+
"""
|
|
831
|
+
return self._data.get("status", "nok") != "nok"
|
|
832
|
+
|
|
833
|
+
@property
|
|
834
|
+
def fields(self):
|
|
835
|
+
"""
|
|
836
|
+
Fields extracted from the original document.
|
|
837
|
+
Follows the structure of the extraction schema, has only the fields that abide by it.
|
|
838
|
+
|
|
839
|
+
:returns: extracted fields.
|
|
840
|
+
:rtype: dict
|
|
841
|
+
"""
|
|
842
|
+
self._fail_unless_success()
|
|
843
|
+
return self._data["curatedFields"]
|
|
844
|
+
|
|
845
|
+
@property
|
|
846
|
+
def parsed_fields(self):
|
|
847
|
+
"""
|
|
848
|
+
Fields extracted from the original document.
|
|
849
|
+
Follows the structure of the extraction schema, has only the fields that abide by it.
|
|
850
|
+
Only available for extraction schema given as a Pydantic model or using Python type hint.
|
|
851
|
+
|
|
852
|
+
:returns: extracted fields deserialized into a Pydantic model instance.
|
|
853
|
+
:rtype: pydantic.BaseModel
|
|
854
|
+
"""
|
|
855
|
+
self._fail_unless_success()
|
|
856
|
+
if self._parsed_fields is None and self._data["curatedFields"] is not None:
|
|
857
|
+
if not self._response_parser:
|
|
858
|
+
raise Exception("Require extraction schema to be given as a Pydantic model or using Python type hint.")
|
|
859
|
+
else:
|
|
860
|
+
self._parsed_fields = self._response_parser(json.dumps(self._data["curatedFields"]))
|
|
861
|
+
return self._parsed_fields
|
|
862
|
+
|
|
863
|
+
@property
|
|
864
|
+
def invalid_fields(self):
|
|
865
|
+
"""
|
|
866
|
+
Fields in the extraction schema that the Vision LLM could not extract.
|
|
867
|
+
Follows the structure/hierarchy of the extraction schema, but has only the incorrect or missing fields.
|
|
868
|
+
|
|
869
|
+
:rtype: dict
|
|
870
|
+
"""
|
|
871
|
+
self._fail_unless_success()
|
|
872
|
+
return self._data["invalidFields"]
|
|
873
|
+
|
|
874
|
+
def _fail_unless_success(self):
|
|
875
|
+
if not self.success:
|
|
876
|
+
error_message = "Document failed to be extracted - request failed: {}".format(
|
|
877
|
+
self._data.get("errorMessage", "An unknown error occurred")
|
|
878
|
+
)
|
|
879
|
+
raise Exception(error_message)
|
|
880
|
+
|
|
709
881
|
|
|
710
882
|
class InputRef(object):
|
|
711
883
|
def as_dict(self):
|
|
@@ -2,11 +2,8 @@ import textwrap
|
|
|
2
2
|
import warnings
|
|
3
3
|
from typing import Optional, Callable, Literal, Type, Any, Dict
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
except ModuleNotFoundError:
|
|
8
|
-
from langchain.tools import StructuredTool
|
|
9
|
-
|
|
5
|
+
from langchain_core.tools import StructuredTool, create_schema_from_function
|
|
6
|
+
from langchain_core.tools.structured import _filter_schema_args
|
|
10
7
|
from pydantic import BaseModel
|
|
11
8
|
|
|
12
9
|
from dataiku.langchain.dku_tracer import dku_span_builder_for_callbacks
|
|
@@ -98,12 +95,12 @@ class DKUStructuredTool(StructuredTool):
|
|
|
98
95
|
name = name or source_function.__name__
|
|
99
96
|
if args_schema is None and infer_schema:
|
|
100
97
|
# schema name is appended within function
|
|
101
|
-
args_schema = create_schema_from_function(
|
|
98
|
+
args_schema = create_schema_from_function(
|
|
102
99
|
name,
|
|
103
100
|
source_function,
|
|
104
101
|
parse_docstring=parse_docstring,
|
|
105
102
|
error_on_invalid_docstring=error_on_invalid_docstring,
|
|
106
|
-
filter_args=_filter_schema_args(source_function),
|
|
103
|
+
filter_args=_filter_schema_args(source_function),
|
|
107
104
|
)
|
|
108
105
|
description_ = description
|
|
109
106
|
if description is None and not parse_docstring:
|
|
@@ -6,7 +6,7 @@ from .utils import DSSTaggableObjectListItem
|
|
|
6
6
|
from .llm_tracing import (
|
|
7
7
|
prepare_query_for_nested_llm_mesh_call,
|
|
8
8
|
)
|
|
9
|
-
from .llm_utils import _ChunkAggregator, LLMException
|
|
9
|
+
from .llm_utils import _ChunkAggregator, LLMException, _get_json_schema_and_parser_from_pydantic_model
|
|
10
10
|
|
|
11
11
|
_dku_bypass_guardrail_ls = threading.local()
|
|
12
12
|
|
|
@@ -413,40 +413,12 @@ class SettingsMixin(object):
|
|
|
413
413
|
:param bool strict: (optional) see :func:`with_json_output`
|
|
414
414
|
:param bool compatible: (optional) see :func:`with_json_output`
|
|
415
415
|
"""
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
self._response_parser = model_type.model_validate_json
|
|
419
|
-
elif hasattr(model_type, "schema") and hasattr(model_type, "parse_raw"):
|
|
420
|
-
schema = model_type.schema() # Pydantic 1 BaseModel
|
|
421
|
-
self._response_parser = model_type.parse_raw
|
|
422
|
-
else:
|
|
423
|
-
# 'model_type' is not a Pydantic BaseModel. Derive schema Python type hints.
|
|
424
|
-
try:
|
|
425
|
-
import pydantic
|
|
426
|
-
except ImportError:
|
|
427
|
-
raise Exception("Pydantic is required to use Python's type hints with structured output")
|
|
428
|
-
|
|
429
|
-
if hasattr(pydantic, "TypeAdapter"):
|
|
430
|
-
# Pydantic 2 provides a TypeAdapter to work with regular Python classes / type hints
|
|
431
|
-
from pydantic import TypeAdapter
|
|
432
|
-
adapter = TypeAdapter(model_type)
|
|
433
|
-
schema = adapter.json_schema()
|
|
434
|
-
self._response_parser = adapter.validate_json
|
|
435
|
-
elif hasattr(pydantic, "schema_of") and hasattr(pydantic, "parse_obj_as"):
|
|
436
|
-
# Pydantic 1 had similar functionality via 'schema_of' and 'parse_obj_as'
|
|
437
|
-
schema = pydantic.schema_of(model_type)
|
|
438
|
-
|
|
439
|
-
def response_parser(json_response):
|
|
440
|
-
parsed_json = json.loads(json_response)
|
|
441
|
-
return pydantic.parse_obj_as(model_type, parsed_json)
|
|
442
|
-
|
|
443
|
-
self._response_parser = response_parser
|
|
444
|
-
else:
|
|
445
|
-
# Unsupported Pydantic version
|
|
446
|
-
raise Exception("Incompatible Pydantic version")
|
|
416
|
+
schema, response_parser = _get_json_schema_and_parser_from_pydantic_model(model_type)
|
|
417
|
+
self._response_parser = response_parser
|
|
447
418
|
self.with_json_output(schema=schema, strict=strict, compatible=compatible)
|
|
448
419
|
return self
|
|
449
420
|
|
|
421
|
+
|
|
450
422
|
class DSSLLMRequestGuardrailBuilder(object):
|
|
451
423
|
def __init__(self, request, type):
|
|
452
424
|
self.request = request
|
{dataiku_api_client-14.5.0 → dataiku_api_client-14.5.2}/dataikuapi/dss/llm_utils/__init__.py
RENAMED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import copy
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from six import string_types
|
|
5
|
+
|
|
2
6
|
from ...utils import DataikuException
|
|
3
7
|
|
|
4
8
|
_footer_attributes = [
|
|
@@ -16,6 +20,59 @@ _footer_attributes = [
|
|
|
16
20
|
"contextUpsert",
|
|
17
21
|
]
|
|
18
22
|
|
|
23
|
+
def get_json_schema_and_parser(schema):
|
|
24
|
+
"""
|
|
25
|
+
Build JSON schema + parser from str, dict, Pydantic model or Python type hint.
|
|
26
|
+
str/dict input must be a valid json schema, returned parser is then None.
|
|
27
|
+
|
|
28
|
+
:rtype: Tuple[str, Optional[Callable[[str], Any]]]
|
|
29
|
+
"""
|
|
30
|
+
if isinstance(schema, string_types) and schema: # schema given directly as string
|
|
31
|
+
return schema, None
|
|
32
|
+
elif isinstance(schema, dict):
|
|
33
|
+
return json.dumps(schema), None
|
|
34
|
+
else: # schema might be given as a pydantic model :
|
|
35
|
+
json_schema, parser_method = _get_json_schema_and_parser_from_pydantic_model(schema)
|
|
36
|
+
return json.dumps(json_schema), parser_method
|
|
37
|
+
|
|
38
|
+
def _get_json_schema_and_parser_from_pydantic_model(model_type):
|
|
39
|
+
"""
|
|
40
|
+
Build JSON schema and response parser from a Pydantic model or Python type hint.
|
|
41
|
+
|
|
42
|
+
:param model_type: Pydantic BaseModel class or Python type hint.
|
|
43
|
+
:rtype: Tuple[dict, Callable[[str], Any]]
|
|
44
|
+
"""
|
|
45
|
+
if hasattr(model_type, "model_json_schema") and hasattr(model_type, "model_validate_json"):
|
|
46
|
+
# Pydantic 2 BaseModel
|
|
47
|
+
return model_type.model_json_schema(), model_type.model_validate_json
|
|
48
|
+
elif hasattr(model_type, "schema") and hasattr(model_type, "parse_raw"):
|
|
49
|
+
# Pydantic 1 BaseModel
|
|
50
|
+
return model_type.schema(), model_type.parse_raw
|
|
51
|
+
else:
|
|
52
|
+
# 'model_type' is not a Pydantic BaseModel. Derive schema from Python type hints.
|
|
53
|
+
try:
|
|
54
|
+
import pydantic
|
|
55
|
+
except ImportError:
|
|
56
|
+
raise Exception("Pydantic is required to use Python's type hints with structured output")
|
|
57
|
+
|
|
58
|
+
if hasattr(pydantic, "TypeAdapter"):
|
|
59
|
+
# Pydantic 2 provides a TypeAdapter to work with regular Python classes / type hints
|
|
60
|
+
from pydantic import TypeAdapter
|
|
61
|
+
adapter = TypeAdapter(model_type)
|
|
62
|
+
return adapter.json_schema(), adapter.validate_json
|
|
63
|
+
elif hasattr(pydantic, "schema_of") and hasattr(pydantic, "parse_obj_as"):
|
|
64
|
+
# Pydantic 1 had similar functionality via 'schema_of' and 'parse_obj_as'
|
|
65
|
+
schema = pydantic.schema_of(model_type)
|
|
66
|
+
|
|
67
|
+
def response_parser(json_response):
|
|
68
|
+
parsed_json = json.loads(json_response)
|
|
69
|
+
return pydantic.parse_obj_as(model_type, parsed_json)
|
|
70
|
+
|
|
71
|
+
return schema, response_parser
|
|
72
|
+
else:
|
|
73
|
+
# Unsupported Pydantic version
|
|
74
|
+
raise Exception("Incompatible Pydantic version")
|
|
75
|
+
|
|
19
76
|
|
|
20
77
|
class LLMException(DataikuException):
|
|
21
78
|
def __init__(self, error_message, error_code=None, error_type=None, error_source=None):
|