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
|
@@ -9,7 +9,7 @@ class AuthHandlerEndpoint(AbstractEndpoint):
|
|
|
9
9
|
super().__init__(client)
|
|
10
10
|
self.prefix = "/auth_handler"
|
|
11
11
|
|
|
12
|
-
def get_auth_handlers_settings(self, agent_id: str
|
|
12
|
+
def get_auth_handlers_settings(self, agent_id: str) -> FactoryObjectSettingsOutput:
|
|
13
13
|
"""
|
|
14
14
|
Get all auth handler settings for the agent with the given ID.
|
|
15
15
|
:param agent_id: The ID of the agent.
|
|
@@ -17,11 +17,11 @@ class AuthHandlerEndpoint(AbstractEndpoint):
|
|
|
17
17
|
"""
|
|
18
18
|
return self.get(
|
|
19
19
|
self.format_url("/settings"),
|
|
20
|
-
FactoryObjectSettingsOutput,
|
|
21
20
|
agent_id,
|
|
21
|
+
output_class=FactoryObjectSettingsOutput,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
def get_auth_handler_settings(self, auth_handler: str, agent_id: str
|
|
24
|
+
def get_auth_handler_settings(self, auth_handler: str, agent_id: str) -> FactoryObjectSettingOutput:
|
|
25
25
|
"""
|
|
26
26
|
Get the settings for the auth handler with the given name.
|
|
27
27
|
:param auth_handler: The name of the auth handler.
|
|
@@ -30,23 +30,23 @@ class AuthHandlerEndpoint(AbstractEndpoint):
|
|
|
30
30
|
"""
|
|
31
31
|
return self.get(
|
|
32
32
|
self.format_url(f"/settings/{auth_handler}"),
|
|
33
|
-
FactoryObjectSettingOutput,
|
|
34
33
|
agent_id,
|
|
34
|
+
output_class=FactoryObjectSettingOutput,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def put_auth_handler_settings(
|
|
38
|
-
self, auth_handler: str, values: Dict[str, Any]
|
|
38
|
+
self, auth_handler: str, agent_id: str, values: Dict[str, Any]
|
|
39
39
|
) -> FactoryObjectSettingOutput:
|
|
40
40
|
"""
|
|
41
41
|
Update the settings for the auth handler with the given name.
|
|
42
42
|
:param auth_handler: The name of the auth handler.
|
|
43
|
-
:param values: The new settings for the auth handler.
|
|
44
43
|
:param agent_id: The ID of the agent.
|
|
44
|
+
:param values: The new settings for the auth handler.
|
|
45
45
|
:return: FactoryObjectSettingOutput, containing the updated settings for the auth handler.
|
|
46
46
|
"""
|
|
47
47
|
return self.put(
|
|
48
48
|
self.format_url(f"/settings/{auth_handler}"),
|
|
49
|
-
FactoryObjectSettingOutput,
|
|
50
|
-
values,
|
|
51
49
|
agent_id,
|
|
50
|
+
output_class=FactoryObjectSettingOutput,
|
|
51
|
+
payload=values,
|
|
52
52
|
)
|
|
@@ -2,6 +2,7 @@ from abc import ABC
|
|
|
2
2
|
from typing import Dict, Any, List, Tuple, Type
|
|
3
3
|
import requests
|
|
4
4
|
from pydantic import BaseModel
|
|
5
|
+
from requests_toolbelt.sessions import BaseUrlSession
|
|
5
6
|
from websockets import ClientConnection
|
|
6
7
|
|
|
7
8
|
from cheshirecat_python_sdk.utils import T, deserialize
|
|
@@ -21,25 +22,35 @@ class AbstractEndpoint(ABC):
|
|
|
21
22
|
def format_url(self, endpoint: str) -> str:
|
|
22
23
|
return f"/{self.prefix}/{endpoint}".replace("//", "/")
|
|
23
24
|
|
|
24
|
-
def get_http_client(
|
|
25
|
-
|
|
25
|
+
def get_http_client(
|
|
26
|
+
self,
|
|
27
|
+
agent_id: str | None = None,
|
|
28
|
+
user_id: str | None = None,
|
|
29
|
+
chat_id: str | None = None,
|
|
30
|
+
) -> requests.Session:
|
|
31
|
+
return self.client.http_client.get_client(agent_id, user_id, chat_id)
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
return
|
|
33
|
+
def get_http_session(self) -> BaseUrlSession:
|
|
34
|
+
return self.client.http_client.get_base_session()
|
|
35
|
+
|
|
36
|
+
async def get_ws_client(self, agent_id: str, user_id: str, chat_id: str | None = None) -> ClientConnection:
|
|
37
|
+
return await self.client.ws_client.get_client(agent_id, user_id, chat_id)
|
|
29
38
|
|
|
30
39
|
def get(
|
|
31
40
|
self,
|
|
32
41
|
endpoint: str,
|
|
42
|
+
agent_id: str,
|
|
33
43
|
output_class: Type[T] | None = None,
|
|
34
|
-
agent_id: str | None = None,
|
|
35
|
-
user_id: str | None = None,
|
|
36
44
|
query: Dict[str, Any] | None = None,
|
|
45
|
+
user_id: str | None = None,
|
|
46
|
+
chat_id: str | None = None,
|
|
37
47
|
) -> T:
|
|
38
48
|
options = {}
|
|
39
49
|
if query:
|
|
40
50
|
options["params"] = query
|
|
41
51
|
|
|
42
|
-
response = self.get_http_client(agent_id, user_id).get(endpoint, **options)
|
|
52
|
+
response = self.get_http_client(agent_id, user_id, chat_id).get(endpoint, **options)
|
|
53
|
+
response.raise_for_status()
|
|
43
54
|
|
|
44
55
|
if output_class is None:
|
|
45
56
|
return response.json()
|
|
@@ -48,24 +59,29 @@ class AbstractEndpoint(ABC):
|
|
|
48
59
|
def post_json(
|
|
49
60
|
self,
|
|
50
61
|
endpoint: str,
|
|
51
|
-
|
|
62
|
+
agent_id: str,
|
|
63
|
+
output_class: Type[T] | None = None,
|
|
52
64
|
payload: Dict[str, Any] | None = None,
|
|
53
|
-
agent_id: str | None = None,
|
|
54
65
|
user_id: str | None = None,
|
|
66
|
+
chat_id: str | None = None,
|
|
55
67
|
) -> T:
|
|
56
68
|
options = {}
|
|
57
69
|
if payload:
|
|
58
70
|
options["json"] = payload
|
|
59
71
|
|
|
60
|
-
response = self.get_http_client(agent_id, user_id).post(endpoint, **options)
|
|
72
|
+
response = self.get_http_client(agent_id, user_id, chat_id).post(endpoint, **options)
|
|
73
|
+
response.raise_for_status()
|
|
74
|
+
|
|
75
|
+
if output_class is None:
|
|
76
|
+
return response.json()
|
|
61
77
|
return deserialize(response.json(), output_class)
|
|
62
78
|
|
|
63
79
|
def post_multipart(
|
|
64
80
|
self,
|
|
65
81
|
endpoint: str,
|
|
66
|
-
|
|
82
|
+
agent_id: str,
|
|
83
|
+
output_class: Type[T] | None = None,
|
|
67
84
|
payload: MultipartPayload | None = None,
|
|
68
|
-
agent_id: str | None = None,
|
|
69
85
|
user_id: str | None = None,
|
|
70
86
|
) -> T:
|
|
71
87
|
options = {}
|
|
@@ -75,30 +91,48 @@ class AbstractEndpoint(ABC):
|
|
|
75
91
|
options["files"] = payload.files
|
|
76
92
|
|
|
77
93
|
response = self.get_http_client(agent_id, user_id).post(endpoint, **options)
|
|
94
|
+
response.raise_for_status()
|
|
95
|
+
|
|
96
|
+
if output_class is None:
|
|
97
|
+
return response.json()
|
|
78
98
|
return deserialize(response.json(), output_class)
|
|
79
99
|
|
|
80
100
|
def put(
|
|
81
101
|
self,
|
|
82
102
|
endpoint: str,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
agent_id: str,
|
|
104
|
+
output_class: Type[T] | None = None,
|
|
105
|
+
payload: Dict[str, Any] | None = None,
|
|
86
106
|
user_id: str | None = None,
|
|
107
|
+
chat_id: str | None = None,
|
|
87
108
|
) -> T:
|
|
88
|
-
|
|
109
|
+
options = {}
|
|
110
|
+
if payload:
|
|
111
|
+
options["json"] = payload
|
|
112
|
+
|
|
113
|
+
response = self.get_http_client(agent_id, user_id, chat_id).put(endpoint, **options)
|
|
114
|
+
response.raise_for_status()
|
|
115
|
+
|
|
116
|
+
if output_class is None:
|
|
117
|
+
return response.json()
|
|
89
118
|
return deserialize(response.json(), output_class)
|
|
90
119
|
|
|
91
120
|
def delete(
|
|
92
121
|
self,
|
|
93
122
|
endpoint: str,
|
|
94
|
-
|
|
95
|
-
|
|
123
|
+
agent_id: str,
|
|
124
|
+
output_class: Type[T] | None = None,
|
|
96
125
|
user_id: str | None = None,
|
|
126
|
+
chat_id: str | None = None,
|
|
97
127
|
payload: Dict[str, Any] | None = None,
|
|
98
128
|
) -> T:
|
|
99
129
|
options = {}
|
|
100
130
|
if payload:
|
|
101
131
|
options["json"] = payload
|
|
102
132
|
|
|
103
|
-
response = self.get_http_client(agent_id, user_id).delete(endpoint, **options)
|
|
133
|
+
response = self.get_http_client(agent_id, user_id, chat_id).delete(endpoint, **options)
|
|
134
|
+
response.raise_for_status()
|
|
135
|
+
|
|
136
|
+
if output_class is None:
|
|
137
|
+
return response.json()
|
|
104
138
|
return deserialize(response.json(), output_class)
|
|
@@ -9,7 +9,7 @@ class ChunkerEndpoint(AbstractEndpoint):
|
|
|
9
9
|
super().__init__(client)
|
|
10
10
|
self.prefix = "/chunking"
|
|
11
11
|
|
|
12
|
-
def get_chunkers_settings(self, agent_id: str
|
|
12
|
+
def get_chunkers_settings(self, agent_id: str) -> FactoryObjectSettingsOutput:
|
|
13
13
|
"""
|
|
14
14
|
Get all chunker settings for the agent specified by agent_id
|
|
15
15
|
:param agent_id: The agent id
|
|
@@ -17,11 +17,11 @@ class ChunkerEndpoint(AbstractEndpoint):
|
|
|
17
17
|
"""
|
|
18
18
|
return self.get(
|
|
19
19
|
self.format_url("/settings"),
|
|
20
|
-
FactoryObjectSettingsOutput,
|
|
21
20
|
agent_id,
|
|
21
|
+
output_class=FactoryObjectSettingsOutput,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
def get_chunker_settings(self, chunker: str, agent_id: str
|
|
24
|
+
def get_chunker_settings(self, chunker: str, agent_id: str) -> FactoryObjectSettingOutput:
|
|
25
25
|
"""
|
|
26
26
|
Get the chunker settings for the chunker specified by chunker and agent_id
|
|
27
27
|
:param chunker: The name of the chunker
|
|
@@ -30,23 +30,23 @@ class ChunkerEndpoint(AbstractEndpoint):
|
|
|
30
30
|
"""
|
|
31
31
|
return self.get(
|
|
32
32
|
self.format_url(f"/settings/{chunker}"),
|
|
33
|
-
FactoryObjectSettingOutput,
|
|
34
33
|
agent_id,
|
|
34
|
+
output_class=FactoryObjectSettingOutput,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def put_chunker_settings(
|
|
38
|
-
self, chunker: str, values: Dict[str, Any]
|
|
38
|
+
self, chunker: str, agent_id: str, values: Dict[str, Any]
|
|
39
39
|
) -> FactoryObjectSettingOutput:
|
|
40
40
|
"""
|
|
41
41
|
Update the chunker settings for the chunker specified by chunker and agent_id
|
|
42
42
|
:param chunker: The name of the chunker
|
|
43
|
-
:param values: The new settings
|
|
44
43
|
:param agent_id: The agent id
|
|
44
|
+
:param values: The new settings
|
|
45
45
|
:return: FactoryObjectSettingOutput, the updated chunker settings
|
|
46
46
|
"""
|
|
47
47
|
return self.put(
|
|
48
48
|
self.format_url(f"/settings/{chunker}"),
|
|
49
|
-
FactoryObjectSettingOutput,
|
|
50
|
-
values,
|
|
51
49
|
agent_id,
|
|
50
|
+
output_class=FactoryObjectSettingOutput,
|
|
51
|
+
payload=values,
|
|
52
52
|
)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
|
|
4
|
+
from cheshirecat_python_sdk.models.api.conversations import (
|
|
5
|
+
ConversationHistoryOutput,
|
|
6
|
+
ConversationDeleteOutput,
|
|
7
|
+
ConversationsResponse,
|
|
8
|
+
ConversationNameChangeOutput,
|
|
9
|
+
)
|
|
10
|
+
from cheshirecat_python_sdk.utils import deserialize
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ConversationEndpoint(AbstractEndpoint):
|
|
14
|
+
def __init__(self, client: "CheshireCatClient"):
|
|
15
|
+
super().__init__(client)
|
|
16
|
+
self.prefix = "/conversation"
|
|
17
|
+
|
|
18
|
+
def get_conversation_history(self, agent_id: str, user_id: str, chat_id: str) -> ConversationHistoryOutput:
|
|
19
|
+
"""
|
|
20
|
+
This endpoint returns the conversation history.
|
|
21
|
+
:param agent_id: The agent ID.
|
|
22
|
+
:param user_id: The user ID to filter the conversation history.
|
|
23
|
+
:param chat_id: The chat ID to filter the conversation history.
|
|
24
|
+
:return: ConversationHistoryOutput, a list of conversation history entries.
|
|
25
|
+
"""
|
|
26
|
+
return self.get(
|
|
27
|
+
self.format_url(chat_id),
|
|
28
|
+
agent_id,
|
|
29
|
+
user_id=user_id,
|
|
30
|
+
output_class=ConversationHistoryOutput,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def get_conversations(self, agent_id: str, user_id: str) -> List[ConversationsResponse]:
|
|
34
|
+
"""
|
|
35
|
+
This endpoint returns the attributes of the different conversations, given the `agent_id` and the `user_id`.
|
|
36
|
+
:param agent_id: The agent ID.
|
|
37
|
+
:param user_id: The user ID to filter the conversation history.
|
|
38
|
+
:return: List[ConversationsResponse], a list of conversation attributes.
|
|
39
|
+
"""
|
|
40
|
+
response = self.get_http_client(agent_id, user_id).get(self.prefix)
|
|
41
|
+
response.raise_for_status()
|
|
42
|
+
|
|
43
|
+
return [deserialize(item, ConversationsResponse) for item in response.json()]
|
|
44
|
+
|
|
45
|
+
def delete_conversation(self, agent_id: str, user_id: str, chat_id: str) -> ConversationDeleteOutput:
|
|
46
|
+
"""
|
|
47
|
+
This endpoint deletes the conversation.
|
|
48
|
+
:param agent_id: The agent ID.
|
|
49
|
+
:param user_id: The user ID to filter the conversation history.
|
|
50
|
+
:param chat_id: The chat ID to filter the conversation history.
|
|
51
|
+
:return: ConversationDeleteOutput, a message indicating whether the conversation was deleted.
|
|
52
|
+
"""
|
|
53
|
+
return self.delete(
|
|
54
|
+
self.format_url(chat_id),
|
|
55
|
+
agent_id,
|
|
56
|
+
output_class=ConversationDeleteOutput,
|
|
57
|
+
user_id=user_id,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def post_conversation_name(
|
|
61
|
+
self,
|
|
62
|
+
name: str,
|
|
63
|
+
agent_id: str,
|
|
64
|
+
user_id: str,
|
|
65
|
+
chat_id: str,
|
|
66
|
+
) -> ConversationNameChangeOutput:
|
|
67
|
+
"""
|
|
68
|
+
This endpoint creates a new element in the conversation history.
|
|
69
|
+
:param name: The new name to assign to the conversation
|
|
70
|
+
:param agent_id: The agent ID.
|
|
71
|
+
:param user_id: The user ID to filter the conversation history.
|
|
72
|
+
:param chat_id: The chat ID to filter the conversation history.
|
|
73
|
+
:return: ConversationNameChangeOutput, a message indicating whether the conversation name was changed.
|
|
74
|
+
"""
|
|
75
|
+
payload = {"name": name}
|
|
76
|
+
|
|
77
|
+
return self.post_json(
|
|
78
|
+
self.format_url(chat_id),
|
|
79
|
+
agent_id,
|
|
80
|
+
output_class=ConversationNameChangeOutput,
|
|
81
|
+
payload=payload,
|
|
82
|
+
user_id=user_id,
|
|
83
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CustomEndpoint(AbstractEndpoint):
|
|
7
|
+
def get_custom(
|
|
8
|
+
self, url: str, agent_id: str, user_id: str | None = None, query: Dict[str, Any] | None = None
|
|
9
|
+
) -> Any:
|
|
10
|
+
"""
|
|
11
|
+
This method is used to trigger a custom endpoint with GET method
|
|
12
|
+
:param url: The url of the custom endpoint to trigger
|
|
13
|
+
:param agent_id: The id of the agent to get settings for (optional)
|
|
14
|
+
:param user_id: The id of the user to get settings for (optional)
|
|
15
|
+
:param query: The query parameters to send to the custom endpoint (optional)
|
|
16
|
+
:return Any, the response from the custom endpoint
|
|
17
|
+
"""
|
|
18
|
+
return self.get(url, agent_id, user_id=user_id, query=query)
|
|
19
|
+
|
|
20
|
+
def post_custom(
|
|
21
|
+
self, url: str, agent_id: str, payload: Dict[str, Any] | None = None, user_id: str | None = None
|
|
22
|
+
) -> Any:
|
|
23
|
+
"""
|
|
24
|
+
This method is used to trigger a custom endpoint with POST method
|
|
25
|
+
:param url: The url of the custom endpoint to trigger
|
|
26
|
+
:param agent_id: The id of the agent to get settings for (optional)
|
|
27
|
+
:param payload: The payload to send to the custom endpoint (optional)
|
|
28
|
+
:param user_id: The id of the user to get settings for (optional)
|
|
29
|
+
:return Any, the response from the custom endpoint
|
|
30
|
+
"""
|
|
31
|
+
return self.post_json(url, agent_id, payload=payload, user_id=user_id)
|
|
32
|
+
|
|
33
|
+
def put_custom(
|
|
34
|
+
self, url: str, agent_id: str, payload: Dict[str, Any] | None = None, user_id: str | None = None
|
|
35
|
+
) -> Any:
|
|
36
|
+
"""
|
|
37
|
+
The method is used to trigger a custom endpoint with PUT method
|
|
38
|
+
:param url: The url of the custom endpoint to trigger
|
|
39
|
+
:param agent_id: The id of the agent to get settings for (optional)
|
|
40
|
+
:param payload: The payload to send to the custom endpoint (optional)
|
|
41
|
+
:param user_id: The id of the user to get settings for (optional)
|
|
42
|
+
:return Any, the response from the custom endpoint
|
|
43
|
+
"""
|
|
44
|
+
return self.put(url, agent_id, payload=payload, user_id=user_id)
|
|
45
|
+
|
|
46
|
+
def delete_custom(
|
|
47
|
+
self, url: str, agent_id: str, payload: Dict[str, Any] | None = None, user_id: str | None = None
|
|
48
|
+
) -> Any:
|
|
49
|
+
"""
|
|
50
|
+
This method is used to trigger a custom endpoint with DELETE method
|
|
51
|
+
:param url: The url of the custom endpoint to trigger
|
|
52
|
+
:param agent_id: The id of the agent to get settings for (optional)
|
|
53
|
+
:param payload: The payload to send to the custom endpoint (optional)
|
|
54
|
+
:param user_id: The id of the user to get settings for (optional)
|
|
55
|
+
:return Any, the response from the custom endpoint
|
|
56
|
+
"""
|
|
57
|
+
return self.delete(url, agent_id, payload=payload, user_id=user_id)
|
|
@@ -16,8 +16,8 @@ class EmbedderEndpoint(AbstractEndpoint):
|
|
|
16
16
|
"""
|
|
17
17
|
return self.get(
|
|
18
18
|
self.format_url("/settings"),
|
|
19
|
-
FactoryObjectSettingsOutput,
|
|
20
19
|
self.system_id,
|
|
20
|
+
output_class=FactoryObjectSettingsOutput,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
def get_embedder_settings(self, embedder: str) -> FactoryObjectSettingOutput:
|
|
@@ -28,8 +28,8 @@ class EmbedderEndpoint(AbstractEndpoint):
|
|
|
28
28
|
"""
|
|
29
29
|
return self.get(
|
|
30
30
|
self.format_url(f"/settings/{embedder}"),
|
|
31
|
-
FactoryObjectSettingOutput,
|
|
32
31
|
self.system_id,
|
|
32
|
+
output_class=FactoryObjectSettingOutput,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
def put_embedder_settings(self, embedder: str, values: Dict[str, Any]) -> FactoryObjectSettingOutput:
|
|
@@ -41,7 +41,7 @@ class EmbedderEndpoint(AbstractEndpoint):
|
|
|
41
41
|
"""
|
|
42
42
|
return self.put(
|
|
43
43
|
self.format_url(f"/settings/{embedder}"),
|
|
44
|
-
FactoryObjectSettingOutput,
|
|
45
|
-
values,
|
|
46
44
|
self.system_id,
|
|
45
|
+
output_class=FactoryObjectSettingOutput,
|
|
46
|
+
payload=values,
|
|
47
47
|
)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from typing import Dict, Any
|
|
2
|
+
from requests import Response
|
|
2
3
|
|
|
3
4
|
from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
|
|
4
5
|
from cheshirecat_python_sdk.models.api.factories import FactoryObjectSettingOutput, FactoryObjectSettingsOutput
|
|
6
|
+
from cheshirecat_python_sdk.models.api.file_managers import FileManagerAttributes, FileManagerDeletedFiles
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
class FileManagerEndpoint(AbstractEndpoint):
|
|
@@ -9,7 +11,7 @@ class FileManagerEndpoint(AbstractEndpoint):
|
|
|
9
11
|
super().__init__(client)
|
|
10
12
|
self.prefix = "/file_manager"
|
|
11
13
|
|
|
12
|
-
def get_file_managers_settings(self, agent_id: str
|
|
14
|
+
def get_file_managers_settings(self, agent_id: str) -> FactoryObjectSettingsOutput:
|
|
13
15
|
"""
|
|
14
16
|
Get all file managers settings for the agent specified by agent_id
|
|
15
17
|
:param agent_id: The agent id
|
|
@@ -17,11 +19,11 @@ class FileManagerEndpoint(AbstractEndpoint):
|
|
|
17
19
|
"""
|
|
18
20
|
return self.get(
|
|
19
21
|
self.format_url("/settings"),
|
|
20
|
-
FactoryObjectSettingsOutput,
|
|
21
22
|
agent_id,
|
|
23
|
+
output_class=FactoryObjectSettingsOutput,
|
|
22
24
|
)
|
|
23
25
|
|
|
24
|
-
def get_file_manager_settings(self, file_manager: str, agent_id: str
|
|
26
|
+
def get_file_manager_settings(self, file_manager: str, agent_id: str) -> FactoryObjectSettingOutput:
|
|
25
27
|
"""
|
|
26
28
|
Get the settings of a file manager by name for the agent specified by agent_id
|
|
27
29
|
:param file_manager: str, the name of the file manager
|
|
@@ -30,23 +32,78 @@ class FileManagerEndpoint(AbstractEndpoint):
|
|
|
30
32
|
"""
|
|
31
33
|
return self.get(
|
|
32
34
|
self.format_url(f"/settings/{file_manager}"),
|
|
33
|
-
FactoryObjectSettingOutput,
|
|
34
35
|
agent_id,
|
|
36
|
+
output_class=FactoryObjectSettingOutput,
|
|
35
37
|
)
|
|
36
38
|
|
|
37
39
|
def put_file_manager_settings(
|
|
38
|
-
self, file_manager: str, values: Dict[str, Any]
|
|
40
|
+
self, file_manager: str, agent_id: str, values: Dict[str, Any]
|
|
39
41
|
) -> FactoryObjectSettingOutput:
|
|
40
42
|
"""
|
|
41
43
|
Update the settings of a file manager by name with the given values, for the agent specified by agent_id
|
|
42
44
|
:param file_manager: str, the name of the file manager
|
|
43
|
-
:param values: Dict[str, Any], the values to update
|
|
44
45
|
:param agent_id: The agent id
|
|
46
|
+
:param values: Dict[str, Any], the values to update
|
|
45
47
|
:return: FactoryObjectSettingOutput, the updated settings of the file manager
|
|
46
48
|
"""
|
|
47
49
|
return self.put(
|
|
48
50
|
self.format_url(f"/settings/{file_manager}"),
|
|
49
|
-
FactoryObjectSettingOutput,
|
|
50
|
-
values,
|
|
51
51
|
agent_id,
|
|
52
|
+
output_class=FactoryObjectSettingOutput,
|
|
53
|
+
payload=values,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def get_file_manager_attributes(self, agent_id: str, chat_id: str | None = None) -> FileManagerAttributes:
|
|
57
|
+
"""
|
|
58
|
+
Get the attributes of the file manager for the agent specified by agent_id
|
|
59
|
+
:param agent_id: The agent id
|
|
60
|
+
:param chat_id: The chat id, optional
|
|
61
|
+
:return: FileManagerAttributes, the attributes of the file manager
|
|
62
|
+
"""
|
|
63
|
+
return self.get(self.prefix, agent_id, output_class=FileManagerAttributes, chat_id=chat_id)
|
|
64
|
+
|
|
65
|
+
def get_file(self, agent_id: str, file_name: str, chat_id: str | None = None) -> Response:
|
|
66
|
+
"""
|
|
67
|
+
Download a file from the file manager for the agent specified by agent_id
|
|
68
|
+
:param agent_id: The agent id
|
|
69
|
+
:param file_name: The name of the file to download
|
|
70
|
+
:param chat_id: The chat id, optional
|
|
71
|
+
:return: Response, the response containing the file content
|
|
72
|
+
"""
|
|
73
|
+
response = self.get_http_client(agent_id, chat_id=chat_id).get(
|
|
74
|
+
self.format_url(f"/files/{file_name}"),
|
|
75
|
+
stream=True,
|
|
76
|
+
headers={"Accept": "application/octet-stream"}
|
|
77
|
+
)
|
|
78
|
+
response.raise_for_status()
|
|
79
|
+
|
|
80
|
+
return response
|
|
81
|
+
|
|
82
|
+
def delete_file(self, agent_id: str, file_name: str, chat_id: str | None = None) -> FileManagerDeletedFiles:
|
|
83
|
+
"""
|
|
84
|
+
Download a file from the file manager for the agent specified by agent_id
|
|
85
|
+
:param agent_id: The agent id
|
|
86
|
+
:param file_name: The name of the file to delete
|
|
87
|
+
:param chat_id: The chat id, optional
|
|
88
|
+
:return: FileManagerDeletedFiles, the response containing info about the deleted file
|
|
89
|
+
"""
|
|
90
|
+
return self.delete(
|
|
91
|
+
self.format_url(f"/files/{file_name}"),
|
|
92
|
+
agent_id,
|
|
93
|
+
output_class=FileManagerDeletedFiles,
|
|
94
|
+
chat_id=chat_id,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def delete_files(self, agent_id: str, chat_id: str | None = None) -> FileManagerDeletedFiles:
|
|
98
|
+
"""
|
|
99
|
+
Download a file from the file manager for the agent specified by agent_id
|
|
100
|
+
:param agent_id: The agent id
|
|
101
|
+
:param chat_id: The chat id, optional
|
|
102
|
+
:return: bool, True if all files were deleted successfully
|
|
103
|
+
"""
|
|
104
|
+
return self.delete(
|
|
105
|
+
self.format_url("/files"),
|
|
106
|
+
agent_id,
|
|
107
|
+
output_class=FileManagerDeletedFiles,
|
|
108
|
+
chat_id=chat_id,
|
|
52
109
|
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from cheshirecat_python_sdk.endpoints.base import AbstractEndpoint
|
|
2
|
+
|
|
3
|
+
class HealthCheckEndpoint(AbstractEndpoint):
|
|
4
|
+
def liveness(self):
|
|
5
|
+
"""
|
|
6
|
+
This endpoint is used to check if the server is running.
|
|
7
|
+
:return: dict, the status of the server.
|
|
8
|
+
"""
|
|
9
|
+
response = self.get_http_session().get("/health/liveness")
|
|
10
|
+
response.raise_for_status()
|
|
11
|
+
|
|
12
|
+
return response.json()
|
|
13
|
+
|
|
14
|
+
def readiness(self):
|
|
15
|
+
"""
|
|
16
|
+
This endpoint is used to check if the server is running.
|
|
17
|
+
:return: dict, the status of the server.
|
|
18
|
+
"""
|
|
19
|
+
response = self.get_http_session().get("/health/readiness")
|
|
20
|
+
response.raise_for_status()
|
|
21
|
+
|
|
22
|
+
return response.json()
|
|
@@ -9,7 +9,7 @@ class LargeLanguageModelEndpoint(AbstractEndpoint):
|
|
|
9
9
|
super().__init__(client)
|
|
10
10
|
self.prefix = "/llm"
|
|
11
11
|
|
|
12
|
-
def get_large_language_models_settings(self, agent_id: str
|
|
12
|
+
def get_large_language_models_settings(self, agent_id: str) -> FactoryObjectSettingsOutput:
|
|
13
13
|
"""
|
|
14
14
|
Get all large language model settings for the agent specified by agent_id
|
|
15
15
|
:param agent_id: The agent id
|
|
@@ -17,11 +17,11 @@ class LargeLanguageModelEndpoint(AbstractEndpoint):
|
|
|
17
17
|
"""
|
|
18
18
|
return self.get(
|
|
19
19
|
self.format_url("/settings"),
|
|
20
|
-
FactoryObjectSettingsOutput,
|
|
21
20
|
agent_id,
|
|
21
|
+
output_class=FactoryObjectSettingsOutput,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
def get_large_language_model_settings(self, llm: str, agent_id: str
|
|
24
|
+
def get_large_language_model_settings(self, llm: str, agent_id: str) -> FactoryObjectSettingOutput:
|
|
25
25
|
"""
|
|
26
26
|
Get the large language model settings for the large language model specified by llm and agent_id
|
|
27
27
|
:param llm: The name of the large language model
|
|
@@ -30,23 +30,23 @@ class LargeLanguageModelEndpoint(AbstractEndpoint):
|
|
|
30
30
|
"""
|
|
31
31
|
return self.get(
|
|
32
32
|
self.format_url(f"/settings/{llm}"),
|
|
33
|
-
FactoryObjectSettingOutput,
|
|
34
33
|
agent_id,
|
|
34
|
+
output_class=FactoryObjectSettingOutput,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def put_large_language_model_settings(
|
|
38
|
-
self, llm: str, values: Dict[str, Any]
|
|
38
|
+
self, llm: str, agent_id: str, values: Dict[str, Any]
|
|
39
39
|
) -> FactoryObjectSettingOutput:
|
|
40
40
|
"""
|
|
41
41
|
Update the large language model settings for the large language model specified by llm and agent_id
|
|
42
42
|
:param llm: The name of the large language model
|
|
43
|
-
:param values: The new settings
|
|
44
43
|
:param agent_id: The agent id
|
|
44
|
+
:param values: The new settings
|
|
45
45
|
:return: FactoryObjectSettingOutput, the updated large language model settings
|
|
46
46
|
"""
|
|
47
47
|
return self.put(
|
|
48
48
|
self.format_url(f"/settings/{llm}"),
|
|
49
|
-
FactoryObjectSettingOutput,
|
|
50
|
-
values,
|
|
51
49
|
agent_id,
|
|
50
|
+
output_class=FactoryObjectSettingOutput,
|
|
51
|
+
payload=values,
|
|
52
52
|
)
|