jl-ecms-client 0.2.8__py3-none-any.whl → 0.2.22__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 (40) hide show
  1. {jl_ecms_client-0.2.8.dist-info → jl_ecms_client-0.2.22.dist-info}/METADATA +6 -1
  2. jl_ecms_client-0.2.22.dist-info/RECORD +67 -0
  3. mirix/__init__.py +41 -0
  4. mirix/client/client.py +1 -1
  5. mirix/constants.py +251 -0
  6. mirix/errors.py +238 -0
  7. mirix/functions/__init__.py +0 -0
  8. mirix/functions/ast_parsers.py +113 -0
  9. mirix/functions/function_sets/__init__.py +1 -0
  10. mirix/functions/function_sets/base.py +330 -0
  11. mirix/functions/function_sets/extras.py +271 -0
  12. mirix/functions/function_sets/memory_tools.py +933 -0
  13. mirix/functions/functions.py +199 -0
  14. mirix/functions/helpers.py +311 -0
  15. mirix/functions/schema_generator.py +511 -0
  16. mirix/helpers/json_helpers.py +3 -3
  17. mirix/log.py +163 -0
  18. mirix/schemas/agent.py +1 -1
  19. mirix/schemas/block.py +1 -1
  20. mirix/schemas/embedding_config.py +0 -3
  21. mirix/schemas/enums.py +12 -0
  22. mirix/schemas/episodic_memory.py +1 -1
  23. mirix/schemas/knowledge_vault.py +1 -1
  24. mirix/schemas/memory.py +1 -1
  25. mirix/schemas/message.py +1 -1
  26. mirix/schemas/mirix_request.py +1 -1
  27. mirix/schemas/procedural_memory.py +1 -1
  28. mirix/schemas/providers.py +1 -1
  29. mirix/schemas/resource_memory.py +1 -1
  30. mirix/schemas/sandbox_config.py +1 -3
  31. mirix/schemas/semantic_memory.py +1 -1
  32. mirix/schemas/tool.py +241 -241
  33. mirix/schemas/user.py +3 -3
  34. mirix/settings.py +280 -0
  35. mirix/system.py +261 -0
  36. jl_ecms_client-0.2.8.dist-info/RECORD +0 -53
  37. mirix/client/constants.py +0 -60
  38. {jl_ecms_client-0.2.8.dist-info → jl_ecms_client-0.2.22.dist-info}/WHEEL +0 -0
  39. {jl_ecms_client-0.2.8.dist-info → jl_ecms_client-0.2.22.dist-info}/licenses/LICENSE +0 -0
  40. {jl_ecms_client-0.2.8.dist-info → jl_ecms_client-0.2.22.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jl-ecms-client
3
- Version: 0.2.8
3
+ Version: 0.2.22
4
4
  Summary: Intuit ECMS Client - Lightweight Python client for Intuit ECMS server
5
5
  Home-page: https://github.com/Mirix-AI/MIRIX
6
6
  Author: Mirix AI
@@ -31,8 +31,13 @@ Requires-Dist: pydantic>=2.0.0
31
31
  Requires-Dist: pydantic-settings>=2.0.0
32
32
  Requires-Dist: python-dotenv>=1.0.0
33
33
  Requires-Dist: httpx>=0.25.0
34
+ Requires-Dist: jinja2>=3.1.0
35
+ Requires-Dist: demjson3>=3.0.0
36
+ Requires-Dist: json-repair>=0.25.0
34
37
  Requires-Dist: rich<14.0.0,>=13.7.1
35
38
  Requires-Dist: pytz>=2024.1
39
+ Requires-Dist: docstring-parser>=0.15
40
+ Requires-Dist: pyhumps>=3.8.0
36
41
  Provides-Extra: dev
37
42
  Requires-Dist: pytest>=6.0.0; extra == "dev"
38
43
  Requires-Dist: pytest-asyncio; extra == "dev"
@@ -0,0 +1,67 @@
1
+ jl_ecms_client-0.2.22.dist-info/licenses/LICENSE,sha256=8fOrt8t-9Lb_RKUa_xmj1_bVzbbluGEXERWSfM7rXfY,10758
2
+ mirix/__init__.py,sha256=t3TnaGOphy_dCj9Fi7ELrv9_NDrGOsPK41y6AFvyQS0,1748
3
+ mirix/constants.py,sha256=ekqrVAjR8dccbLtw6ZAmXoCHc11At-OeIeE_my54FIs,8949
4
+ mirix/errors.py,sha256=1ey4Ze4kKMO0Os_c8mSAQWvawa_srFkIsPZBt_Phb3o,6642
5
+ mirix/log.py,sha256=Jl_Gr6xigdGwRL-z-k2pp8WW2ahfTgwGStEIt6Y6WuY,5768
6
+ mirix/settings.py,sha256=SjZrsiNn6_fTi4cCEiK6PneS23XGzwjdVN6Apmg3d0w,10446
7
+ mirix/system.py,sha256=dmSz0SC4IZcJGHVMwtuKrZr27swB-h2uUl2BQXM_6Uo,8378
8
+ mirix/client/__init__.py,sha256=IMgb1FqBcVVcqrK_zWoCDPkb8x1AK4PBtTj5PyhnyWI,433
9
+ mirix/client/client.py,sha256=yVvA_mCX-8B7Mlm4yyHACTtwFosgHMm-01NgbhhywcU,13223
10
+ mirix/client/remote_client.py,sha256=P0sTbGlqeuT_cIvGh243NK1Uf4a2JgNkQLdLvN950HQ,42646
11
+ mirix/client/utils.py,sha256=xPAvR3slBQ5srOFLtYTqpL3PeD5n0YsxBRR1sLgKBdY,786
12
+ mirix/functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ mirix/functions/ast_parsers.py,sha256=4MLx-r_jD6nfaTpkpoc6bH6NtxaCebtSWNgsZjYtINo,3684
14
+ mirix/functions/functions.py,sha256=8eUomnEZpb4qV7yU5KUh1wsEr5tGf4pERVRdV5hgpys,7106
15
+ mirix/functions/helpers.py,sha256=NUpHk6VCwJgKc_EVTBSU6ZuAGTwRRsXLiTisW9Q0Ntg,13053
16
+ mirix/functions/schema_generator.py,sha256=YEMItK0wGG7JRZBkkJDIAtgt7_pgfEv_8lGUS6Pno9Y,19569
17
+ mirix/functions/function_sets/__init__.py,sha256=gnUpz_NoRrVh2IHhiSOnxreVgnV0Hn6wpdvSJ98ogyg,24
18
+ mirix/functions/function_sets/base.py,sha256=bL6-Msn6j1Adf84kLx2S7lEsZ4AM4X34gqYEdJ_TbYQ,14150
19
+ mirix/functions/function_sets/extras.py,sha256=qHQHKiY8vMt314VNAHs3lw_P00msTMzKTRq3quAyNZo,10471
20
+ mirix/functions/function_sets/memory_tools.py,sha256=uE7HyrTDuBS9UOsBKnC_z977SSTOhB1kseWQDYI9pjQ,37035
21
+ mirix/helpers/__init__.py,sha256=2QXDAywb0wF3JNLC7GgMDJb_kQpwvlb6ZCnjuLmOfPw,78
22
+ mirix/helpers/converters.py,sha256=WuYkra4c9-JRC2lRo7LmmFMH42qf3k6ox3OGOYlDQLk,13504
23
+ mirix/helpers/datetime_helpers.py,sha256=7U5ZJkE0cLki4sG8ukIHZSAoFfQpLWQu2kFekETy6Zg,2633
24
+ mirix/helpers/json_helpers.py,sha256=FL6ACXaoOCwwJq4ccygI5XbNLE4-BESa8SRGoAsxXCg,1219
25
+ mirix/helpers/message_helpers.py,sha256=xOn2Uwx5XK4C1ahYKmFe9ak7QjE5vcPVuZBcLDYxkZA,2571
26
+ mirix/helpers/tool_rule_solver.py,sha256=LM9YuugmYtxxtcrD7GakbCNvmnuLK4Zp5KV8vA-UNSA,6542
27
+ mirix/schemas/__init__.py,sha256=HPrtil4I9_KC2u6eJZpBJ2dbl_YxOj_ZeYnKYq3RSGM,24
28
+ mirix/schemas/agent.py,sha256=3JjicV_7VX5JZk7cKORAsod6Dh6Z-14OjUKq8mJH9o8,15847
29
+ mirix/schemas/block.py,sha256=F8G8pOO-dQuYQK7X7DNRdbRo5cTkfOp-vcDIora_VV8,5138
30
+ mirix/schemas/cloud_file_mapping.py,sha256=i_5N41hNt0rEl-fvnGoPggLMbFdEk97wI71qQTjHKIg,977
31
+ mirix/schemas/embedding_config.py,sha256=-wCLpCv0ohxZAjAjr-gZqq5oGIIZBevfKd_Er8oHqYA,3986
32
+ mirix/schemas/enums.py,sha256=Rdlm0HPKAQQgZFjo_DI_DrkbHVAtNqsnbxHhJPlDlD8,1706
33
+ mirix/schemas/environment_variables.py,sha256=mSL5U2NYxJHO4fb2dF3YgPyINgYgelsSzMqQ6nsjzng,2573
34
+ mirix/schemas/episodic_memory.py,sha256=MG7CxQoFmQd30kO8OMNQyyDAtodMJPfAw-icGuKz5OA,6323
35
+ mirix/schemas/file.py,sha256=J92aWus84jPoF71wRtKIvoAPSdIDt4McEM6yDWzHiqg,2064
36
+ mirix/schemas/health.py,sha256=zT6mYovvD17iJRuu2rcaQQzbEEYrkwvAE9TB7iU824c,139
37
+ mirix/schemas/knowledge_vault.py,sha256=9jwwVVKVClr6yMK-suj0uxgWBYJg5W3gHSaPxvPDV84,6309
38
+ mirix/schemas/llm_config.py,sha256=ZTJtqlD-J8wsEx4_aAMbqHaL0vxDrDjsgwD5RK07zcs,7256
39
+ mirix/schemas/memory.py,sha256=CEVmCf0Ez3pxyee3YlsLrxXXwEzpmlXNQQKOvNZIRos,11984
40
+ mirix/schemas/message.py,sha256=X-rpz4ylmKyJFrCmHHjXm-cG2jArOxunubJ_833zn34,53983
41
+ mirix/schemas/mirix_base.py,sha256=DMkOMZw1mw8Vte8yCGK9xAhqgY2O2CO6uYD9pgf9e6A,3859
42
+ mirix/schemas/mirix_message.py,sha256=WQHdA1dhLiwh0I3y710JMZx42fFmFkXBKdQdl1XdiDY,15334
43
+ mirix/schemas/mirix_message_content.py,sha256=xdgTM5AkkONe4mjgcZNuKkbKk_fEY4rqzobD7cvy5cA,6815
44
+ mirix/schemas/mirix_request.py,sha256=dyCcH7RHGL8P962QcDgd6EH9pE__dfMIUa94y5vX5V0,1392
45
+ mirix/schemas/mirix_response.py,sha256=w_hTYJs_cpBdx1mWfezzbiV49U4MWHKEfwFrYSMAVR0,7444
46
+ mirix/schemas/organization.py,sha256=tHjE4CmboPJV8OMZ1BfGuFanMJKCED5rh1IBpNQhGTc,1120
47
+ mirix/schemas/procedural_memory.py,sha256=dfKhyTQuR54ghmTIewCdLY6-kzJoC8iI-oTNjeTyGCc,5502
48
+ mirix/schemas/providers.py,sha256=kZmC2-RTb8Hzhd7LXvwg0yyL2-d4JVFoYIZ7l04DPWs,30545
49
+ mirix/schemas/resource_memory.py,sha256=_SurGWLEmVsEfl_1s7-V74uW7wi3eEMwh1RgijfTp1g,4900
50
+ mirix/schemas/sandbox_config.py,sha256=VhHM2DwqfL4OzsgprWEQMw_oLwdI7_sa2h-eeNSpaqI,4447
51
+ mirix/schemas/semantic_memory.py,sha256=duAuVDrStUEA1FbE_v_i8TWwC7DjerMkiM-MG-3K-fM,5986
52
+ mirix/schemas/source.py,sha256=9Qe-E15sDXcopd3UPW0-sC3lFHIjlV44t_lV7KxkCWY,3050
53
+ mirix/schemas/step.py,sha256=msWn5uBdaR3dYmjTuCwmvq3Mm-kP0Ha8e3-2sfCvG1Y,1826
54
+ mirix/schemas/tool.py,sha256=payIHfE8xwqpx3fgTor_8PaV1KkNp1hecDZDBEA8dwY,10243
55
+ mirix/schemas/tool_rule.py,sha256=uwyrOX38Vtp-6V1CbHnvBI3DzmWpW2zy7UPtYPmewus,6877
56
+ mirix/schemas/usage.py,sha256=QX7uIaK7-GgrZDMgeot-1ae2n-ol0yif3E7JsLF0Sxk,1166
57
+ mirix/schemas/user.py,sha256=sr7Rv4tIBWWaf1MJs-Qukie9YpMjfa5G5k8NSfvEyXo,2431
58
+ mirix/schemas/openai/__init__.py,sha256=u3PhqJOMwv1fPfMOD6TNZ6zsWvEBpmur4Ypwj733UB0,24
59
+ mirix/schemas/openai/chat_completion_request.py,sha256=eC4fMMJRucHtXfCUVPZu7ZeSt_LUPAsZtu_Z-hzfW6c,3395
60
+ mirix/schemas/openai/chat_completion_response.py,sha256=1hF0Gaxvd03oBdKupz37qk_2LVFoev0T8GVEHHyVLfo,4054
61
+ mirix/schemas/openai/chat_completions.py,sha256=PfC4MOiADLW_BfgmUohqK033VB4IO5fLIR1416C1DCE,3616
62
+ mirix/schemas/openai/embedding_response.py,sha256=WKIZpXab1Av7v6sxKG8feW3ZtpQUNosmLVSuhXYa_xU,357
63
+ mirix/schemas/openai/openai.py,sha256=gXfYwdGRJ-co15zVKw3lua0iZL_lJBBo03XMWsw1uTI,8394
64
+ jl_ecms_client-0.2.22.dist-info/METADATA,sha256=HL2bMzVHxk7RODvNgtT-ko_oelGj8_NmoE4188fODj4,11007
65
+ jl_ecms_client-0.2.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
66
+ jl_ecms_client-0.2.22.dist-info/top_level.txt,sha256=hQ_Eh5KYzEGkhtEyWHdBYJ5iCom6_nlj0zQ6-v0WDIY,6
67
+ jl_ecms_client-0.2.22.dist-info/RECORD,,
mirix/__init__.py ADDED
@@ -0,0 +1,41 @@
1
+ __version__ = "0.2.22"
2
+
3
+
4
+ # Client imports (always available)
5
+ from mirix.client import MirixClient as MirixClient
6
+
7
+ # Server-only imports (only available when full package is installed)
8
+ try:
9
+ from mirix.local_client import LocalClient as LocalClient
10
+ from mirix.local_client import create_client as create_client
11
+ except ImportError:
12
+ LocalClient = None
13
+ create_client = None
14
+
15
+ try:
16
+ from mirix.sdk import Mirix as Mirix
17
+ from mirix.sdk import load_config as load_config
18
+ except ImportError:
19
+ Mirix = None
20
+ load_config = None
21
+
22
+ # Schema imports for easier access (available in both client and server)
23
+ from mirix.schemas.agent import AgentState as AgentState
24
+ from mirix.schemas.block import Block as Block
25
+ from mirix.schemas.embedding_config import EmbeddingConfig as EmbeddingConfig
26
+ from mirix.schemas.enums import JobStatus as JobStatus
27
+ from mirix.schemas.llm_config import LLMConfig as LLMConfig
28
+ from mirix.schemas.memory import ArchivalMemorySummary as ArchivalMemorySummary
29
+ from mirix.schemas.memory import BasicBlockMemory as BasicBlockMemory
30
+ from mirix.schemas.memory import ChatMemory as ChatMemory
31
+ from mirix.schemas.memory import Memory as Memory
32
+ from mirix.schemas.memory import RecallMemorySummary as RecallMemorySummary
33
+ from mirix.schemas.message import Message as Message
34
+ from mirix.schemas.mirix_message import MirixMessage as MirixMessage
35
+ from mirix.schemas.openai.chat_completion_response import (
36
+ UsageStatistics as UsageStatistics,
37
+ )
38
+ from mirix.schemas.organization import Organization as Organization
39
+ from mirix.schemas.tool import Tool as Tool
40
+ from mirix.schemas.usage import MirixUsageStatistics as MirixUsageStatistics
41
+ from mirix.schemas.user import User as User
mirix/client/client.py CHANGED
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
22
22
  from langchain_core.tools import BaseTool as LangChainBaseTool
23
23
  except ImportError:
24
24
  LangChainBaseTool = Any # type: ignore
25
- from mirix.client.constants import FUNCTION_RETURN_CHAR_LIMIT
25
+ from mirix.constants import FUNCTION_RETURN_CHAR_LIMIT
26
26
  from mirix.schemas.agent import AgentState, AgentType, CreateAgent, CreateMetaAgent
27
27
  from mirix.schemas.block import Block, BlockUpdate, CreateBlock, Human, Persona
28
28
  from mirix.schemas.embedding_config import EmbeddingConfig
mirix/constants.py ADDED
@@ -0,0 +1,251 @@
1
+ import os
2
+ from logging import CRITICAL, DEBUG, ERROR, INFO, NOTSET, WARN, WARNING
3
+
4
+ # ============================================================================
5
+ # Client Constants - Used by both client and server
6
+ # ============================================================================
7
+
8
+ # Default organization and user IDs (needed by schemas)
9
+ DEFAULT_ORG_ID = "org-00000000-0000-4000-8000-000000000000"
10
+ DEFAULT_USER_ID = "user-00000000-0000-4000-8000-000000000000"
11
+
12
+ # Embedding constants
13
+ MAX_EMBEDDING_DIM = 4096 # maximum supported embedding size - do NOT change or else DBs will need to be reset
14
+ DEFAULT_EMBEDDING_CHUNK_SIZE = 300
15
+ MIN_CONTEXT_WINDOW = 4096
16
+
17
+ # Memory limits
18
+ CORE_MEMORY_BLOCK_CHAR_LIMIT: int = 5000
19
+
20
+ # Function/Tool constants
21
+ FUNCTION_RETURN_CHAR_LIMIT = 60000 # ~300 words
22
+ TOOL_CALL_ID_MAX_LEN = 29
23
+
24
+ # Tool module names
25
+ COMPOSIO_TOOL_TAG_NAME = "composio"
26
+ MIRIX_CORE_TOOL_MODULE_NAME = "mirix.functions.function_sets.base"
27
+ MIRIX_MEMORY_TOOL_MODULE_NAME = "mirix.functions.function_sets.memory_tools"
28
+ MIRIX_EXTRA_TOOL_MODULE_NAME = "mirix.functions.function_sets.extras"
29
+
30
+ # Message defaults
31
+ DEFAULT_MESSAGE_TOOL = "send_message"
32
+ DEFAULT_MESSAGE_TOOL_KWARG = "message"
33
+
34
+ # LLM model token limits
35
+ LLM_MAX_TOKENS = {
36
+ "DEFAULT": 8192,
37
+ ## OpenAI models: https://platform.openai.com/docs/models/overview
38
+ "chatgpt-4o-latest": 128000,
39
+ "gpt-4o-2024-08-06": 128000,
40
+ "gpt-4-turbo-preview": 128000,
41
+ "gpt-4o": 128000,
42
+ "gpt-3.5-turbo-instruct": 16385,
43
+ "gpt-4-0125-preview": 128000,
44
+ "gpt-3.5-turbo-0125": 16385,
45
+ "gpt-4-turbo-2024-04-09": 128000,
46
+ "gpt-4-turbo": 8192,
47
+ "gpt-4o-2024-05-13": 128000,
48
+ "gpt-4o-mini": 128000,
49
+ "gpt-4o-mini-2024-07-18": 128000,
50
+ "gpt-4-1106-preview": 128000,
51
+ "gpt-4": 8192,
52
+ "gpt-4-32k": 32768,
53
+ "gpt-4-0613": 8192,
54
+ "gpt-4-32k-0613": 32768,
55
+ "gpt-4-0314": 8192, # legacy
56
+ "gpt-4-32k-0314": 32768, # legacy
57
+ "gpt-3.5-turbo-1106": 16385,
58
+ "gpt-3.5-turbo": 4096,
59
+ "gpt-3.5-turbo-16k": 16385,
60
+ "gpt-3.5-turbo-0613": 4096, # legacy
61
+ "gpt-3.5-turbo-16k-0613": 16385, # legacy
62
+ "gpt-3.5-turbo-0301": 4096, # legacy
63
+ }
64
+
65
+ # ============================================================================
66
+ # Server-Only Constants
67
+ # ============================================================================
68
+
69
+ MIRIX_DIR = os.path.join(os.path.expanduser("~"), ".mirix")
70
+ MIRIX_DIR_TOOL_SANDBOX = os.path.join(MIRIX_DIR, "tool_sandbox_dir")
71
+
72
+ ADMIN_PREFIX = "/v1/admin"
73
+ API_PREFIX = "/v1"
74
+ OPENAI_API_PREFIX = "/openai"
75
+
76
+ COMPOSIO_ENTITY_ENV_VAR_KEY = "COMPOSIO_ENTITY"
77
+
78
+ # String in the error message for when the context window is too large
79
+ # Example full message:
80
+ # This model's maximum context length is 8192 tokens. However, your messages resulted in 8198 tokens (7450 in the messages, 748 in the functions). Please reduce the length of the messages or functions.
81
+ OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING = "maximum context length"
82
+
83
+ # System prompt templating
84
+ IN_CONTEXT_MEMORY_KEYWORD = "CORE_MEMORY"
85
+
86
+ MAX_CHAINING_STEPS = 10
87
+ MAX_RETRIEVAL_LIMIT_IN_SYSTEM = 10
88
+
89
+ # tokenizers
90
+ EMBEDDING_TO_TOKENIZER_MAP = {
91
+ "text-embedding-3-small": "cl100k_base",
92
+ }
93
+ EMBEDDING_TO_TOKENIZER_DEFAULT = "cl100k_base"
94
+
95
+
96
+ DEFAULT_MIRIX_MODEL = "gpt-4" # TODO: fixme
97
+ DEFAULT_PERSONA = "sam_pov"
98
+ DEFAULT_HUMAN = "basic"
99
+ DEFAULT_PRESET = "memgpt_chat"
100
+
101
+ # Base tools that cannot be edited, as they access agent state directly
102
+ # Note that we don't include "conversation_search_date" for now
103
+ BASE_TOOLS = [
104
+ "send_intermediate_message",
105
+ "conversation_search",
106
+ "search_in_memory",
107
+ "list_memory_within_timerange",
108
+ ]
109
+ # Base memory tools CAN be edited, and are added by default by the server
110
+ CORE_MEMORY_TOOLS = ["core_memory_append", "core_memory_rewrite"]
111
+ EPISODIC_MEMORY_TOOLS = [
112
+ "episodic_memory_insert",
113
+ "episodic_memory_merge",
114
+ "episodic_memory_replace",
115
+ "check_episodic_memory",
116
+ ]
117
+ PROCEDURAL_MEMORY_TOOLS = ["procedural_memory_insert", "procedural_memory_update"]
118
+ RESOURCE_MEMORY_TOOLS = ["resource_memory_insert", "resource_memory_update"]
119
+ KNOWLEDGE_VAULT_TOOLS = ["knowledge_vault_insert", "knowledge_vault_update"]
120
+ SEMANTIC_MEMORY_TOOLS = [
121
+ "semantic_memory_insert",
122
+ "semantic_memory_update",
123
+ "check_semantic_memory",
124
+ ]
125
+ CHAT_AGENT_TOOLS = []
126
+ EXTRAS_TOOLS = ["web_search", "fetch_and_read_pdf"]
127
+ MCP_TOOLS = []
128
+ META_MEMORY_TOOLS = ["trigger_memory_update"]
129
+ SEARCH_MEMORY_TOOLS = ["search_in_memory", "list_memory_within_timerange"]
130
+ UNIVERSAL_MEMORY_TOOLS = [
131
+ "search_in_memory",
132
+ "finish_memory_update",
133
+ "list_memory_within_timerange",
134
+ ]
135
+ ALL_TOOLS = list(
136
+ set(
137
+ BASE_TOOLS
138
+ + CORE_MEMORY_TOOLS
139
+ + EPISODIC_MEMORY_TOOLS
140
+ + PROCEDURAL_MEMORY_TOOLS
141
+ + RESOURCE_MEMORY_TOOLS
142
+ + KNOWLEDGE_VAULT_TOOLS
143
+ + SEMANTIC_MEMORY_TOOLS
144
+ + META_MEMORY_TOOLS
145
+ + UNIVERSAL_MEMORY_TOOLS
146
+ + CHAT_AGENT_TOOLS
147
+ + EXTRAS_TOOLS
148
+ + MCP_TOOLS
149
+ )
150
+ )
151
+
152
+ # The name of the tool used to send message to the user
153
+ # Structured output models
154
+ STRUCTURED_OUTPUT_MODELS = {"gpt-4o", "gpt-4o-mini"}
155
+
156
+ # LOGGER_LOG_LEVEL is use to convert Text to Logging level value for logging mostly for Cli input to setting level
157
+ LOGGER_LOG_LEVELS = {
158
+ "CRITICAL": CRITICAL,
159
+ "ERROR": ERROR,
160
+ "WARN": WARN,
161
+ "WARNING": WARNING,
162
+ "INFO": INFO,
163
+ "DEBUG": DEBUG,
164
+ "NOTSET": NOTSET,
165
+ }
166
+
167
+ FIRST_MESSAGE_ATTEMPTS = 10
168
+
169
+ INITIAL_BOOT_MESSAGE = "Boot sequence complete. Persona activated."
170
+ INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT = (
171
+ "Bootup sequence complete. Persona activated. Testing messaging functionality."
172
+ )
173
+ STARTUP_QUOTES = [
174
+ "I think, therefore I am.",
175
+ "All those moments will be lost in time, like tears in rain.",
176
+ "More human than human is our motto.",
177
+ ]
178
+ INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG = STARTUP_QUOTES[2]
179
+
180
+ CLI_WARNING_PREFIX = "Warning: "
181
+
182
+ ERROR_MESSAGE_PREFIX = "Error"
183
+
184
+ NON_USER_MSG_PREFIX = "[This is an automated system message hidden from the user] "
185
+
186
+ # The error message that Mirix will receive
187
+ # MESSAGE_SUMMARY_WARNING_STR = f"Warning: the conversation history will soon reach its maximum length and be trimmed. Make sure to save any important information from the conversation to your memory before it is removed."
188
+ # Much longer and more specific variant of the prompt
189
+ # TODO: Emit the warning to Meta Memory Manager instead of the Chat Agent.
190
+ MESSAGE_SUMMARY_WARNING_STR = " ".join(
191
+ [
192
+ f"{NON_USER_MSG_PREFIX}The conversation history will soon reach its maximum length and be trimmed.",
193
+ "Do NOT tell the user about this system alert, they should not know that the history is reaching max length.",
194
+ ]
195
+ )
196
+
197
+ # The ackknowledgement message used in the summarize sequence
198
+ MESSAGE_SUMMARY_REQUEST_ACK = "Understood, I will respond with a summary of the message (and only the summary, nothing else) once I receive the conversation history. I'm ready."
199
+
200
+ # Maximum length of an error message
201
+ MAX_ERROR_MESSAGE_CHAR_LIMIT = 500
202
+
203
+ # Default memory limits
204
+ CORE_MEMORY_PERSONA_CHAR_LIMIT: int = 5000
205
+ CORE_MEMORY_HUMAN_CHAR_LIMIT: int = 5000
206
+
207
+ MAX_PAUSE_HEARTBEATS = 360 # in min
208
+
209
+ MESSAGE_CHATGPT_FUNCTION_MODEL = "gpt-3.5-turbo"
210
+ MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE = (
211
+ "You are a helpful assistant. Keep your responses short and concise."
212
+ )
213
+
214
+ #### Functions related
215
+
216
+ # REQ_HEARTBEAT_MESSAGE = f"{NON_USER_MSG_PREFIX}continue_chaining == true"
217
+ REQ_HEARTBEAT_MESSAGE = f"{NON_USER_MSG_PREFIX}Function called using continue_chaining=true, returning control"
218
+ # FUNC_FAILED_HEARTBEAT_MESSAGE = f"{NON_USER_MSG_PREFIX}Function call failed"
219
+ FUNC_FAILED_HEARTBEAT_MESSAGE = (
220
+ f"{NON_USER_MSG_PREFIX}Function call failed, returning control"
221
+ )
222
+
223
+
224
+ RETRIEVAL_QUERY_DEFAULT_PAGE_SIZE = 5
225
+
226
+ MAX_FILENAME_LENGTH = 255
227
+ RESERVED_FILENAMES = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "LPT1", "LPT2"}
228
+
229
+ MAX_IMAGES_TO_PROCESS = 100
230
+
231
+ DEFAULT_WRAPPER_NAME = "chatml"
232
+ INNER_THOUGHTS_KWARG_DESCRIPTION = "Deep inner monologue private to you only."
233
+ INNER_THOUGHTS_CLI_SYMBOL = "💭"
234
+ ASSISTANT_MESSAGE_CLI_SYMBOL = "🤖"
235
+
236
+ CLEAR_HISTORY_AFTER_MEMORY_UPDATE = os.getenv(
237
+ "CLEAR_HISTORY_AFTER_MEMORY_UPDATE", "true"
238
+ ).lower() in ("true", "1", "yes")
239
+ CALL_MEMORY_AGENT_IN_PARALLEL = os.getenv(
240
+ "CALL_MEMORY_AGENT_IN_PARALLEL", "false"
241
+ ).lower() in ("true", "1", "yes")
242
+ CHAINING_FOR_MEMORY_UPDATE = os.getenv(
243
+ "CHAINING_FOR_MEMORY_UPDATE", "false"
244
+ ).lower() in ("true", "1", "yes")
245
+
246
+ LOAD_IMAGE_CONTENT_FOR_LAST_MESSAGE_ONLY = os.getenv(
247
+ "LOAD_IMAGE_CONTENT_FOR_LAST_MESSAGE_ONLY", "false"
248
+ ).lower() in ("true", "1", "yes")
249
+ BUILD_EMBEDDINGS_FOR_MEMORY = os.getenv(
250
+ "BUILD_EMBEDDINGS_FOR_MEMORY", "true"
251
+ ).lower() in ("true", "1", "yes")
mirix/errors.py ADDED
@@ -0,0 +1,238 @@
1
+ import json
2
+ from enum import Enum
3
+ from typing import TYPE_CHECKING, List, Optional, Union
4
+
5
+ # Avoid circular imports
6
+ if TYPE_CHECKING:
7
+ from mirix.schemas.message import Message
8
+ from mirix.schemas.mirix_message import MirixMessage
9
+
10
+
11
+ class ErrorCode(Enum):
12
+ """Enum for error codes used by client."""
13
+
14
+ INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
15
+ CONTEXT_WINDOW_EXCEEDED = "CONTEXT_WINDOW_EXCEEDED"
16
+ RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED"
17
+
18
+
19
+ class MirixError(Exception):
20
+ """Base class for all Mirix related errors."""
21
+
22
+ def __init__(
23
+ self, message: str, code: Optional[ErrorCode] = None, details: dict = {}
24
+ ):
25
+ self.message = message
26
+ self.code = code
27
+ self.details = details
28
+ super().__init__(message)
29
+
30
+ def __str__(self) -> str:
31
+ if self.code:
32
+ return f"{self.code.value}: {self.message}"
33
+ return self.message
34
+
35
+ def __repr__(self) -> str:
36
+ return f"{self.__class__.__name__}(message='{self.message}', code='{self.code}', details={self.details})"
37
+
38
+
39
+ class MirixToolCreateError(MirixError):
40
+ """Error raised when a tool cannot be created."""
41
+
42
+ default_error_message = "Error creating tool."
43
+
44
+ def __init__(self, message=None):
45
+ super().__init__(message=message or self.default_error_message)
46
+
47
+
48
+ class MirixConfigurationError(MirixError):
49
+ """Error raised when there are configuration-related issues."""
50
+
51
+ def __init__(self, message: str, missing_fields: Optional[List[str]] = None):
52
+ self.missing_fields = missing_fields or []
53
+ super().__init__(
54
+ message=message, details={"missing_fields": self.missing_fields}
55
+ )
56
+
57
+
58
+ class MirixAgentNotFoundError(MirixError):
59
+ """Error raised when an agent is not found."""
60
+
61
+
62
+ class MirixUserNotFoundError(MirixError):
63
+ """Error raised when a user is not found."""
64
+
65
+
66
+ class LLMError(MirixError):
67
+ pass
68
+
69
+
70
+ class LLMAuthenticationError(LLMError):
71
+ """Error raised when LLM authentication fails."""
72
+
73
+ pass
74
+
75
+
76
+ class LLMBadRequestError(LLMError):
77
+ """Error raised when LLM request is malformed."""
78
+
79
+ pass
80
+
81
+
82
+ class LLMConnectionError(LLMError):
83
+ """Error raised when LLM connection fails."""
84
+
85
+ pass
86
+
87
+
88
+ class LLMNotFoundError(LLMError):
89
+ """Error raised when LLM resource is not found."""
90
+
91
+ pass
92
+
93
+
94
+ class LLMPermissionDeniedError(LLMError):
95
+ """Error raised when LLM permission is denied."""
96
+
97
+ pass
98
+
99
+
100
+ class LLMRateLimitError(LLMError):
101
+ """Error raised when LLM rate limit is exceeded."""
102
+
103
+ pass
104
+
105
+
106
+ class LLMServerError(LLMError):
107
+ """Error raised when LLM server encounters an error."""
108
+
109
+ pass
110
+
111
+
112
+ class LLMUnprocessableEntityError(LLMError):
113
+ """Error raised when LLM cannot process the entity."""
114
+
115
+ pass
116
+
117
+
118
+ class BedrockPermissionError(MirixError):
119
+ """Exception raised for errors in the Bedrock permission process."""
120
+
121
+ def __init__(
122
+ self,
123
+ message="User does not have access to the Bedrock model with the specified ID.",
124
+ ):
125
+ super().__init__(message=message)
126
+
127
+
128
+ class BedrockError(MirixError):
129
+ """Exception raised for errors in the Bedrock process."""
130
+
131
+ def __init__(self, message="Error with Bedrock model."):
132
+ super().__init__(message=message)
133
+
134
+
135
+ class LLMJSONParsingError(MirixError):
136
+ """Exception raised for errors in the JSON parsing process."""
137
+
138
+ def __init__(self, message="Error parsing JSON generated by LLM"):
139
+ super().__init__(message=message)
140
+
141
+
142
+ class LocalLLMError(MirixError):
143
+ """Generic catch-all error for local LLM problems"""
144
+
145
+ def __init__(self, message="Encountered an error while running local LLM"):
146
+ super().__init__(message=message)
147
+
148
+
149
+ class LocalLLMConnectionError(MirixError):
150
+ """Error for when local LLM cannot be reached with provided IP/port"""
151
+
152
+ def __init__(self, message="Could not connect to local LLM"):
153
+ super().__init__(message=message)
154
+
155
+
156
+ class ContextWindowExceededError(MirixError):
157
+ """Error raised when the context window is exceeded but further summarization fails."""
158
+
159
+ def __init__(self, message: str, details: dict = {}):
160
+ error_message = f"{message} ({details})"
161
+ super().__init__(
162
+ message=error_message,
163
+ code=ErrorCode.CONTEXT_WINDOW_EXCEEDED,
164
+ details=details,
165
+ )
166
+
167
+
168
+ class RateLimitExceededError(MirixError):
169
+ """Error raised when the llm rate limiter throttles api requests."""
170
+
171
+ def __init__(self, message: str, max_retries: int):
172
+ error_message = f"{message} ({max_retries})"
173
+ super().__init__(
174
+ message=error_message,
175
+ code=ErrorCode.RATE_LIMIT_EXCEEDED,
176
+ details={"max_retries": max_retries},
177
+ )
178
+
179
+
180
+ class MirixMessageError(MirixError):
181
+ """Base error class for handling message-related errors."""
182
+
183
+ messages: List[Union["Message", "MirixMessage"]]
184
+ default_error_message: str = "An error occurred with the message."
185
+
186
+ def __init__(
187
+ self,
188
+ *,
189
+ messages: List[Union["Message", "MirixMessage"]],
190
+ explanation: Optional[str] = None,
191
+ ) -> None:
192
+ error_msg = self.construct_error_message(
193
+ messages, self.default_error_message, explanation
194
+ )
195
+ super().__init__(error_msg)
196
+ self.messages = messages
197
+
198
+ @staticmethod
199
+ def construct_error_message(
200
+ messages: List[Union["Message", "MirixMessage"]],
201
+ error_msg: str,
202
+ explanation: Optional[str] = None,
203
+ ) -> str:
204
+ """Helper method to construct a clean and formatted error message."""
205
+ if explanation:
206
+ error_msg += f" (Explanation: {explanation})"
207
+
208
+ # Pretty print out message JSON
209
+ message_json = json.dumps(
210
+ [message.model_dump() for message in messages], indent=4
211
+ )
212
+ return f"{error_msg}\n\n{message_json}"
213
+
214
+
215
+ class MissingToolCallError(MirixMessageError):
216
+ """Error raised when a message is missing a tool call."""
217
+
218
+ default_error_message = "The message is missing a tool call."
219
+
220
+
221
+ class InvalidToolCallError(MirixMessageError):
222
+ """Error raised when a message uses an invalid tool call."""
223
+
224
+ default_error_message = (
225
+ "The message uses an invalid tool call or has improper usage of a tool call."
226
+ )
227
+
228
+
229
+ class MissingInnerMonologueError(MirixMessageError):
230
+ """Error raised when a message is missing an inner monologue."""
231
+
232
+ default_error_message = "The message is missing an inner monologue."
233
+
234
+
235
+ class InvalidInnerMonologueError(MirixMessageError):
236
+ """Error raised when a message has a malformed inner monologue."""
237
+
238
+ default_error_message = "The message has a malformed inner monologue."
File without changes