Skip to content

Commit 43d9baf

Browse files
authored
Publish 13.4.0 on PyPI (#317)
* Sync sources from main repo * 13.4.0 metadata
1 parent fdc24b6 commit 43d9baf

22 files changed

+1271
-60
lines changed

Diff for: HISTORY.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
==========
33

4+
13.4.0 (2025-02-11)
5+
---------------------
6+
7+
* Initial release for DSS 13.4.0
48

59
13.3.3 (2025-01-27)
610
---------------------

Diff for: dataikuapi/dss/admin.py

+75-2
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,31 @@ def remove_plugin_credential(self, plugin_id, param_set_id, preset_id, param_nam
814814
del self.settings["credentials"][name]
815815

816816

817+
class DSSUserPreferences(object):
818+
"""
819+
Preferences for a DSS user.
820+
821+
.. important::
822+
823+
Do not instantiate directly, use :meth:`DSSUserSettings.preferences` instead.
824+
"""
825+
def __init__(self, preferences):
826+
self.preferences = preferences
827+
828+
@property
829+
def ui_language(self):
830+
"""
831+
Get or set the language used in the Web User Interface for this user. Valid values are "en" (English) and "ja" (Japanese)
832+
833+
:rtype: str
834+
"""
835+
return self.preferences['uiLanguage']
836+
837+
@ui_language.setter
838+
def ui_language(self, new_value):
839+
self.preferences["uiLanguage"] = new_value
840+
841+
817842
class DSSUserSettings(DSSUserSettingsBase):
818843
"""
819844
Settings for a DSS user.
@@ -866,6 +891,16 @@ def creation_date(self):
866891
timestamp = self.settings["creationDate"] if "creationDate" in self.settings else None
867892
return _timestamp_ms_to_zoned_datetime(timestamp)
868893

894+
@property
895+
def preferences(self):
896+
"""
897+
Get the preferences for this user
898+
899+
:return: user preferences
900+
:rtype: :class:`DSSUserPreferences`
901+
"""
902+
return DSSUserPreferences(self.settings["preferences"])
903+
869904
def save(self):
870905
"""
871906
Saves the settings
@@ -1460,7 +1495,7 @@ def set_jupyter_support(self, active):
14601495
raise Exception('Env update failed : %s' % (json.dumps(resp.get('messages', {}).get('messages', {}))))
14611496
return resp
14621497

1463-
def update_packages(self, force_rebuild_env=False):
1498+
def update_packages(self, force_rebuild_env=False, version=None):
14641499
"""
14651500
Update the code env packages so that it matches its spec
14661501
@@ -1469,6 +1504,7 @@ def update_packages(self, force_rebuild_env=False):
14691504
This call requires an API key with `Create code envs` or `Manage all code envs` permission
14701505
14711506
:param boolean force_rebuild_env: whether to rebuild the code env from scratch
1507+
:param boolean version: version to rebuild (applies only to version code envs on automation nodes)
14721508
14731509
:return: list of messages collected during the operation. Fields are:
14741510
@@ -1480,7 +1516,7 @@ def update_packages(self, force_rebuild_env=False):
14801516
"""
14811517
resp = self.client._perform_json(
14821518
"POST", "/admin/code-envs/%s/%s/packages" % (self.env_lang, self.env_name),
1483-
params={"forceRebuildEnv": force_rebuild_env})
1519+
params={"forceRebuildEnv": force_rebuild_env, "versionToUpdate": version})
14841520
if resp is None:
14851521
raise Exception('Env update returned no data')
14861522
if resp.get('messages', {}).get('error', False):
@@ -2690,3 +2726,40 @@ def save(self):
26902726
"""
26912727
self.client._perform_empty("PUT", "/admin/code-studios/%s" % (self.template_id), body=self.settings)
26922728

2729+
class DSSLLMCostLimitingCounters(object):
2730+
"""
2731+
The LLM cost limiting counters of the instance
2732+
"""
2733+
def __init__(self, data):
2734+
self._data = data
2735+
2736+
def get_raw(self):
2737+
"""
2738+
Gets counters as a raw dictionary.
2739+
2740+
:return: a dictionary containing raw counters
2741+
:rtype: dict
2742+
"""
2743+
return self._data
2744+
2745+
@property
2746+
def counters(self):
2747+
"""
2748+
Get the list of counters
2749+
2750+
:return: a list of counters
2751+
:rtype: list
2752+
"""
2753+
return self._data['counters']
2754+
2755+
def get_counter(self, id):
2756+
"""
2757+
Retrieve the counters from a quota id
2758+
2759+
:param id identifier of the quota to retrieve
2760+
2761+
:return: a dictionary containing the counter
2762+
:rtype: dict
2763+
"""
2764+
return next((counter for counter in self.counters if counter["id"] == id), None)
2765+

Diff for: dataikuapi/dss/agent_tool.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from .utils import DSSTaggableObjectListItem
2+
import json
3+
4+
class DSSAgentToolListItem(DSSTaggableObjectListItem):
5+
"""
6+
.. important::
7+
Do not instantiate this class directly, instead use :meth:`dataikuapi.dss.project.DSSProject.list_agent_tools`.
8+
"""
9+
def __init__(self, client, project_key, data):
10+
super(DSSAgentToolListItem, self).__init__(data)
11+
self.project_key = project_key
12+
self.client = client
13+
14+
def to_agent_tool(self):
15+
"""
16+
Convert the current item.
17+
"""
18+
return DSSAgentTool(self.client, self.project_key, self._data["id"], "descriptor" in self._data and self._data["desciptor"] or None)
19+
20+
@property
21+
def id(self):
22+
"""
23+
:returns: The id of the tool.
24+
:rtype: string
25+
"""
26+
return self._data["id"]
27+
28+
@property
29+
def type(self):
30+
"""
31+
:returns: The type of the tool
32+
:rtype: string
33+
"""
34+
return self._data["type"]
35+
36+
@property
37+
def description(self):
38+
"""
39+
:returns: The description of the LLM (name, description, input schema)
40+
:rtype: string
41+
"""
42+
return self._data["description"]
43+
44+
45+
46+
class DSSAgentTool(object):
47+
def __init__(self, client, project_key, tool_id, descriptor=None):
48+
self.client = client
49+
self.project_key = project_key
50+
self.tool_id = tool_id
51+
self._descriptor = descriptor
52+
53+
def get_descriptor(self):
54+
if self._descriptor is None:
55+
self._descriptor = self.client._perform_json("GET", "/projects/%s/agents/tools/%s/descriptor" % (self.project_key, self.tool_id))
56+
return self._descriptor
57+
58+
59+
def as_langchain_structured_tool(self, context = None):
60+
from dataikuapi.dss.langchain.tool import convert_to_langchain_structured_tool
61+
return convert_to_langchain_structured_tool(self, context)
62+
63+
def run(self, input, context=None):
64+
invocation = {
65+
"toolId" : self.tool_id,
66+
"input" : {
67+
"input" : input
68+
}
69+
}
70+
if context is not None:
71+
invocation["input"]["context"] = context
72+
73+
return self.client._perform_json("POST", "/projects/%s/agents/tools/%s/invocations" % (self.project_key, self.tool_id), body=invocation)

0 commit comments

Comments
 (0)