cheshirecat-python-sdk 1.2.1__py3-none-any.whl → 1.7.9__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 (47) hide show
  1. cheshirecat_python_sdk/__init__.py +0 -1
  2. cheshirecat_python_sdk/builders/memory.py +0 -12
  3. cheshirecat_python_sdk/builders/why.py +0 -6
  4. cheshirecat_python_sdk/client.py +30 -5
  5. cheshirecat_python_sdk/clients/http_client.py +21 -7
  6. cheshirecat_python_sdk/clients/websocket_client.py +21 -15
  7. cheshirecat_python_sdk/configuration.py +1 -1
  8. cheshirecat_python_sdk/endpoints/__init__.py +6 -1
  9. cheshirecat_python_sdk/endpoints/admins.py +37 -70
  10. cheshirecat_python_sdk/endpoints/auth.py +54 -0
  11. cheshirecat_python_sdk/endpoints/auth_handler.py +8 -8
  12. cheshirecat_python_sdk/endpoints/base.py +48 -17
  13. cheshirecat_python_sdk/endpoints/chunker.py +8 -8
  14. cheshirecat_python_sdk/endpoints/conversation.py +83 -0
  15. cheshirecat_python_sdk/endpoints/custom_endpoint.py +57 -0
  16. cheshirecat_python_sdk/endpoints/embedder.py +4 -4
  17. cheshirecat_python_sdk/endpoints/file_manager.py +59 -8
  18. cheshirecat_python_sdk/endpoints/health_check.py +22 -0
  19. cheshirecat_python_sdk/endpoints/large_language_model.py +8 -8
  20. cheshirecat_python_sdk/endpoints/memory.py +70 -145
  21. cheshirecat_python_sdk/endpoints/message.py +29 -13
  22. cheshirecat_python_sdk/endpoints/plugins.py +31 -26
  23. cheshirecat_python_sdk/endpoints/rabbit_hole.py +51 -23
  24. cheshirecat_python_sdk/endpoints/users.py +22 -56
  25. cheshirecat_python_sdk/endpoints/utils.py +71 -0
  26. cheshirecat_python_sdk/endpoints/vector_database.py +52 -0
  27. cheshirecat_python_sdk/enums.py +0 -11
  28. cheshirecat_python_sdk/models/api/admins.py +4 -0
  29. cheshirecat_python_sdk/models/api/conversations.py +24 -0
  30. cheshirecat_python_sdk/models/api/factories.py +6 -0
  31. cheshirecat_python_sdk/models/api/file_managers.py +18 -0
  32. cheshirecat_python_sdk/models/api/memories.py +2 -10
  33. cheshirecat_python_sdk/models/api/messages.py +8 -6
  34. cheshirecat_python_sdk/models/api/nested/memories.py +5 -5
  35. cheshirecat_python_sdk/models/api/nested/plugins.py +8 -2
  36. cheshirecat_python_sdk/models/api/plugins.py +30 -22
  37. cheshirecat_python_sdk/models/api/tokens.py +19 -0
  38. cheshirecat_python_sdk/models/api/users.py +2 -0
  39. cheshirecat_python_sdk/models/dtos.py +3 -13
  40. cheshirecat_python_sdk/utils.py +2 -1
  41. {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.7.9.dist-info}/METADATA +12 -10
  42. cheshirecat_python_sdk-1.7.9.dist-info/RECORD +49 -0
  43. {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.7.9.dist-info}/WHEEL +1 -1
  44. cheshirecat_python_sdk/endpoints/settings.py +0 -63
  45. cheshirecat_python_sdk/models/api/settings.py +0 -22
  46. cheshirecat_python_sdk-1.2.1.dist-info/RECORD +0 -43
  47. {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.7.9.dist-info}/licenses/LICENSE +0 -0
@@ -19,8 +19,9 @@ class RabbitHoleEndpoint(AbstractEndpoint):
19
19
  def post_file(
20
20
  self,
21
21
  file_path,
22
+ agent_id: str,
23
+ chat_id: str | None = None,
22
24
  file_name: str | None = None,
23
- agent_id: str | None = None,
24
25
  metadata: Dict[str, Any] | None = None,
25
26
  ) -> UploadSingleFileResponse:
26
27
  """
@@ -29,8 +30,9 @@ class RabbitHoleEndpoint(AbstractEndpoint):
29
30
  The process is asynchronous and the results are returned in a batch.
30
31
  The CheshireCat processes the injection in background and the client will be informed at the end of the process.
31
32
  :param file_path: The path to the file to upload.
32
- :param file_name: The name of the file.
33
33
  :param agent_id: The ID of the agent.
34
+ :param chat_id: The ID of the chat (optional).
35
+ :param file_name: The name of the file.
34
36
  :param metadata: The metadata to include with the file.
35
37
  :return: The response from the RabbitHole API.
36
38
  """
@@ -40,24 +42,28 @@ class RabbitHoleEndpoint(AbstractEndpoint):
40
42
  if metadata is not None:
41
43
  payload.data["metadata"] = json.dumps(metadata)
42
44
 
45
+ endpoint = self.prefix if not chat_id else self.format_url(chat_id)
46
+
43
47
  with open(file_path, "rb") as file:
44
48
  payload.files = [("file", file_attributes(file_name, file))]
45
- result = self.post_multipart(self.prefix, UploadSingleFileResponse, payload, agent_id)
49
+ result = self.post_multipart(endpoint, agent_id, output_class=UploadSingleFileResponse, payload=payload)
46
50
 
47
51
  return result
48
52
 
49
53
  def post_files(
50
54
  self,
51
55
  file_paths: List[str],
52
- agent_id: str | None = None,
56
+ agent_id: str,
57
+ chat_id: str | None = None,
53
58
  metadata: Dict[str, Any] | None = None
54
- ) -> Dict[str, UploadSingleFileResponse]:
59
+ ) -> Dict[str, UploadSingleFileResponse]: # type: ignore
55
60
  """
56
61
  Posts multiple files to the RabbitHole API. The files are uploaded to the RabbitHole server and
57
62
  ingested into the RAG system. The files are processed in a batch. The process is asynchronous.
58
63
  The CheshireCat processes the injection in background and the client will be informed at the end of the process.
59
64
  :param file_paths: The paths to the files to upload.
60
65
  :param agent_id: The ID of the agent.
66
+ :param chat_id: The ID of the chat (optional).
61
67
  :param metadata: The metadata to include with the files.
62
68
  :return: The response from the RabbitHole API.
63
69
  """
@@ -67,13 +73,16 @@ class RabbitHoleEndpoint(AbstractEndpoint):
67
73
 
68
74
  files = []
69
75
  file_handles = []
76
+
77
+ endpoint = self.format_url("/batch") if not chat_id else self.format_url(f"/batch/{chat_id}")
70
78
  try:
71
79
  for file_path in file_paths:
72
80
  file = open(file_path, "rb")
73
81
  file_handles.append(file)
74
82
  files.append(("files", file_attributes(Path(file_path).name, file)))
75
83
 
76
- response = self.get_http_client(agent_id).post(self.format_url("/batch"), data=data, files=files)
84
+ response = self.get_http_client(agent_id).post(endpoint, data=data, files=files)
85
+ response.raise_for_status()
77
86
 
78
87
  result = {}
79
88
  for key, item in response.json().items():
@@ -86,39 +95,43 @@ class RabbitHoleEndpoint(AbstractEndpoint):
86
95
  def post_web(
87
96
  self,
88
97
  web_url: str,
89
- agent_id: str | None = None,
98
+ agent_id: str,
99
+ chat_id: str | None = None,
90
100
  metadata: Dict[str, Any] | None = None
91
101
  ) -> UploadUrlResponse:
92
102
  """
93
103
  Posts a web URL to the RabbitHole API. The web URL is ingested into the RAG system. The web URL is
94
- processed by the RAG system by Web scraping and the results are stored in the RAG database.
104
+ processed by the RAG system by Web scraping, and the results are stored in the RAG database.
95
105
  The process is asynchronous.
96
- The CheshireCat processes the injection in background and the client will be informed at the end of the process.
106
+ The CheshireCat processes the injection in background, and the client will be informed at the end of the process.
97
107
  :param web_url: The URL of the website to ingest.
98
108
  :param agent_id: The ID of the agent.
109
+ :param chat_id: The ID of the chat (optional).
99
110
  :param metadata: The metadata to include with the files.
100
111
  :return: The response from the RabbitHole API.
101
112
  """
102
113
  payload = {"url": web_url}
103
114
  if metadata is not None:
104
- payload["metadata"] = metadata
115
+ payload["metadata"] = metadata # type: ignore
116
+
117
+ endpoint = self.format_url("/web") if not chat_id else self.format_url(f"/web/{chat_id}")
105
118
 
106
- return self.post_json(f"{self.prefix}/web", UploadUrlResponse, payload, agent_id)
119
+ return self.post_json(endpoint, agent_id, output_class=UploadUrlResponse, payload=payload)
107
120
 
108
121
  def post_memory(
109
122
  self,
110
123
  file_path: str,
124
+ agent_id: str,
111
125
  file_name: str | None = None,
112
- agent_id: str | None = None
113
126
  ) -> UploadSingleFileResponse:
114
127
  """
115
- Posts a memory point, either for the agent identified by the agent_id parameter (for multi-agent
116
- installations) or for the default agent (for single-agent installations). The memory point is ingested into the
117
- RAG system. The process is asynchronous. The provided file must be in JSON format.
118
- The CheshireCat processes the injection in background and the client will be informed at the end of the process.
128
+ Posts a memory point, for the agent identified by the agent_id parameter.
129
+ The memory point is ingested into the RAG system. The process is asynchronous. The provided file must be in JSON
130
+ format. The CheshireCat processes the injection in the background, and the client will be informed at the end of
131
+ the process.
119
132
  :param file_path: The path to the file to upload.
120
- :param file_name: The name of the file.
121
133
  :param agent_id: The ID of the agent.
134
+ :param file_name: The name of the file (optional).
122
135
  :return: The response from the RabbitHole API.
123
136
  """
124
137
  file_name = file_name or Path(file_path).name
@@ -126,18 +139,33 @@ class RabbitHoleEndpoint(AbstractEndpoint):
126
139
  payload = MultipartPayload()
127
140
  with open(file_path, "rb") as file:
128
141
  payload.files = [("file", file_attributes(file_name, file))]
129
- result = self.post_multipart(f"{self.prefix}/memory", UploadSingleFileResponse, payload, agent_id)
142
+ result = self.post_multipart(
143
+ self.format_url("/memory"), agent_id, output_class=UploadSingleFileResponse, payload=payload
144
+ )
130
145
 
131
146
  return result
132
147
 
133
- def get_allowed_mime_types(self, agent_id: str | None = None) -> AllowedMimeTypesOutput:
148
+ def get_allowed_mime_types(self, agent_id: str) -> AllowedMimeTypesOutput:
134
149
  """
135
150
  Retrieves the allowed MIME types for the RabbitHole API. The allowed MIME types are the MIME types
136
151
  that are allowed to be uploaded to the RabbitHole API. The allowed MIME types are returned in a list.
137
- If the agent_id parameter is provided, the allowed MIME types are retrieved for the agent identified by the
138
- agent_id parameter (for multi-agent installations). If the agent_id parameter is not provided, the allowed MIME
139
- types are retrieved for the default agent (for single-agent installations).
140
152
  :param agent_id: The ID of the agent.
141
153
  :return: AllowedMimeTypesOutput, the details of the allowed MIME types.
142
154
  """
143
- return self.get(f"{self.prefix}/allowed-mimetypes", AllowedMimeTypesOutput, agent_id)
155
+ return self.get(
156
+ self.format_url("/allowed-mimetypes"),
157
+ agent_id,
158
+ output_class=AllowedMimeTypesOutput
159
+ )
160
+
161
+ def get_web_sources(self, agent_id: str) -> List[str]:
162
+ """
163
+ This method retrieves the web sources for the RabbitHole API. The web sources are the web URLs that are allowed
164
+ to be uploaded to the RabbitHole API. The web sources are returned in a list.
165
+ :param agent_id: The ID of the agent.
166
+ :return: List[str]
167
+ """
168
+ return self.get(
169
+ self.format_url("/web"),
170
+ agent_id,
171
+ )
@@ -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,48 +10,18 @@ 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
- http_client = self.client.http_client.get_client()
20
-
21
- response = http_client.post("/auth/token", json={
22
- "username": username,
23
- "password": password,
24
- })
25
-
26
- result = deserialize(response.json(), TokenOutput)
27
- self.client.add_token(result.access_token)
28
-
29
- return result
30
-
31
- def get_available_permissions(self, agent_id: str | None = None) -> dict[int | str, Any]:
32
- """
33
- This endpoint is used to get a list of available permissions in the system. The permissions are used to define
34
- the access rights of the users in the system. The permissions are defined by the system administrator.
35
- The endpoint can be used either for the agent identified by the agentId parameter (for multi-agent installations)
36
- or for the default agent (for single-agent installations).
37
- :param agent_id: The id of the agent to get settings for (optional)
38
- :return array<int|string, Any>, the available permissions
39
- """
40
- return self.get("/auth/available-permissions", agent_id=agent_id)
41
-
42
13
  def post_user(
43
- self, username: str, password: str, permissions: dict[str, Any] | None = None, agent_id: str | None = None
14
+ self, agent_id: str, username: str, password: str, permissions: dict[str, Any] | None = None
44
15
  ) -> UserOutput:
45
16
  """
46
17
  This endpoint is used to create a new user in the system. The user is created with the specified username and
47
18
  password. The user is assigned the specified permissions. The permissions are used to define the access rights
48
19
  of the user in the system and are defined by the system administrator.
49
- The endpoint can be used either for the
50
- agent identified by the agentId parameter (for multi-agent installations) or for the default agent (for
51
- single-agent installations).
20
+ The endpoint can be used for the agent identified by the agentId parameter.
21
+ :param agent_id: The id of the agent to create the user for
52
22
  :param username: The username of the user to create
53
23
  :param password: The password of the user to create
54
24
  :param permissions: The permissions of the user to create (optional)
55
- :param agent_id: The id of the agent to create the user for (optional)
56
25
  :return UserOutput, the created user
57
26
  """
58
27
  payload = {
@@ -60,66 +29,64 @@ class UsersEndpoint(AbstractEndpoint):
60
29
  "password": password,
61
30
  }
62
31
  if permissions is not None:
63
- payload["permissions"] = permissions
32
+ payload["permissions"] = permissions # type: ignore
64
33
 
65
34
  return self.post_json(
66
35
  self.prefix,
67
- UserOutput,
68
- payload,
69
36
  agent_id,
37
+ output_class=UserOutput,
38
+ payload=payload,
70
39
  )
71
40
 
72
- def get_users(self, agent_id: str | None = None) -> List[UserOutput]:
41
+ def get_users(self, agent_id: str) -> List[UserOutput]:
73
42
  """
74
43
  This endpoint is used to get a list of users in the system. The list includes the username and the permissions of
75
44
  each user. The permissions are used to define the access rights of the users in the system and are defined by the
76
45
  system administrator.
77
- The endpoint can be used either for the agent identified by the agentId parameter (for multi-agent installations)
78
- or for the default agent (for single-agent installations).
79
- :param agent_id: The id of the agent to get users for (optional)
46
+ The endpoint can be used for the agent identified by the agentId parameter.
47
+ :param agent_id: The id of the agent to get users for
80
48
  :return List[UserOutput], the users in the system with their permissions for the agent identified by agent_id
81
49
  """
82
50
  response = self.get_http_client(agent_id).get(self.prefix)
51
+ response.raise_for_status()
83
52
 
84
53
  result = []
85
54
  for item in response.json():
86
55
  result.append(deserialize(item, UserOutput))
87
56
  return result
88
57
 
89
- def get_user(self, user_id: str, agent_id: str | None = None) -> UserOutput:
58
+ def get_user(self, user_id: str, agent_id: str) -> UserOutput:
90
59
  """
91
60
  This endpoint is used to get a user in the system. The user is identified by the userId parameter, previously
92
61
  provided by the CheshireCat API when the user was created. The endpoint returns the username and the permissions
93
62
  of the user. The permissions are used to define the access rights of the user in the system and are defined by
94
63
  the system administrator.
95
- The endpoint can be used either for the agent identified by the agentId parameter (for multi-agent installations)
96
- or for the default agent (for single-agent installations).
64
+ The endpoint can be used for the agent identified by the agentId parameter.
97
65
  :param user_id: The id of the user to get
98
- :param agent_id: The id of the agent to get the user for (optional)
66
+ :param agent_id: The id of the agent to get the user for
99
67
  :return UserOutput, the user
100
68
  """
101
- return self.get(self.format_url(user_id), UserOutput, agent_id)
69
+ return self.get(self.format_url(user_id), agent_id, output_class=UserOutput)
102
70
 
103
71
  def put_user(
104
72
  self,
105
73
  user_id: str,
74
+ agent_id: str,
106
75
  username: str | None = None,
107
76
  password: str | None = None,
108
77
  permissions: Dict[str, Any] | None = None,
109
- agent_id: str | None = None
110
78
  ) -> UserOutput:
111
79
  """
112
80
  The endpoint is used to update the user in the system. The user is identified by the userId parameter, previously
113
81
  provided by the CheshireCat API when the user was created. The endpoint updates the username, the password, and
114
82
  the permissions of the user. The permissions are used to define the access rights of the user in the system and
115
83
  are defined by the system administrator.
116
- The endpoint can be used either for the agent identified by the agentId parameter (for multi-agent installations)
117
- or for the default agent (for single-agent installations).
84
+ The endpoint can be used for the agent identified by the agentId parameter.
118
85
  :param user_id: The id of the user to update
86
+ :param agent_id: The id of the agent to update the user for
119
87
  :param username: The new username of the user (optional)
120
88
  :param password: The new password of the user (optional)
121
89
  :param permissions: The new permissions of the user (optional)
122
- :param agent_id: The id of the agent to update the user for (optional)
123
90
  :return UserOutput, the updated user
124
91
  """
125
92
  payload = {}
@@ -130,16 +97,15 @@ class UsersEndpoint(AbstractEndpoint):
130
97
  if permissions is not None:
131
98
  payload["permissions"] = permissions
132
99
 
133
- return self.put(self.format_url(user_id), UserOutput, payload, agent_id)
100
+ return self.put(self.format_url(user_id), agent_id, output_class=UserOutput, payload=payload)
134
101
 
135
- def delete_user(self, user_id: str, agent_id: str | None = None) -> UserOutput:
102
+ def delete_user(self, user_id: str, agent_id: str) -> UserOutput:
136
103
  """
137
104
  This endpoint is used to delete the user in the system. The user is identified by the userId parameter, previously
138
105
  provided by the CheshireCat API when the user was created.
139
- The endpoint can be used either for the agent identified by the agentId parameter (for multi-agent installations)
140
- or for the default agent (for single-agent installations).
106
+ The endpoint can be used for the agent identified by the agentId parameter.
141
107
  :param user_id: The id of the user to delete
142
- :param agent_id: The id of the agent to delete the user for (optional)
108
+ :param agent_id: The id of the agent to delete the user for
143
109
  :return UserOutput, the deleted user
144
110
  """
145
- return self.delete(self.format_url(user_id), UserOutput, agent_id)
111
+ return self.delete(self.format_url(user_id), agent_id, output_class=UserOutput)
@@ -0,0 +1,71 @@
1
+ from typing import List
2
+
3
+ from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
+ from cheshirecat_python_sdk.models.api.admins import ResetOutput, ClonedOutput, CreatedOutput
5
+ from cheshirecat_python_sdk.utils import deserialize
6
+
7
+
8
+ class UtilsEndpoint(AbstractEndpoint):
9
+ def __init__(self, client: "CheshireCatClient"):
10
+ super().__init__(client)
11
+ self.prefix = "/utils"
12
+
13
+ def post_factory_reset(self) -> ResetOutput:
14
+ """
15
+ Reset the system to the factory settings.
16
+ :return: ResetOutput, the details of the reset.
17
+ """
18
+ return self.post_json(self.format_url("/factory/reset/"), self.system_id, output_class=ResetOutput)
19
+
20
+ def get_agents(self) -> List[str]:
21
+ """
22
+ Get a list of all agents.
23
+ :return: List[str], the IDs of the agents.
24
+ """
25
+ return self.get(self.format_url("/agents/"), self.system_id)
26
+
27
+ def post_agent_create(self, agent_id: str) -> CreatedOutput:
28
+ """
29
+ Create a new agent.
30
+ :param agent_id: The ID of the agent.
31
+ :return: CreatedOutput, the details of the agent.
32
+ """
33
+ response = self.get_http_client().post(
34
+ self.format_url("/agents/create/"),
35
+ json={
36
+ "agent_id": agent_id,
37
+ },
38
+ )
39
+ response.raise_for_status()
40
+
41
+ return deserialize(response.json(), CreatedOutput)
42
+
43
+ def post_agent_reset(self, agent_id: str) -> ResetOutput:
44
+ """
45
+ Reset an agent to the factory settings.
46
+ :param agent_id: The ID of the agent.
47
+ :return: ResetOutput, the details of the reset.
48
+ """
49
+ return self.post_json(self.format_url("/agents/reset/"), agent_id, output_class=ResetOutput)
50
+
51
+ def post_agent_destroy(self, agent_id: str) -> ResetOutput:
52
+ """
53
+ Destroy an agent.
54
+ :param agent_id: The ID of the agent.
55
+ :return: ResetOutput, the details of the reset.
56
+ """
57
+ return self.post_json(self.format_url("/agents/destroy/"), agent_id, output_class=ResetOutput)
58
+
59
+ def post_agent_clone(self, agent_id: str, new_agent_id: str) -> ClonedOutput:
60
+ """
61
+ Destroy an agent.
62
+ :param agent_id: The ID of the agent.
63
+ :param new_agent_id: The ID of the new cloned agent.
64
+ :return: ClonedOutput, the details of the cloning.
65
+ """
66
+ return self.post_json(
67
+ self.format_url("/agents/clone/"),
68
+ agent_id,
69
+ payload={"agent_id": new_agent_id},
70
+ output_class=ClonedOutput
71
+ )
@@ -0,0 +1,52 @@
1
+ from typing import Dict, Any
2
+
3
+ from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
4
+ from cheshirecat_python_sdk.models.api.factories import FactoryObjectSettingsOutput, FactoryObjectSettingOutput
5
+
6
+
7
+ class VectorDatabaseEndpoint(AbstractEndpoint):
8
+ def __init__(self, client: "CheshireCatClient"):
9
+ super().__init__(client)
10
+ self.prefix = "/vector_database"
11
+
12
+ def get_vector_databases_settings(self, agent_id: str) -> FactoryObjectSettingsOutput:
13
+ """
14
+ Get all vector databases settings for the agent specified by agent_id
15
+ :param agent_id: The agent id
16
+ :return: FactoryObjectSettingsOutput, a list of vector database settings
17
+ """
18
+ return self.get(
19
+ self.format_url("/settings"),
20
+ agent_id,
21
+ output_class=FactoryObjectSettingsOutput,
22
+ )
23
+
24
+ def get_vector_database_settings(self, vector_database: str, agent_id: str) -> FactoryObjectSettingOutput:
25
+ """
26
+ Get the vector database settings for the vector database specified by vector_database and agent_id
27
+ :param vector_database: The name of the vector database
28
+ :param agent_id: The agent id
29
+ :return: FactoryObjectSettingOutput, the vector database settings
30
+ """
31
+ return self.get(
32
+ self.format_url(f"/settings/{vector_database}"),
33
+ agent_id,
34
+ output_class=FactoryObjectSettingOutput,
35
+ )
36
+
37
+ def put_vector_database_settings(
38
+ self, vector_database: str, agent_id: str, values: Dict[str, Any]
39
+ ) -> FactoryObjectSettingOutput:
40
+ """
41
+ Update the vector database settings for the vector database specified by vector_database and agent_id
42
+ :param vector_database: The name of the vector database
43
+ :param agent_id: The agent id
44
+ :param values: The new settings
45
+ :return: FactoryObjectSettingOutput, the updated vector database settings
46
+ """
47
+ return self.put(
48
+ self.format_url(f"/settings/{vector_database}"),
49
+ agent_id,
50
+ output_class=FactoryObjectSettingOutput,
51
+ payload=values,
52
+ )
@@ -28,14 +28,3 @@ class Enum(BaseEnum, metaclass=MetaEnum):
28
28
 
29
29
  def __hash__(self):
30
30
  return hash(self.value)
31
-
32
-
33
- class Collection(str, Enum):
34
- DECLARATIVE = "declarative"
35
- PROCEDURAL = "procedural"
36
- EPISODIC = "episodic"
37
-
38
-
39
- class Role(str, Enum):
40
- AI = "AI"
41
- HUMAN = "Human"
@@ -36,3 +36,7 @@ class ResetOutput(BaseModel):
36
36
  deleted_settings: bool
37
37
  deleted_memories: bool
38
38
  deleted_plugin_folders: bool
39
+
40
+
41
+ class ClonedOutput(BaseModel):
42
+ cloned: bool = False
@@ -0,0 +1,24 @@
1
+ from typing import List
2
+ from pydantic import BaseModel
3
+
4
+ from cheshirecat_python_sdk.models.api.nested.memories import ConversationMessage
5
+
6
+
7
+ class ConversationDeleteOutput(BaseModel):
8
+ deleted: bool
9
+
10
+
11
+ class ConversationHistoryOutput(BaseModel):
12
+ history: List[ConversationMessage]
13
+
14
+
15
+ class ConversationsResponse(BaseModel):
16
+ chat_id: str
17
+ name: str
18
+ num_messages: int
19
+ created_at: float | None
20
+ updated_at: float | None
21
+
22
+
23
+ class ConversationNameChangeOutput(BaseModel):
24
+ changed: bool
@@ -7,6 +7,12 @@ class FactoryObjectSettingOutput(BaseModel):
7
7
  value: Dict[str, Any]
8
8
  scheme: Dict[str, Any] | None = None
9
9
 
10
+ def __init__(self, /, **data: Any) -> None:
11
+ # if tags is a list, convert it to a comma-separated string
12
+ if "scheme" in data and isinstance(data["scheme"], Dict) and not data["scheme"]:
13
+ data["scheme"] = None
14
+ super().__init__(**data)
15
+
10
16
 
11
17
  class FactoryObjectSettingsOutput(BaseModel):
12
18
  settings: List[FactoryObjectSettingOutput]
@@ -0,0 +1,18 @@
1
+ from typing import List
2
+ from pydantic import BaseModel
3
+
4
+
5
+ class FileResponse(BaseModel):
6
+ path: str
7
+ name: str
8
+ size: int
9
+ last_modified: str
10
+
11
+
12
+ class FileManagerAttributes(BaseModel):
13
+ files: List[FileResponse]
14
+ size: int
15
+
16
+
17
+ class FileManagerDeletedFiles(BaseModel):
18
+ deleted: bool
@@ -1,9 +1,8 @@
1
- from typing import Dict, List
1
+ from typing import Dict, List, Any
2
2
  from pydantic import BaseModel
3
3
 
4
4
  from cheshirecat_python_sdk.models.api.nested.memories import (
5
5
  CollectionsItem,
6
- ConversationHistoryItem,
7
6
  MemoryPointsDeleteByMetadataInfo,
8
7
  Record,
9
8
  MemoryRecallQuery,
@@ -19,13 +18,6 @@ class CollectionPointsDestroyOutput(BaseModel):
19
18
  class CollectionsOutput(BaseModel):
20
19
  collections: List[CollectionsItem]
21
20
 
22
- class ConversationHistoryDeleteOutput(BaseModel):
23
- deleted: bool
24
-
25
-
26
- class ConversationHistoryOutput(BaseModel):
27
- history: List[ConversationHistoryItem]
28
-
29
21
 
30
22
  class MemoryPointDeleteOutput(BaseModel):
31
23
  deleted: str
@@ -33,7 +25,7 @@ class MemoryPointDeleteOutput(BaseModel):
33
25
 
34
26
  class MemoryPointOutput(MemoryPoint):
35
27
  id: str
36
- vector: List[float]
28
+ vector: List[float] | List[List[float]] | Dict[str, Any]
37
29
 
38
30
 
39
31
  class MemoryPointsDeleteByMetadataOutput(BaseModel):
@@ -1,14 +1,16 @@
1
- from pydantic import Field
1
+ from pydantic import Field, BaseModel
2
2
 
3
3
  from cheshirecat_python_sdk.models.dtos import MessageBase, Why
4
4
 
5
5
 
6
6
  class MessageOutput(MessageBase):
7
- why: Why = Field(default_factory=Why) # Assuming Why has a no-args constructor
7
+ why: Why | None = Field(default_factory=Why) # Assuming Why has a no-args constructor
8
8
  type: str | None = "chat" # Default argument
9
9
  error: bool | None = False # Default argument
10
- content: str = Field(init=False) # Field without a default value
11
10
 
12
- def __init__(self, **data):
13
- super().__init__(**data)
14
- self.content = self.text
11
+
12
+ class ChatOutput(BaseModel):
13
+ agent_id: str
14
+ user_id: str
15
+ chat_id: str
16
+ message: MessageOutput
@@ -13,7 +13,7 @@ class ConversationHistoryItemContent(MessageBase):
13
13
  why: Why | None = None
14
14
 
15
15
 
16
- class ConversationHistoryItem(BaseModel):
16
+ class ConversationMessage(BaseModel):
17
17
  who: str
18
18
  when: float
19
19
  content: ConversationHistoryItemContent
@@ -26,7 +26,7 @@ class MemoryPointsDeleteByMetadataInfo(BaseModel):
26
26
 
27
27
  class MemoryRecallQuery(BaseModel):
28
28
  text: str
29
- vector: List[float]
29
+ vector: List[float] | List[List[float]] | Dict[str, Any]
30
30
 
31
31
 
32
32
  class MemoryRecallVectors(BaseModel):
@@ -37,6 +37,6 @@ class MemoryRecallVectors(BaseModel):
37
37
  class Record(BaseModel):
38
38
  id: str
39
39
  payload: Dict[str, Any] | None = None
40
- vector: List[float] | None = None
41
- shard_key: str | None = None
42
- order_value: float | None = None
40
+ vector: List[float] | List[List[float]] | Dict[str, Any] | None = None
41
+ shard_key: int | str | None = None
42
+ order_value: int | float | None = None
@@ -4,8 +4,8 @@ from pydantic import BaseModel
4
4
 
5
5
  class PropertySettingsOutput(BaseModel):
6
6
  default: Any
7
- title: str
8
- type: str
7
+ title: str | None = None
8
+ type: str | None = None
9
9
  extra: Dict[str, Any] | None = None
10
10
 
11
11
 
@@ -19,3 +19,9 @@ class PluginSettingsOutput(BaseModel):
19
19
  name: str
20
20
  value: Dict[str, Any]
21
21
  scheme: PluginSchemaSettings | None = None
22
+
23
+ def __init__(self, /, **data: Any) -> None:
24
+ # if tags is a list, convert it to a comma-separated string
25
+ if "scheme" in data and isinstance(data["scheme"], Dict) and not data["scheme"]:
26
+ data["scheme"] = None
27
+ super().__init__(**data)