cheshirecat-python-sdk 1.2.1__py3-none-any.whl → 1.8.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.
- cheshirecat_python_sdk/__init__.py +0 -1
- cheshirecat_python_sdk/builders/__init__.py +1 -1
- cheshirecat_python_sdk/builders/memory.py +1 -32
- cheshirecat_python_sdk/builders/why.py +8 -14
- cheshirecat_python_sdk/client.py +35 -5
- cheshirecat_python_sdk/clients/http_client.py +21 -7
- cheshirecat_python_sdk/clients/websocket_client.py +21 -15
- cheshirecat_python_sdk/configuration.py +1 -1
- cheshirecat_python_sdk/endpoints/__init__.py +7 -1
- cheshirecat_python_sdk/endpoints/admins.py +33 -145
- cheshirecat_python_sdk/endpoints/agentic_workflow.py +52 -0
- cheshirecat_python_sdk/endpoints/auth.py +54 -0
- cheshirecat_python_sdk/endpoints/auth_handler.py +8 -8
- cheshirecat_python_sdk/endpoints/base.py +53 -19
- cheshirecat_python_sdk/endpoints/chunker.py +8 -8
- cheshirecat_python_sdk/endpoints/conversation.py +83 -0
- cheshirecat_python_sdk/endpoints/custom_endpoint.py +57 -0
- cheshirecat_python_sdk/endpoints/embedder.py +4 -4
- cheshirecat_python_sdk/endpoints/file_manager.py +65 -8
- cheshirecat_python_sdk/endpoints/health_check.py +22 -0
- cheshirecat_python_sdk/endpoints/large_language_model.py +8 -8
- cheshirecat_python_sdk/endpoints/memory.py +101 -146
- cheshirecat_python_sdk/endpoints/message.py +29 -13
- cheshirecat_python_sdk/endpoints/plugins.py +31 -26
- cheshirecat_python_sdk/endpoints/rabbit_hole.py +53 -23
- cheshirecat_python_sdk/endpoints/users.py +35 -56
- cheshirecat_python_sdk/endpoints/utils.py +71 -0
- cheshirecat_python_sdk/endpoints/vector_database.py +52 -0
- cheshirecat_python_sdk/enums.py +0 -11
- cheshirecat_python_sdk/models/api/admins.py +5 -7
- cheshirecat_python_sdk/models/api/conversations.py +24 -0
- cheshirecat_python_sdk/models/api/factories.py +6 -0
- cheshirecat_python_sdk/models/api/file_managers.py +18 -0
- cheshirecat_python_sdk/models/api/memories.py +2 -10
- cheshirecat_python_sdk/models/api/messages.py +8 -6
- cheshirecat_python_sdk/models/api/nested/memories.py +5 -5
- cheshirecat_python_sdk/models/api/nested/plugins.py +8 -2
- cheshirecat_python_sdk/models/api/plugins.py +30 -22
- cheshirecat_python_sdk/models/api/tokens.py +19 -0
- cheshirecat_python_sdk/models/api/users.py +4 -1
- cheshirecat_python_sdk/models/dtos.py +14 -18
- cheshirecat_python_sdk/utils.py +2 -1
- {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.8.4.dist-info}/METADATA +12 -10
- cheshirecat_python_sdk-1.8.4.dist-info/RECORD +50 -0
- {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.8.4.dist-info}/WHEEL +1 -1
- cheshirecat_python_sdk/endpoints/settings.py +0 -63
- cheshirecat_python_sdk/models/api/settings.py +0 -22
- cheshirecat_python_sdk-1.2.1.dist-info/RECORD +0 -43
- {cheshirecat_python_sdk-1.2.1.dist-info → cheshirecat_python_sdk-1.8.4.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(
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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,35 @@ 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(
|
|
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
|
|
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(
|
|
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, chat_id: str | None = None) -> 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
|
+
:param chat_id: The chat id, optional
|
|
167
|
+
:return: List[str]
|
|
168
|
+
"""
|
|
169
|
+
return self.get(
|
|
170
|
+
self.format_url("/web"),
|
|
171
|
+
agent_id,
|
|
172
|
+
chat_id=chat_id,
|
|
173
|
+
)
|
|
@@ -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,24 @@ 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,
|
|
14
|
+
self,
|
|
15
|
+
agent_id: str,
|
|
16
|
+
username: str,
|
|
17
|
+
password: str,
|
|
18
|
+
permissions: dict[str, Any] | None = None,
|
|
19
|
+
metadata: dict[str, Any] | None = None,
|
|
44
20
|
) -> UserOutput:
|
|
45
21
|
"""
|
|
46
22
|
This endpoint is used to create a new user in the system. The user is created with the specified username and
|
|
47
23
|
password. The user is assigned the specified permissions. The permissions are used to define the access rights
|
|
48
24
|
of the user in the system and are defined by the system administrator.
|
|
49
|
-
The endpoint can be used
|
|
50
|
-
|
|
51
|
-
single-agent installations).
|
|
25
|
+
The endpoint can be used for the agent identified by the agentId parameter.
|
|
26
|
+
:param agent_id: The id of the agent to create the user for
|
|
52
27
|
:param username: The username of the user to create
|
|
53
28
|
:param password: The password of the user to create
|
|
54
29
|
:param permissions: The permissions of the user to create (optional)
|
|
55
|
-
:param
|
|
30
|
+
:param metadata: The metadata of the user to create (optional)
|
|
56
31
|
:return UserOutput, the created user
|
|
57
32
|
"""
|
|
58
33
|
payload = {
|
|
@@ -60,66 +35,69 @@ class UsersEndpoint(AbstractEndpoint):
|
|
|
60
35
|
"password": password,
|
|
61
36
|
}
|
|
62
37
|
if permissions is not None:
|
|
63
|
-
payload["permissions"] = permissions
|
|
38
|
+
payload["permissions"] = permissions # type: ignore
|
|
39
|
+
|
|
40
|
+
if metadata is not None:
|
|
41
|
+
payload["metadata"] = metadata # type: ignore
|
|
64
42
|
|
|
65
43
|
return self.post_json(
|
|
66
44
|
self.prefix,
|
|
67
|
-
UserOutput,
|
|
68
|
-
payload,
|
|
69
45
|
agent_id,
|
|
46
|
+
output_class=UserOutput,
|
|
47
|
+
payload=payload,
|
|
70
48
|
)
|
|
71
49
|
|
|
72
|
-
def get_users(self, agent_id: str
|
|
50
|
+
def get_users(self, agent_id: str) -> List[UserOutput]:
|
|
73
51
|
"""
|
|
74
52
|
This endpoint is used to get a list of users in the system. The list includes the username and the permissions of
|
|
75
53
|
each user. The permissions are used to define the access rights of the users in the system and are defined by the
|
|
76
54
|
system administrator.
|
|
77
|
-
The endpoint can be used
|
|
78
|
-
|
|
79
|
-
:param agent_id: The id of the agent to get users for (optional)
|
|
55
|
+
The endpoint can be used for the agent identified by the agentId parameter.
|
|
56
|
+
:param agent_id: The id of the agent to get users for
|
|
80
57
|
:return List[UserOutput], the users in the system with their permissions for the agent identified by agent_id
|
|
81
58
|
"""
|
|
82
59
|
response = self.get_http_client(agent_id).get(self.prefix)
|
|
60
|
+
response.raise_for_status()
|
|
83
61
|
|
|
84
62
|
result = []
|
|
85
63
|
for item in response.json():
|
|
86
64
|
result.append(deserialize(item, UserOutput))
|
|
87
65
|
return result
|
|
88
66
|
|
|
89
|
-
def get_user(self, user_id: str, agent_id: str
|
|
67
|
+
def get_user(self, user_id: str, agent_id: str) -> UserOutput:
|
|
90
68
|
"""
|
|
91
69
|
This endpoint is used to get a user in the system. The user is identified by the userId parameter, previously
|
|
92
70
|
provided by the CheshireCat API when the user was created. The endpoint returns the username and the permissions
|
|
93
71
|
of the user. The permissions are used to define the access rights of the user in the system and are defined by
|
|
94
72
|
the system administrator.
|
|
95
|
-
The endpoint can be used
|
|
96
|
-
or for the default agent (for single-agent installations).
|
|
73
|
+
The endpoint can be used for the agent identified by the agentId parameter.
|
|
97
74
|
:param user_id: The id of the user to get
|
|
98
|
-
:param agent_id: The id of the agent to get the user for
|
|
75
|
+
:param agent_id: The id of the agent to get the user for
|
|
99
76
|
:return UserOutput, the user
|
|
100
77
|
"""
|
|
101
|
-
return self.get(self.format_url(user_id),
|
|
78
|
+
return self.get(self.format_url(user_id), agent_id, output_class=UserOutput)
|
|
102
79
|
|
|
103
80
|
def put_user(
|
|
104
81
|
self,
|
|
105
82
|
user_id: str,
|
|
83
|
+
agent_id: str,
|
|
106
84
|
username: str | None = None,
|
|
107
85
|
password: str | None = None,
|
|
108
86
|
permissions: Dict[str, Any] | None = None,
|
|
109
|
-
|
|
87
|
+
metadata: Dict[str, Any] | None = None,
|
|
110
88
|
) -> UserOutput:
|
|
111
89
|
"""
|
|
112
90
|
The endpoint is used to update the user in the system. The user is identified by the userId parameter, previously
|
|
113
91
|
provided by the CheshireCat API when the user was created. The endpoint updates the username, the password, and
|
|
114
92
|
the permissions of the user. The permissions are used to define the access rights of the user in the system and
|
|
115
93
|
are defined by the system administrator.
|
|
116
|
-
The endpoint can be used
|
|
117
|
-
or for the default agent (for single-agent installations).
|
|
94
|
+
The endpoint can be used for the agent identified by the agentId parameter.
|
|
118
95
|
:param user_id: The id of the user to update
|
|
96
|
+
:param agent_id: The id of the agent to update the user for
|
|
119
97
|
:param username: The new username of the user (optional)
|
|
120
98
|
:param password: The new password of the user (optional)
|
|
121
99
|
:param permissions: The new permissions of the user (optional)
|
|
122
|
-
:param
|
|
100
|
+
:param metadata: The new metadata of the user (optional)
|
|
123
101
|
:return UserOutput, the updated user
|
|
124
102
|
"""
|
|
125
103
|
payload = {}
|
|
@@ -129,17 +107,18 @@ class UsersEndpoint(AbstractEndpoint):
|
|
|
129
107
|
payload["password"] = password
|
|
130
108
|
if permissions is not None:
|
|
131
109
|
payload["permissions"] = permissions
|
|
110
|
+
if metadata is not None:
|
|
111
|
+
payload["metadata"] = metadata
|
|
132
112
|
|
|
133
|
-
return self.put(self.format_url(user_id), UserOutput, payload
|
|
113
|
+
return self.put(self.format_url(user_id), agent_id, output_class=UserOutput, payload=payload)
|
|
134
114
|
|
|
135
|
-
def delete_user(self, user_id: str, agent_id: str
|
|
115
|
+
def delete_user(self, user_id: str, agent_id: str) -> UserOutput:
|
|
136
116
|
"""
|
|
137
117
|
This endpoint is used to delete the user in the system. The user is identified by the userId parameter, previously
|
|
138
118
|
provided by the CheshireCat API when the user was created.
|
|
139
|
-
The endpoint can be used
|
|
140
|
-
or for the default agent (for single-agent installations).
|
|
119
|
+
The endpoint can be used for the agent identified by the agentId parameter.
|
|
141
120
|
:param user_id: The id of the user to delete
|
|
142
|
-
:param agent_id: The id of the agent to delete the user for
|
|
121
|
+
:param agent_id: The id of the agent to delete the user for
|
|
143
122
|
:return UserOutput, the deleted user
|
|
144
123
|
"""
|
|
145
|
-
return self.delete(self.format_url(user_id),
|
|
124
|
+
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
|
+
)
|
cheshirecat_python_sdk/enums.py
CHANGED
|
@@ -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"
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
from typing import Dict,
|
|
1
|
+
from typing import Dict, Any
|
|
2
2
|
from pydantic import BaseModel
|
|
3
3
|
|
|
4
4
|
from cheshirecat_python_sdk.models.api.plugins import PluginToggleOutput
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class AdminOutput(BaseModel):
|
|
8
|
-
username: str
|
|
9
|
-
permissions: Dict[str, List[str]]
|
|
10
|
-
id: str
|
|
11
|
-
|
|
12
|
-
|
|
13
7
|
class CreatedOutput(BaseModel):
|
|
14
8
|
created: bool
|
|
15
9
|
|
|
@@ -36,3 +30,7 @@ class ResetOutput(BaseModel):
|
|
|
36
30
|
deleted_settings: bool
|
|
37
31
|
deleted_memories: bool
|
|
38
32
|
deleted_plugin_folders: bool
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ClonedOutput(BaseModel):
|
|
36
|
+
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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
|