jl-ecms-client 0.2.8__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.

Potentially problematic release.


This version of jl-ecms-client might be problematic. Click here for more details.

Files changed (53) hide show
  1. jl_ecms_client-0.2.8.dist-info/METADATA +295 -0
  2. jl_ecms_client-0.2.8.dist-info/RECORD +53 -0
  3. jl_ecms_client-0.2.8.dist-info/WHEEL +5 -0
  4. jl_ecms_client-0.2.8.dist-info/licenses/LICENSE +190 -0
  5. jl_ecms_client-0.2.8.dist-info/top_level.txt +1 -0
  6. mirix/client/__init__.py +14 -0
  7. mirix/client/client.py +405 -0
  8. mirix/client/constants.py +60 -0
  9. mirix/client/remote_client.py +1136 -0
  10. mirix/client/utils.py +34 -0
  11. mirix/helpers/__init__.py +1 -0
  12. mirix/helpers/converters.py +429 -0
  13. mirix/helpers/datetime_helpers.py +90 -0
  14. mirix/helpers/json_helpers.py +47 -0
  15. mirix/helpers/message_helpers.py +74 -0
  16. mirix/helpers/tool_rule_solver.py +166 -0
  17. mirix/schemas/__init__.py +1 -0
  18. mirix/schemas/agent.py +401 -0
  19. mirix/schemas/block.py +188 -0
  20. mirix/schemas/cloud_file_mapping.py +29 -0
  21. mirix/schemas/embedding_config.py +114 -0
  22. mirix/schemas/enums.py +69 -0
  23. mirix/schemas/environment_variables.py +82 -0
  24. mirix/schemas/episodic_memory.py +170 -0
  25. mirix/schemas/file.py +57 -0
  26. mirix/schemas/health.py +10 -0
  27. mirix/schemas/knowledge_vault.py +181 -0
  28. mirix/schemas/llm_config.py +187 -0
  29. mirix/schemas/memory.py +318 -0
  30. mirix/schemas/message.py +1315 -0
  31. mirix/schemas/mirix_base.py +107 -0
  32. mirix/schemas/mirix_message.py +411 -0
  33. mirix/schemas/mirix_message_content.py +230 -0
  34. mirix/schemas/mirix_request.py +39 -0
  35. mirix/schemas/mirix_response.py +183 -0
  36. mirix/schemas/openai/__init__.py +1 -0
  37. mirix/schemas/openai/chat_completion_request.py +122 -0
  38. mirix/schemas/openai/chat_completion_response.py +144 -0
  39. mirix/schemas/openai/chat_completions.py +127 -0
  40. mirix/schemas/openai/embedding_response.py +11 -0
  41. mirix/schemas/openai/openai.py +229 -0
  42. mirix/schemas/organization.py +38 -0
  43. mirix/schemas/procedural_memory.py +151 -0
  44. mirix/schemas/providers.py +816 -0
  45. mirix/schemas/resource_memory.py +134 -0
  46. mirix/schemas/sandbox_config.py +132 -0
  47. mirix/schemas/semantic_memory.py +162 -0
  48. mirix/schemas/source.py +96 -0
  49. mirix/schemas/step.py +53 -0
  50. mirix/schemas/tool.py +241 -0
  51. mirix/schemas/tool_rule.py +209 -0
  52. mirix/schemas/usage.py +31 -0
  53. mirix/schemas/user.py +67 -0
mirix/client/client.py ADDED
@@ -0,0 +1,405 @@
1
+ import base64
2
+ import hashlib
3
+ import logging
4
+ import os
5
+ import shutil
6
+ from pathlib import Path
7
+ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
8
+ from urllib.parse import urlparse
9
+
10
+ import requests
11
+
12
+ if TYPE_CHECKING:
13
+ try:
14
+ from composio import ActionType
15
+ except ImportError:
16
+ ActionType = Any # type: ignore
17
+ try:
18
+ from crewai_tools import BaseTool as CrewAIBaseTool
19
+ except ImportError:
20
+ CrewAIBaseTool = Any # type: ignore
21
+ try:
22
+ from langchain_core.tools import BaseTool as LangChainBaseTool
23
+ except ImportError:
24
+ LangChainBaseTool = Any # type: ignore
25
+ from mirix.client.constants import FUNCTION_RETURN_CHAR_LIMIT
26
+ from mirix.schemas.agent import AgentState, AgentType, CreateAgent, CreateMetaAgent
27
+ from mirix.schemas.block import Block, BlockUpdate, CreateBlock, Human, Persona
28
+ from mirix.schemas.embedding_config import EmbeddingConfig
29
+
30
+ # new schemas
31
+ from mirix.schemas.enums import MessageRole
32
+ from mirix.schemas.environment_variables import (
33
+ SandboxEnvironmentVariable,
34
+ SandboxEnvironmentVariableCreate,
35
+ SandboxEnvironmentVariableUpdate,
36
+ )
37
+ from mirix.schemas.file import FileMetadata
38
+ from mirix.schemas.file import FileMetadata as PydanticFileMetadata
39
+ from mirix.schemas.llm_config import LLMConfig
40
+ from mirix.schemas.memory import ArchivalMemorySummary, Memory, RecallMemorySummary
41
+ from mirix.schemas.message import Message, MessageCreate
42
+ from mirix.schemas.mirix_message_content import (
43
+ CloudFileContent,
44
+ FileContent,
45
+ ImageContent,
46
+ MessageContentType,
47
+ TextContent,
48
+ )
49
+ from mirix.schemas.mirix_response import MirixResponse
50
+ from mirix.schemas.organization import Organization
51
+ from mirix.schemas.sandbox_config import (
52
+ E2BSandboxConfig,
53
+ LocalSandboxConfig,
54
+ SandboxConfig,
55
+ SandboxConfigCreate,
56
+ SandboxConfigUpdate,
57
+ )
58
+ from mirix.schemas.tool import Tool, ToolCreate, ToolUpdate
59
+ from mirix.schemas.tool_rule import BaseToolRule
60
+ from mirix.schemas.user import User as PydanticUser
61
+ from mirix.schemas.user import UserCreate
62
+
63
+
64
+ class AbstractClient(object):
65
+ def __init__(
66
+ self,
67
+ debug: bool = False,
68
+ ):
69
+ self.debug = debug
70
+
71
+ def agent_exists(
72
+ self, agent_id: Optional[str] = None, agent_name: Optional[str] = None
73
+ ) -> bool:
74
+ raise NotImplementedError
75
+
76
+ def create_agent(
77
+ self,
78
+ name: Optional[str] = None,
79
+ agent_type: Optional[AgentType] = AgentType.chat_agent,
80
+ embedding_config: Optional[EmbeddingConfig] = None,
81
+ llm_config: Optional[LLMConfig] = None,
82
+ memory: Optional[Memory] = None,
83
+ block_ids: Optional[List[str]] = None,
84
+ system: Optional[str] = None,
85
+ tool_ids: Optional[List[str]] = None,
86
+ tool_rules: Optional[List[BaseToolRule]] = None,
87
+ include_base_tools: Optional[bool] = True,
88
+ include_meta_memory_tools: Optional[bool] = False,
89
+ metadata: Optional[Dict] = None,
90
+ description: Optional[str] = None,
91
+ initial_message_sequence: Optional[List[Message]] = None,
92
+ tags: Optional[List[str]] = None,
93
+ ) -> AgentState:
94
+ raise NotImplementedError
95
+
96
+ def update_agent(
97
+ self,
98
+ agent_id: str,
99
+ name: Optional[str] = None,
100
+ description: Optional[str] = None,
101
+ system: Optional[str] = None,
102
+ tool_ids: Optional[List[str]] = None,
103
+ metadata: Optional[Dict] = None,
104
+ llm_config: Optional[LLMConfig] = None,
105
+ embedding_config: Optional[EmbeddingConfig] = None,
106
+ message_ids: Optional[List[str]] = None,
107
+ memory: Optional[Memory] = None,
108
+ tags: Optional[List[str]] = None,
109
+ ):
110
+ raise NotImplementedError
111
+
112
+ def get_tools_from_agent(self, agent_id: str):
113
+ raise NotImplementedError
114
+
115
+ def add_tool_to_agent(self, agent_id: str, tool_id: str):
116
+ raise NotImplementedError
117
+
118
+ def remove_tool_from_agent(self, agent_id: str, tool_id: str):
119
+ raise NotImplementedError
120
+
121
+ def rename_agent(self, agent_id: str, new_name: str):
122
+ raise NotImplementedError
123
+
124
+ def delete_agent(self, agent_id: str):
125
+ raise NotImplementedError
126
+
127
+ def get_agent(self, agent_id: str) -> AgentState:
128
+ raise NotImplementedError
129
+
130
+ def get_agent_id(self, agent_name: str) -> AgentState:
131
+ raise NotImplementedError
132
+
133
+ def get_in_context_memory(self, agent_id: str) -> Memory:
134
+ raise NotImplementedError
135
+
136
+ def update_in_context_memory(
137
+ self, agent_id: str, section: str, value: Union[List[str], str]
138
+ ) -> Memory:
139
+ raise NotImplementedError
140
+
141
+ def get_archival_memory_summary(self, agent_id: str) -> ArchivalMemorySummary:
142
+ raise NotImplementedError
143
+
144
+ def get_recall_memory_summary(self, agent_id: str) -> RecallMemorySummary:
145
+ raise NotImplementedError
146
+
147
+ def get_in_context_messages(self, agent_id: str) -> List[Message]:
148
+ raise NotImplementedError
149
+
150
+ def send_message(
151
+ self,
152
+ message: str,
153
+ role: str,
154
+ agent_id: Optional[str] = None,
155
+ agent_name: Optional[str] = None,
156
+ name: Optional[str] = None,
157
+ stream_steps: bool = False,
158
+ stream_tokens: bool = False,
159
+ chaining: Optional[bool] = None,
160
+ verbose: Optional[bool] = None,
161
+ ) -> MirixResponse:
162
+ raise NotImplementedError
163
+
164
+ def user_message(self, agent_id: str, message: str) -> MirixResponse:
165
+ raise NotImplementedError
166
+
167
+ def create_human(self, name: str, text: str) -> Human:
168
+ raise NotImplementedError
169
+
170
+ def create_persona(self, name: str, text: str) -> Persona:
171
+ raise NotImplementedError
172
+
173
+ def list_humans(self) -> List[Human]:
174
+ raise NotImplementedError
175
+
176
+ def list_personas(self) -> List[Persona]:
177
+ raise NotImplementedError
178
+
179
+ def update_human(self, human_id: str, text: str) -> Human:
180
+ raise NotImplementedError
181
+
182
+ def update_persona(self, persona_id: str, text: str) -> Persona:
183
+ raise NotImplementedError
184
+
185
+ def get_persona(self, id: str) -> Persona:
186
+ raise NotImplementedError
187
+
188
+ def get_human(self, id: str) -> Human:
189
+ raise NotImplementedError
190
+
191
+ def get_persona_id(self, name: str) -> str:
192
+ raise NotImplementedError
193
+
194
+ def get_human_id(self, name: str) -> str:
195
+ raise NotImplementedError
196
+
197
+ def delete_persona(self, id: str):
198
+ raise NotImplementedError
199
+
200
+ def delete_human(self, id: str):
201
+ raise NotImplementedError
202
+
203
+ def load_langchain_tool(
204
+ self,
205
+ langchain_tool: "LangChainBaseTool",
206
+ additional_imports_module_attr_map: dict[str, str] = None,
207
+ ) -> Tool:
208
+ raise NotImplementedError
209
+
210
+ def load_composio_tool(self, action: "ActionType") -> Tool:
211
+ raise NotImplementedError
212
+
213
+ def create_tool(
214
+ self,
215
+ func,
216
+ name: Optional[str] = None,
217
+ tags: Optional[List[str]] = None,
218
+ return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
219
+ ) -> Tool:
220
+ raise NotImplementedError
221
+
222
+ def create_or_update_tool(
223
+ self,
224
+ func,
225
+ name: Optional[str] = None,
226
+ tags: Optional[List[str]] = None,
227
+ return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
228
+ ) -> Tool:
229
+ raise NotImplementedError
230
+
231
+ def update_tool(
232
+ self,
233
+ id: str,
234
+ name: Optional[str] = None,
235
+ description: Optional[str] = None,
236
+ func: Optional[Callable] = None,
237
+ tags: Optional[List[str]] = None,
238
+ return_char_limit: int = FUNCTION_RETURN_CHAR_LIMIT,
239
+ ) -> Tool:
240
+ raise NotImplementedError
241
+
242
+ def list_tools(
243
+ self, cursor: Optional[str] = None, limit: Optional[int] = 50
244
+ ) -> List[Tool]:
245
+ raise NotImplementedError
246
+
247
+ def get_tool(self, id: str) -> Tool:
248
+ raise NotImplementedError
249
+
250
+ def delete_tool(self, id: str):
251
+ raise NotImplementedError
252
+
253
+ def get_tool_id(self, name: str) -> Optional[str]:
254
+ raise NotImplementedError
255
+
256
+ def upsert_base_tools(self) -> List[Tool]:
257
+ raise NotImplementedError
258
+
259
+ def get_messages(
260
+ self,
261
+ agent_id: str,
262
+ before: Optional[str] = None,
263
+ after: Optional[str] = None,
264
+ limit: Optional[int] = 1000,
265
+ ) -> List[Message]:
266
+ raise NotImplementedError
267
+
268
+ def list_model_configs(self) -> List[LLMConfig]:
269
+ raise NotImplementedError
270
+
271
+ def list_embedding_configs(self) -> List[EmbeddingConfig]:
272
+ raise NotImplementedError
273
+
274
+ def create_org(self, name: Optional[str] = None) -> Organization:
275
+ raise NotImplementedError
276
+
277
+ def list_orgs(
278
+ self, cursor: Optional[str] = None, limit: Optional[int] = 50
279
+ ) -> List[Organization]:
280
+ raise NotImplementedError
281
+
282
+ def delete_org(self, org_id: str) -> Organization:
283
+ raise NotImplementedError
284
+
285
+ def create_sandbox_config(
286
+ self, config: Union[LocalSandboxConfig, E2BSandboxConfig]
287
+ ) -> SandboxConfig:
288
+ """
289
+ Create a new sandbox configuration.
290
+
291
+ Args:
292
+ config (Union[LocalSandboxConfig, E2BSandboxConfig]): The sandbox settings.
293
+
294
+ Returns:
295
+ SandboxConfig: The created sandbox configuration.
296
+ """
297
+ raise NotImplementedError
298
+
299
+ def update_sandbox_config(
300
+ self,
301
+ sandbox_config_id: str,
302
+ config: Union[LocalSandboxConfig, E2BSandboxConfig],
303
+ ) -> SandboxConfig:
304
+ """
305
+ Update an existing sandbox configuration.
306
+
307
+ Args:
308
+ sandbox_config_id (str): The ID of the sandbox configuration to update.
309
+ config (Union[LocalSandboxConfig, E2BSandboxConfig]): The updated sandbox settings.
310
+
311
+ Returns:
312
+ SandboxConfig: The updated sandbox configuration.
313
+ """
314
+ raise NotImplementedError
315
+
316
+ def delete_sandbox_config(self, sandbox_config_id: str) -> None:
317
+ """
318
+ Delete a sandbox configuration.
319
+
320
+ Args:
321
+ sandbox_config_id (str): The ID of the sandbox configuration to delete.
322
+ """
323
+ raise NotImplementedError
324
+
325
+ def list_sandbox_configs(
326
+ self, limit: int = 50, cursor: Optional[str] = None
327
+ ) -> List[SandboxConfig]:
328
+ """
329
+ List all sandbox configurations.
330
+
331
+ Args:
332
+ limit (int, optional): The maximum number of sandbox configurations to return. Defaults to 50.
333
+ cursor (Optional[str], optional): The pagination cursor for retrieving the next set of results.
334
+
335
+ Returns:
336
+ List[SandboxConfig]: A list of sandbox configurations.
337
+ """
338
+ raise NotImplementedError
339
+
340
+ def create_sandbox_env_var(
341
+ self,
342
+ sandbox_config_id: str,
343
+ key: str,
344
+ value: str,
345
+ description: Optional[str] = None,
346
+ ) -> SandboxEnvironmentVariable:
347
+ """
348
+ Create a new environment variable for a sandbox configuration.
349
+
350
+ Args:
351
+ sandbox_config_id (str): The ID of the sandbox configuration to associate the environment variable with.
352
+ key (str): The name of the environment variable.
353
+ value (str): The value of the environment variable.
354
+ description (Optional[str], optional): A description of the environment variable. Defaults to None.
355
+
356
+ Returns:
357
+ SandboxEnvironmentVariable: The created environment variable.
358
+ """
359
+ raise NotImplementedError
360
+
361
+ def update_sandbox_env_var(
362
+ self,
363
+ env_var_id: str,
364
+ key: Optional[str] = None,
365
+ value: Optional[str] = None,
366
+ description: Optional[str] = None,
367
+ ) -> SandboxEnvironmentVariable:
368
+ """
369
+ Update an existing environment variable.
370
+
371
+ Args:
372
+ env_var_id (str): The ID of the environment variable to update.
373
+ key (Optional[str], optional): The updated name of the environment variable. Defaults to None.
374
+ value (Optional[str], optional): The updated value of the environment variable. Defaults to None.
375
+ description (Optional[str], optional): The updated description of the environment variable. Defaults to None.
376
+
377
+ Returns:
378
+ SandboxEnvironmentVariable: The updated environment variable.
379
+ """
380
+ raise NotImplementedError
381
+
382
+ def delete_sandbox_env_var(self, env_var_id: str) -> None:
383
+ """
384
+ Delete an environment variable by its ID.
385
+
386
+ Args:
387
+ env_var_id (str): The ID of the environment variable to delete.
388
+ """
389
+ raise NotImplementedError
390
+
391
+ def list_sandbox_env_vars(
392
+ self, sandbox_config_id: str, limit: int = 50, cursor: Optional[str] = None
393
+ ) -> List[SandboxEnvironmentVariable]:
394
+ """
395
+ List all environment variables associated with a sandbox configuration.
396
+
397
+ Args:
398
+ sandbox_config_id (str): The ID of the sandbox configuration to retrieve environment variables for.
399
+ limit (int, optional): The maximum number of environment variables to return. Defaults to 50.
400
+ cursor (Optional[str], optional): The pagination cursor for retrieving the next set of results.
401
+
402
+ Returns:
403
+ List[SandboxEnvironmentVariable]: A list of environment variables.
404
+ """
405
+ raise NotImplementedError
@@ -0,0 +1,60 @@
1
+ """
2
+ Client-side constants - minimal set needed by schemas and client code.
3
+
4
+ These are the constants required by the client package (schemas, helpers, client).
5
+ The full server constants module (mirix.constants) imports from here and adds
6
+ additional server-only constants.
7
+ """
8
+
9
+ # Embedding constants
10
+ MAX_EMBEDDING_DIM = 4096 # maximum supported embedding size - do NOT change or else DBs will need to be reset
11
+ DEFAULT_EMBEDDING_CHUNK_SIZE = 300
12
+ MIN_CONTEXT_WINDOW = 4096
13
+
14
+ # Memory limits
15
+ CORE_MEMORY_BLOCK_CHAR_LIMIT: int = 5000
16
+
17
+ # Function/Tool constants
18
+ FUNCTION_RETURN_CHAR_LIMIT = 60000 # ~300 words
19
+ TOOL_CALL_ID_MAX_LEN = 29
20
+
21
+ # Tool module names
22
+ COMPOSIO_TOOL_TAG_NAME = "composio"
23
+ MIRIX_CORE_TOOL_MODULE_NAME = "mirix.functions.function_sets.base"
24
+ MIRIX_MEMORY_TOOL_MODULE_NAME = "mirix.functions.function_sets.memory_tools"
25
+ MIRIX_EXTRA_TOOL_MODULE_NAME = "mirix.functions.function_sets.extras"
26
+
27
+ # Message defaults
28
+ DEFAULT_MESSAGE_TOOL = "send_message"
29
+ DEFAULT_MESSAGE_TOOL_KWARG = "message"
30
+
31
+ # LLM model token limits
32
+ LLM_MAX_TOKENS = {
33
+ "DEFAULT": 8192,
34
+ ## OpenAI models: https://platform.openai.com/docs/models/overview
35
+ "chatgpt-4o-latest": 128000,
36
+ "gpt-4o-2024-08-06": 128000,
37
+ "gpt-4-turbo-preview": 128000,
38
+ "gpt-4o": 128000,
39
+ "gpt-3.5-turbo-instruct": 16385,
40
+ "gpt-4-0125-preview": 128000,
41
+ "gpt-3.5-turbo-0125": 16385,
42
+ "gpt-4-turbo-2024-04-09": 128000,
43
+ "gpt-4-turbo": 8192,
44
+ "gpt-4o-2024-05-13": 128000,
45
+ "gpt-4o-mini": 128000,
46
+ "gpt-4o-mini-2024-07-18": 128000,
47
+ "gpt-4-1106-preview": 128000,
48
+ "gpt-4": 8192,
49
+ "gpt-4-32k": 32768,
50
+ "gpt-4-0613": 8192,
51
+ "gpt-4-32k-0613": 32768,
52
+ "gpt-4-0314": 8192, # legacy
53
+ "gpt-4-32k-0314": 32768, # legacy
54
+ "gpt-3.5-turbo-1106": 16385,
55
+ "gpt-3.5-turbo": 4096,
56
+ "gpt-3.5-turbo-16k": 16385,
57
+ "gpt-3.5-turbo-0613": 4096, # legacy
58
+ "gpt-3.5-turbo-16k-0613": 16385, # legacy
59
+ "gpt-3.5-turbo-0301": 4096, # legacy
60
+ }