cheshirecat-python-sdk 1.8.4__py3-none-any.whl → 1.8.6__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.
@@ -1,11 +1,11 @@
1
- from typing import List
1
+ from typing import List, Dict
2
2
 
3
3
  from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
4
  from cheshirecat_python_sdk.models.api.conversations import (
5
5
  ConversationHistoryOutput,
6
6
  ConversationDeleteOutput,
7
7
  ConversationsResponse,
8
- ConversationNameChangeOutput,
8
+ ConversationAttributesChangeOutput,
9
9
  )
10
10
  from cheshirecat_python_sdk.utils import deserialize
11
11
 
@@ -13,7 +13,7 @@ from cheshirecat_python_sdk.utils import deserialize
13
13
  class ConversationEndpoint(AbstractEndpoint):
14
14
  def __init__(self, client: "CheshireCatClient"):
15
15
  super().__init__(client)
16
- self.prefix = "/conversation"
16
+ self.prefix = "/conversations"
17
17
 
18
18
  def get_conversation_history(self, agent_id: str, user_id: str, chat_id: str) -> ConversationHistoryOutput:
19
19
  """
@@ -24,7 +24,7 @@ class ConversationEndpoint(AbstractEndpoint):
24
24
  :return: ConversationHistoryOutput, a list of conversation history entries.
25
25
  """
26
26
  return self.get(
27
- self.format_url(chat_id),
27
+ self.format_url(f"{chat_id}/history"),
28
28
  agent_id,
29
29
  user_id=user_id,
30
30
  output_class=ConversationHistoryOutput,
@@ -42,6 +42,22 @@ class ConversationEndpoint(AbstractEndpoint):
42
42
 
43
43
  return [deserialize(item, ConversationsResponse) for item in response.json()]
44
44
 
45
+ def get_conversation(self, agent_id: str, user_id: str, chat_id: str) -> ConversationsResponse:
46
+ """
47
+ This endpoint returns the attributes of a specific conversation, given the `agent_id`, the `user_id` and the
48
+ `chat_id`.
49
+ :param agent_id: The agent ID.
50
+ :param user_id: The user ID to filter the conversation history.
51
+ :param chat_id: The chat ID to filter the conversation history.
52
+ :return: ConversationsResponse, the conversation attributes.
53
+ """
54
+ return self.get(
55
+ self.format_url(chat_id),
56
+ agent_id,
57
+ user_id=user_id,
58
+ output_class=ConversationsResponse,
59
+ )
60
+
45
61
  def delete_conversation(self, agent_id: str, user_id: str, chat_id: str) -> ConversationDeleteOutput:
46
62
  """
47
63
  This endpoint deletes the conversation.
@@ -57,27 +73,36 @@ class ConversationEndpoint(AbstractEndpoint):
57
73
  user_id=user_id,
58
74
  )
59
75
 
60
- def post_conversation_name(
76
+ def put_conversation_attributes(
61
77
  self,
62
- name: str,
63
78
  agent_id: str,
64
79
  user_id: str,
65
80
  chat_id: str,
66
- ) -> ConversationNameChangeOutput:
81
+ name: str | None,
82
+ metadata: Dict | None = None,
83
+ ) -> ConversationAttributesChangeOutput:
67
84
  """
68
85
  This endpoint creates a new element in the conversation history.
69
- :param name: The new name to assign to the conversation
70
86
  :param agent_id: The agent ID.
71
87
  :param user_id: The user ID to filter the conversation history.
72
88
  :param chat_id: The chat ID to filter the conversation history.
89
+ :param name: The new name to assign to the conversation
90
+ :param metadata: The metadata to assign to the conversation
73
91
  :return: ConversationNameChangeOutput, a message indicating whether the conversation name was changed.
74
92
  """
75
- payload = {"name": name}
93
+ if not name and not metadata:
94
+ raise ValueError("Either name or metadata must be provided")
95
+
96
+ payload = {}
97
+ if name:
98
+ payload = {"name": name}
99
+ if metadata:
100
+ payload["metadata"] = metadata
76
101
 
77
- return self.post_json(
102
+ return self.put(
78
103
  self.format_url(chat_id),
79
104
  agent_id,
80
- output_class=ConversationNameChangeOutput,
105
+ output_class=ConversationAttributesChangeOutput,
81
106
  payload=payload,
82
107
  user_id=user_id,
83
108
  )
@@ -59,10 +59,7 @@ class UsersEndpoint(AbstractEndpoint):
59
59
  response = self.get_http_client(agent_id).get(self.prefix)
60
60
  response.raise_for_status()
61
61
 
62
- result = []
63
- for item in response.json():
64
- result.append(deserialize(item, UserOutput))
65
- return result
62
+ return [deserialize(item, UserOutput) for item in response.json()]
66
63
 
67
64
  def get_user(self, user_id: str, agent_id: str) -> UserOutput:
68
65
  """
@@ -1,7 +1,13 @@
1
- from typing import List
1
+ from typing import List, Dict
2
2
 
3
3
  from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
- from cheshirecat_python_sdk.models.api.admins import ResetOutput, ClonedOutput, CreatedOutput
4
+ from cheshirecat_python_sdk.models.api.admins import (
5
+ ResetOutput,
6
+ AgentClonedOutput,
7
+ AgentCreatedOutput,
8
+ AgentOutput,
9
+ AgentUpdatedOutput,
10
+ )
5
11
  from cheshirecat_python_sdk.utils import deserialize
6
12
 
7
13
 
@@ -17,28 +23,33 @@ class UtilsEndpoint(AbstractEndpoint):
17
23
  """
18
24
  return self.post_json(self.format_url("/factory/reset/"), self.system_id, output_class=ResetOutput)
19
25
 
20
- def get_agents(self) -> List[str]:
26
+ def get_agents(self) -> List[AgentOutput]:
21
27
  """
22
28
  Get a list of all agents.
23
- :return: List[str], the IDs of the agents.
29
+ :return: List[AgentOutput], the ID and the metadata of the agents.
24
30
  """
25
- return self.get(self.format_url("/agents/"), self.system_id)
31
+ response = self.get_http_client(agent_id=self.system_id).get(self.format_url("/agents/"))
32
+ response.raise_for_status()
33
+
34
+ return [deserialize(item, AgentOutput) for item in response.json()]
26
35
 
27
- def post_agent_create(self, agent_id: str) -> CreatedOutput:
36
+ def post_agent_create(self, agent_id: str, metadata: Dict | None = None) -> AgentCreatedOutput:
28
37
  """
29
38
  Create a new agent.
30
39
  :param agent_id: The ID of the agent.
31
- :return: CreatedOutput, the details of the agent.
40
+ :param metadata: The metadata of the agent.
41
+ :return: AgentCreatedOutput, the details of the agent.
32
42
  """
33
- response = self.get_http_client().post(
43
+ payload = {"agent_id": agent_id}
44
+ if metadata is not None:
45
+ payload["metadata"] = metadata # type: ignore
46
+
47
+ return self.post_json(
34
48
  self.format_url("/agents/create/"),
35
- json={
36
- "agent_id": agent_id,
37
- },
49
+ self.system_id,
50
+ output_class=AgentCreatedOutput,
51
+ payload=payload,
38
52
  )
39
- response.raise_for_status()
40
-
41
- return deserialize(response.json(), CreatedOutput)
42
53
 
43
54
  def post_agent_reset(self, agent_id: str) -> ResetOutput:
44
55
  """
@@ -56,16 +67,30 @@ class UtilsEndpoint(AbstractEndpoint):
56
67
  """
57
68
  return self.post_json(self.format_url("/agents/destroy/"), agent_id, output_class=ResetOutput)
58
69
 
59
- def post_agent_clone(self, agent_id: str, new_agent_id: str) -> ClonedOutput:
70
+ def post_agent_clone(self, agent_id: str, new_agent_id: str) -> AgentClonedOutput:
60
71
  """
61
72
  Destroy an agent.
62
73
  :param agent_id: The ID of the agent.
63
74
  :param new_agent_id: The ID of the new cloned agent.
64
- :return: ClonedOutput, the details of the cloning.
75
+ :return: AgentClonedOutput, the details of the cloning.
65
76
  """
66
77
  return self.post_json(
67
78
  self.format_url("/agents/clone/"),
68
79
  agent_id,
69
80
  payload={"agent_id": new_agent_id},
70
- output_class=ClonedOutput
71
- )
81
+ output_class=AgentClonedOutput,
82
+ )
83
+
84
+ def put_agent(self, agent_id: str, metadata: Dict) -> AgentUpdatedOutput:
85
+ """
86
+ Update the metadata of an agent.
87
+ :param agent_id: The ID of the agent.
88
+ :param metadata: The new metadata for the agent.
89
+ :return: AgentUpdatedOutput, the details of the update.
90
+ """
91
+ return self.put(
92
+ self.format_url("/agents/"),
93
+ agent_id,
94
+ payload={"metadata": metadata},
95
+ output_class=AgentUpdatedOutput,
96
+ )
@@ -4,7 +4,7 @@ from pydantic import BaseModel
4
4
  from cheshirecat_python_sdk.models.api.plugins import PluginToggleOutput
5
5
 
6
6
 
7
- class CreatedOutput(BaseModel):
7
+ class AgentCreatedOutput(BaseModel):
8
8
  created: bool
9
9
 
10
10
 
@@ -32,5 +32,14 @@ class ResetOutput(BaseModel):
32
32
  deleted_plugin_folders: bool
33
33
 
34
34
 
35
- class ClonedOutput(BaseModel):
35
+ class AgentClonedOutput(BaseModel):
36
36
  cloned: bool = False
37
+
38
+
39
+ class AgentUpdatedOutput(BaseModel):
40
+ updated: bool
41
+
42
+
43
+ class AgentOutput(BaseModel):
44
+ agent_id: str
45
+ metadata: Dict
@@ -1,4 +1,4 @@
1
- from typing import List
1
+ from typing import List, Any, Dict
2
2
  from pydantic import BaseModel
3
3
 
4
4
  from cheshirecat_python_sdk.models.api.nested.memories import ConversationMessage
@@ -16,9 +16,10 @@ class ConversationsResponse(BaseModel):
16
16
  chat_id: str
17
17
  name: str
18
18
  num_messages: int
19
+ metadata: Dict[str, Any]
19
20
  created_at: float | None
20
21
  updated_at: float | None
21
22
 
22
23
 
23
- class ConversationNameChangeOutput(BaseModel):
24
+ class ConversationAttributesChangeOutput(BaseModel):
24
25
  changed: bool
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cheshirecat-python-sdk
3
- Version: 1.8.4
3
+ Version: 1.8.6
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
@@ -18,7 +18,7 @@ cheshirecat_python_sdk/endpoints/auth.py,sha256=_22fLGznoxo2pybcQGgcsHCpLoq76P6R
18
18
  cheshirecat_python_sdk/endpoints/auth_handler.py,sha256=Jfi7E7L3SIzJyECbJnUenIyl6xxkJlyC31AHpAlmqSs,2117
19
19
  cheshirecat_python_sdk/endpoints/base.py,sha256=0X2EQxRGqR6VG5gXE5XKcscmQ7rNM9de61GBrQlKD90,4210
20
20
  cheshirecat_python_sdk/endpoints/chunker.py,sha256=bgp-2gQpKt7W_B46eEb-KFRkd4eZJH0euwsf3N0jfC8,1979
21
- cheshirecat_python_sdk/endpoints/conversation.py,sha256=jG1z7ivdD53H8JZe7WZWihoBWy2_-W951SwKXmnpmTk,3282
21
+ cheshirecat_python_sdk/endpoints/conversation.py,sha256=OGxG312kQBzL5629vCmTreltUrEnoUV4JshZUcj4L2U,4335
22
22
  cheshirecat_python_sdk/endpoints/custom_endpoint.py,sha256=HVRQMqA5JfPr87gHtWpYcsXsE-TA-coXLcvsPKabqds,2791
23
23
  cheshirecat_python_sdk/endpoints/embedder.py,sha256=4B2yc3KBThKGreq_KPTTCsxt2Ekktw_muZ5gBfxrrwY,1741
24
24
  cheshirecat_python_sdk/endpoints/file_manager.py,sha256=U4kc2oR3UszK0EKzYnES_RkgF1zhaPINAW_3X2WgX7A,4614
@@ -28,12 +28,12 @@ cheshirecat_python_sdk/endpoints/memory.py,sha256=dgfoyjZH0gL3kln31gFJ42JHfL-S-o
28
28
  cheshirecat_python_sdk/endpoints/message.py,sha256=QTUSUJcj52VhfnX9hdjsD2aLeFC43O4eU8ld5lRvITU,2607
29
29
  cheshirecat_python_sdk/endpoints/plugins.py,sha256=FasjwNY2UVv7zfg9lvXEj2ATefPDOPQpJXzQ2BbQIYI,3474
30
30
  cheshirecat_python_sdk/endpoints/rabbit_hole.py,sha256=KjF5IRG6ghGEji-Js5try-9FhmWsuiM5v04jA68VoVY,7316
31
- cheshirecat_python_sdk/endpoints/users.py,sha256=ySpFi9ILyoT44fnAz8p4LSGTaEAMWv3RBWq72Hv73mI,5803
32
- cheshirecat_python_sdk/endpoints/utils.py,sha256=yKGrFRpu6ItLnBEuc98093LbXqGYaGdgCLiWuLQJVno,2551
31
+ cheshirecat_python_sdk/endpoints/users.py,sha256=19kei56IDYlteq_KePgzjJne_NgJkaLDAyPVwV3_2i8,5742
32
+ cheshirecat_python_sdk/endpoints/utils.py,sha256=etF2lipz-rGY8CAQve0zqDIgauJGeTdGYB3PtkcAb_4,3457
33
33
  cheshirecat_python_sdk/endpoints/vector_database.py,sha256=Xu6zcopjZgcFVVmyN547piiqFcaTUtF35X0QxQHycXQ,2149
34
34
  cheshirecat_python_sdk/models/dtos.py,sha256=0N6Auv43Gifo0ptdZxMZXAB6QGk8NNbcf8vQGm8HClo,869
35
- cheshirecat_python_sdk/models/api/admins.py,sha256=sIX4NdEntjORgVACsqkBkzte4zwD6w35BdPRRG0D7uo,661
36
- cheshirecat_python_sdk/models/api/conversations.py,sha256=Ej8677MLBqZEME1lZFd4UhHokdja762zYNjV9ZaEg-I,505
35
+ cheshirecat_python_sdk/models/api/admins.py,sha256=eIzK2MFjzF3w9Sqgt1Rkei-IW06sMpBhuOea7HenvSY,797
36
+ cheshirecat_python_sdk/models/api/conversations.py,sha256=ifgCwbtYwPiilQ-pz1peXaR7yVDNXlmIy_eWp25LGDE,551
37
37
  cheshirecat_python_sdk/models/api/factories.py,sha256=_NWz0nKhaVYEbaphxe2YZGznDIUiMKb-xqA1xymME5A,594
38
38
  cheshirecat_python_sdk/models/api/file_managers.py,sha256=V0ZBjQWmYM1t0Qpfp3W2NDI_tScOtORB0i5YMEpTiRU,301
39
39
  cheshirecat_python_sdk/models/api/memories.py,sha256=4rqFuFNzNbmwIG1KGiSyfnv40nds5g7fSkov3drj0cc,948
@@ -44,7 +44,7 @@ cheshirecat_python_sdk/models/api/tokens.py,sha256=GavSaCq0-SRWjvLtDgrYBOdUELd7V
44
44
  cheshirecat_python_sdk/models/api/users.py,sha256=_T3-8hfmlZK9cZcqBTbNMYS74yEnDrRACRQn9PNCEiQ,280
45
45
  cheshirecat_python_sdk/models/api/nested/memories.py,sha256=ddGDsmZa2refElM0sGz9QfKHGk50wsTpkwN5qDC5bF4,946
46
46
  cheshirecat_python_sdk/models/api/nested/plugins.py,sha256=7vrwgXh0csaUn11YKY_OWnGEnD8Fu_ewKxt024VOBEs,738
47
- cheshirecat_python_sdk-1.8.4.dist-info/METADATA,sha256=f5sjZkDGm4AXlxsMLbEjOEEgD2Pyke2NMqM7zi0Ag_4,44136
48
- cheshirecat_python_sdk-1.8.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
49
- cheshirecat_python_sdk-1.8.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
50
- cheshirecat_python_sdk-1.8.4.dist-info/RECORD,,
47
+ cheshirecat_python_sdk-1.8.6.dist-info/METADATA,sha256=-bXe7LwP6dz8_a8LmjHqOEV8XYO9Svml0kXY6wD1DTI,44136
48
+ cheshirecat_python_sdk-1.8.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
49
+ cheshirecat_python_sdk-1.8.6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
50
+ cheshirecat_python_sdk-1.8.6.dist-info/RECORD,,