cheshirecat-python-sdk 1.7.3__py3-none-any.whl → 1.7.4__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.
@@ -2,6 +2,7 @@ from cheshirecat_python_sdk.clients import HttpClient, WSClient
2
2
  from cheshirecat_python_sdk.configuration import Configuration
3
3
  from cheshirecat_python_sdk.endpoints import (
4
4
  AdminsEndpoint,
5
+ AuthEndpoint,
5
6
  AuthHandlerEndpoint,
6
7
  ChunkerEndpoint,
7
8
  ConversationEndpoint,
@@ -55,6 +56,10 @@ class CheshireCatClient:
55
56
  def admins(self):
56
57
  return AdminsEndpoint(self)
57
58
 
59
+ @property
60
+ def auth(self):
61
+ return AuthEndpoint(self)
62
+
58
63
  @property
59
64
  def auth_handler(self):
60
65
  return AuthHandlerEndpoint(self)
@@ -40,19 +40,19 @@ class HttpClient:
40
40
  if self.apikey:
41
41
  self.headers["Authorization"] = f"Bearer {self.apikey}"
42
42
  if self.agent_id:
43
- self.headers["agent_id"] = self.agent_id
43
+ self.headers["X-Agent-ID"] = self.agent_id
44
44
  if self.user_id:
45
- self.headers["user_id"] = self.user_id
45
+ self.headers["X-User-ID"] = self.user_id
46
46
  if self.chat_id:
47
- self.headers["chat_id"] = self.chat_id
47
+ self.headers["X-Chat-ID"] = self.chat_id
48
48
 
49
49
  def __before_jwt_request(self):
50
50
  if self.token:
51
51
  self.headers["Authorization"] = f"Bearer {self.token}"
52
52
  if self.agent_id:
53
- self.headers["agent_id"] = self.agent_id
53
+ self.headers["X-Agent-ID"] = self.agent_id
54
54
  if self.chat_id:
55
- self.headers["chat_id"] = self.chat_id
55
+ self.headers["X-Chat-ID"] = self.chat_id
56
56
 
57
57
  def get_client(
58
58
  self,
@@ -1,4 +1,5 @@
1
1
  from cheshirecat_python_sdk.endpoints.admins import AdminsEndpoint
2
+ from cheshirecat_python_sdk.endpoints.auth import AuthEndpoint
2
3
  from cheshirecat_python_sdk.endpoints.auth_handler import AuthHandlerEndpoint
3
4
  from cheshirecat_python_sdk.endpoints.chunker import ChunkerEndpoint
4
5
  from cheshirecat_python_sdk.endpoints.conversation import ConversationEndpoint
@@ -1,4 +1,4 @@
1
- from typing import List, Any
1
+ from typing import List
2
2
 
3
3
  from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint, MultipartPayload
4
4
  from cheshirecat_python_sdk.models.api.admins import (
@@ -10,7 +10,6 @@ from cheshirecat_python_sdk.models.api.admins import (
10
10
  )
11
11
  from cheshirecat_python_sdk.models.api.nested.plugins import PluginSettingsOutput
12
12
  from cheshirecat_python_sdk.models.api.plugins import PluginCollectionOutput, PluginsSettingsOutput, PluginToggleOutput
13
- from cheshirecat_python_sdk.models.api.tokens import TokenOutput
14
13
  from cheshirecat_python_sdk.utils import deserialize, file_attributes
15
14
 
16
15
 
@@ -19,35 +18,6 @@ class AdminsEndpoint(AbstractEndpoint):
19
18
  super().__init__(client)
20
19
  self.prefix = "/admins"
21
20
 
22
- def token(self, username: str, password: str) -> TokenOutput:
23
- """
24
- This endpoint is used to get a token for the user. The token is used to authenticate the user in the system.
25
- When the token expires, the user must request a new token.
26
- :param username: The username of the user.
27
- :param password: The password of the user.
28
- :return: TokenOutput, the token of the user.
29
- """
30
- response = self.get_http_session().post(
31
- self.format_url("/auth/token"),
32
- json={"username": username, "password": password},
33
- )
34
- response.raise_for_status()
35
-
36
- result = deserialize(response.json(), TokenOutput)
37
- self.client.add_token(result.access_token)
38
- return result
39
-
40
- def get_available_permissions(self) -> dict[int | str, Any]:
41
- """
42
- This endpoint is used to get a list of available permissions in the system. The permissions are used to define
43
- the access rights of the users in the system. The permissions are defined by the system administrator.
44
- :return array<int|string, Any>, the available permissions
45
- """
46
- response = self.get_http_client().get(self.format_url("/auth/available-permissions"))
47
- response.raise_for_status()
48
-
49
- return response.json()
50
-
51
21
  def post_admin(self, username: str, password: str, permissions: dict | None = None) -> AdminOutput:
52
22
  """
53
23
  Create a new admin user.
@@ -0,0 +1,42 @@
1
+ from typing import Any
2
+
3
+ from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
+ from cheshirecat_python_sdk.models.api.tokens import TokenOutput
5
+ from cheshirecat_python_sdk.utils import deserialize
6
+
7
+
8
+ class AuthEndpoint(AbstractEndpoint):
9
+ def __init__(self, client: "CheshireCatClient"):
10
+ super().__init__(client)
11
+ self.prefix = "/auth"
12
+
13
+ def token(self, username: str, password: str, agent_id: str | None = None) -> TokenOutput:
14
+ """
15
+ This endpoint is used to get a token for the user. The token is used to authenticate the user in the system. When
16
+ the token expires, the user must request a new token.
17
+ """
18
+ response = self.get_http_session().post(
19
+ self.format_url("/token"),
20
+ json={
21
+ "username": username,
22
+ "password": password,
23
+ },
24
+ headers={"X-Agent-ID": agent_id} if agent_id else None,
25
+ )
26
+ response.raise_for_status()
27
+
28
+ result = deserialize(response.json(), TokenOutput)
29
+ self.client.add_token(result.access_token)
30
+
31
+ return result
32
+
33
+ def get_available_permissions(self) -> dict[int | str, Any]:
34
+ """
35
+ This endpoint is used to get a list of available permissions in the system. The permissions are used to define
36
+ the access rights of the users in the system. The permissions are defined by the system administrator.
37
+ :return array<int|string, Any>, the available permissions
38
+ """
39
+ response = self.get_http_client().get(self.format_url("/available-permissions"))
40
+ response.raise_for_status()
41
+
42
+ return response.json()
@@ -1,7 +1,6 @@
1
1
  from typing import Any, List, Dict
2
2
 
3
3
  from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
- from cheshirecat_python_sdk.models.api.tokens import TokenOutput
5
4
  from cheshirecat_python_sdk.models.api.users import UserOutput
6
5
  from cheshirecat_python_sdk.utils import deserialize
7
6
 
@@ -11,33 +10,6 @@ class UsersEndpoint(AbstractEndpoint):
11
10
  super().__init__(client)
12
11
  self.prefix = "/users"
13
12
 
14
- def token(self, username: str, password: str) -> TokenOutput:
15
- """
16
- This endpoint is used to get a token for the user. The token is used to authenticate the user in the system. When
17
- the token expires, the user must request a new token.
18
- """
19
- response = self.get_http_session().post("/auth/token", json={
20
- "username": username,
21
- "password": password,
22
- })
23
- response.raise_for_status()
24
-
25
- result = deserialize(response.json(), TokenOutput)
26
- self.client.add_token(result.access_token)
27
-
28
- return result
29
-
30
- def get_available_permissions(self) -> dict[int | str, Any]:
31
- """
32
- This endpoint is used to get a list of available permissions in the system. The permissions are used to define
33
- the access rights of the users in the system. The permissions are defined by the system administrator.
34
- :return array<int|string, Any>, the available permissions
35
- """
36
- response = self.get_http_client().get("/auth/available-permissions")
37
- response.raise_for_status()
38
-
39
- return response.json()
40
-
41
13
  def post_user(
42
14
  self, agent_id: str, username: str, password: str, permissions: dict[str, Any] | None = None
43
15
  ) -> UserOutput:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cheshirecat-python-sdk
3
- Version: 1.7.3
3
+ Version: 1.7.4
4
4
  Summary: Python SDK for the Cloud-ready fork of the Cheshire Cat
5
5
  Project-URL: Repository, https://github.com/matteocacciola/cheshirecat-python-sdk
6
6
  Project-URL: Documentation, https://github.com/matteocacciola/cheshirecat-python-sdk#README
@@ -1,5 +1,5 @@
1
1
  cheshirecat_python_sdk/__init__.py,sha256=59esRUsh_6xPlfoCz-gQYQdDgp2xbaINYWyDcTJlvys,284
2
- cheshirecat_python_sdk/client.py,sha256=s5mPA9U67lcTrKZ2pKnuFd9yJKj8mOSaSNL4JUuO2ZA,2752
2
+ cheshirecat_python_sdk/client.py,sha256=J8C8j9q-Lz3cGKyYbd9w19Ayh9muMa8s3N_gYpmLI-E,2839
3
3
  cheshirecat_python_sdk/configuration.py,sha256=7uXebZGzCuJdpgOeN5l1YXkWVIrTk4apxvjPKZFcJTE,283
4
4
  cheshirecat_python_sdk/enums.py,sha256=qJyhl5D_oDMHqNcIivr9pTxNrZY6XkX7lGgGydk22TY,665
5
5
  cheshirecat_python_sdk/utils.py,sha256=2pcSCREOuIAUi5El5ou2rCm-VtmzyGVd3YHcKrFHgBM,458
@@ -9,10 +9,11 @@ cheshirecat_python_sdk/builders/memory.py,sha256=vIoQADNZF51mMjPoJ-xW6DFWgUeAufi
9
9
  cheshirecat_python_sdk/builders/settings_input.py,sha256=EvaCDmmYOtHWUwCgG-nWonkY6UF6g1blytBwAmH477I,762
10
10
  cheshirecat_python_sdk/builders/why.py,sha256=liwellCzZ6EyzWcL3lNgBy9SU76zAqGufxiaZ_o3ZT4,1008
11
11
  cheshirecat_python_sdk/clients/__init__.py,sha256=i4Hqux9vihFRbXVK48yJ1k9gm4JeCHnfPgosizQZv-g,135
12
- cheshirecat_python_sdk/clients/http_client.py,sha256=mDClvl-B7KTkHK35Gd7nkOOpkAF9vKxwlqlgmE3vDg4,2309
12
+ cheshirecat_python_sdk/clients/http_client.py,sha256=LnP0kr-kHRCwC-BZiysj1Zg-T3b3yuLd81wOctfcBTg,2319
13
13
  cheshirecat_python_sdk/clients/websocket_client.py,sha256=xNjkLSEZhpHzRqIZL21V0oG3srAGFaqYveMqlma2gvI,1932
14
- cheshirecat_python_sdk/endpoints/__init__.py,sha256=ViB3JVpc9-H2-TrjNCSN42TuGDf6qyzDzWh4N7vQuGc,1184
15
- cheshirecat_python_sdk/endpoints/admins.py,sha256=-SNwYKENanA7eM9voPG27KCElG42asEVyDQTRfVT9g8,8407
14
+ cheshirecat_python_sdk/endpoints/__init__.py,sha256=uQPclok3DdKTibR7ywDVM67eqtxEMwx_iuza37Wqkr8,1247
15
+ cheshirecat_python_sdk/endpoints/admins.py,sha256=rc6jEhYF8KTTWFXLinm3xPV7Rj87iKT8Kp0zHn1qUO4,7024
16
+ cheshirecat_python_sdk/endpoints/auth.py,sha256=GcmN90uZIgeRqc_NjBhZx7bxYRSpfKL6ZOLHLom1aKQ,1658
16
17
  cheshirecat_python_sdk/endpoints/auth_handler.py,sha256=Jfi7E7L3SIzJyECbJnUenIyl6xxkJlyC31AHpAlmqSs,2117
17
18
  cheshirecat_python_sdk/endpoints/base.py,sha256=ldayH0QxQfzD5bYqlMBH1JVBOTd11RYDWxf-6kl0fng,4003
18
19
  cheshirecat_python_sdk/endpoints/chunker.py,sha256=bgp-2gQpKt7W_B46eEb-KFRkd4eZJH0euwsf3N0jfC8,1979
@@ -26,7 +27,7 @@ cheshirecat_python_sdk/endpoints/memory.py,sha256=dEnQ2Hb_VG907p7T9oQgPCWWFHAUwk
26
27
  cheshirecat_python_sdk/endpoints/message.py,sha256=QTUSUJcj52VhfnX9hdjsD2aLeFC43O4eU8ld5lRvITU,2607
27
28
  cheshirecat_python_sdk/endpoints/plugins.py,sha256=FasjwNY2UVv7zfg9lvXEj2ATefPDOPQpJXzQ2BbQIYI,3474
28
29
  cheshirecat_python_sdk/endpoints/rabbit_hole.py,sha256=DH5KGpk0Ur8RPi1fZIO9D925mc2D0GHQpsOeIKIa1G0,7213
29
- cheshirecat_python_sdk/endpoints/users.py,sha256=Pc_Od5pNMiyEAbxs_-en4YAZOfIPa1vZOcjScsJFh04,6559
30
+ cheshirecat_python_sdk/endpoints/users.py,sha256=PXlPPobLoWpiuAzi0k89YUyqSp24Sc5DEcDQYGRXRBA,5369
30
31
  cheshirecat_python_sdk/endpoints/utils.py,sha256=UhhWCC4h9c7lbPxAaV3nHjLYwod4z0tHzrE-2tuKs8M,2328
31
32
  cheshirecat_python_sdk/endpoints/vector_database.py,sha256=Xu6zcopjZgcFVVmyN547piiqFcaTUtF35X0QxQHycXQ,2149
32
33
  cheshirecat_python_sdk/models/dtos.py,sha256=yK6CfCGdwLvZtYFPoImDEgpV5eyHB2iwji2t6dh6gxc,668
@@ -42,7 +43,7 @@ cheshirecat_python_sdk/models/api/tokens.py,sha256=5vzQqmcYWg593U1cTnnmLPZMNkgNN
42
43
  cheshirecat_python_sdk/models/api/users.py,sha256=2l86y6ol0R0823gGl4bmc1TzGP4ZyvTm9AR8riKiatA,160
43
44
  cheshirecat_python_sdk/models/api/nested/memories.py,sha256=ddGDsmZa2refElM0sGz9QfKHGk50wsTpkwN5qDC5bF4,946
44
45
  cheshirecat_python_sdk/models/api/nested/plugins.py,sha256=7vrwgXh0csaUn11YKY_OWnGEnD8Fu_ewKxt024VOBEs,738
45
- cheshirecat_python_sdk-1.7.3.dist-info/METADATA,sha256=dTIDOlGA3_ZxozOkspAz0wqxRNIvJFlBbtqyb_kP4gc,44136
46
- cheshirecat_python_sdk-1.7.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
47
- cheshirecat_python_sdk-1.7.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
48
- cheshirecat_python_sdk-1.7.3.dist-info/RECORD,,
46
+ cheshirecat_python_sdk-1.7.4.dist-info/METADATA,sha256=R1wHR1rsC5gYTtJFJ-zM02uo_qY2S2yJa-i8Bh5i4eM,44136
47
+ cheshirecat_python_sdk-1.7.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
48
+ cheshirecat_python_sdk-1.7.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
49
+ cheshirecat_python_sdk-1.7.4.dist-info/RECORD,,