jl-ecms-client 0.2.7__py3-none-any.whl → 0.2.19__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.
- {jl_ecms_client-0.2.7.dist-info → jl_ecms_client-0.2.19.dist-info}/METADATA +6 -1
- jl_ecms_client-0.2.19.dist-info/RECORD +58 -0
- mirix/__init__.py +32 -0
- mirix/client/__init__.py +5 -63
- mirix/client/client.py +2 -2181
- mirix/constants.py +251 -0
- mirix/errors.py +238 -0
- mirix/helpers/json_helpers.py +3 -3
- mirix/log.py +163 -0
- mirix/schemas/agent.py +1 -1
- mirix/schemas/block.py +1 -1
- mirix/schemas/embedding_config.py +0 -3
- mirix/schemas/enums.py +12 -0
- mirix/schemas/episodic_memory.py +1 -1
- mirix/schemas/knowledge_vault.py +1 -1
- mirix/schemas/memory.py +1 -1
- mirix/schemas/message.py +1 -1
- mirix/schemas/mirix_request.py +1 -1
- mirix/schemas/procedural_memory.py +1 -1
- mirix/schemas/providers.py +1 -1
- mirix/schemas/resource_memory.py +1 -1
- mirix/schemas/sandbox_config.py +1 -3
- mirix/schemas/semantic_memory.py +1 -1
- mirix/schemas/tool.py +241 -241
- mirix/schemas/user.py +3 -3
- mirix/settings.py +280 -0
- mirix/system.py +261 -0
- jl_ecms_client-0.2.7.dist-info/RECORD +0 -53
- mirix/client/constants.py +0 -60
- {jl_ecms_client-0.2.7.dist-info → jl_ecms_client-0.2.19.dist-info}/WHEEL +0 -0
- {jl_ecms_client-0.2.7.dist-info → jl_ecms_client-0.2.19.dist-info}/licenses/LICENSE +0 -0
- {jl_ecms_client-0.2.7.dist-info → jl_ecms_client-0.2.19.dist-info}/top_level.txt +0 -0
mirix/settings.py
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from dotenv import load_dotenv
|
|
6
|
+
from pydantic import Field
|
|
7
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
8
|
+
|
|
9
|
+
# Load .env file if it exists before initializing settings
|
|
10
|
+
# This ensures environment variables from .env are available when settings are instantiated
|
|
11
|
+
load_dotenv()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolSettings(BaseSettings):
|
|
15
|
+
composio_api_key: Optional[str] = None
|
|
16
|
+
|
|
17
|
+
# E2B Sandbox configurations
|
|
18
|
+
e2b_api_key: Optional[str] = None
|
|
19
|
+
e2b_sandbox_template_id: Optional[str] = None # Updated manually
|
|
20
|
+
|
|
21
|
+
# Local Sandbox configurations
|
|
22
|
+
local_sandbox_dir: Optional[str] = None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SummarizerSettings(BaseSettings):
|
|
26
|
+
model_config = SettingsConfigDict(env_prefix="mirix_summarizer_", extra="ignore")
|
|
27
|
+
|
|
28
|
+
# Controls if we should evict all messages
|
|
29
|
+
# TODO: Can refactor this into an enum if we have a bunch of different kinds of summarizers
|
|
30
|
+
evict_all_messages: bool = False
|
|
31
|
+
|
|
32
|
+
# The maximum number of retries for the summarizer
|
|
33
|
+
# If we reach this cutoff, it probably means that the summarizer is not compressing down the in-context messages any further
|
|
34
|
+
# And we throw a fatal error
|
|
35
|
+
max_summarizer_retries: int = 3
|
|
36
|
+
|
|
37
|
+
# When to warn the model that a summarize command will happen soon
|
|
38
|
+
# The amount of tokens before a system warning about upcoming truncation is sent to Mirix
|
|
39
|
+
memory_warning_threshold: float = 0.75
|
|
40
|
+
|
|
41
|
+
# Whether to send the system memory warning message
|
|
42
|
+
send_memory_warning_message: bool = False
|
|
43
|
+
|
|
44
|
+
# The desired memory pressure to summarize down to
|
|
45
|
+
desired_memory_token_pressure: float = 0.1
|
|
46
|
+
|
|
47
|
+
# The number of messages at the end to keep
|
|
48
|
+
# Even when summarizing, we may want to keep a handful of recent messages
|
|
49
|
+
# These serve as in-context examples of how to use functions / what user messages look like
|
|
50
|
+
keep_last_n_messages: int = 5
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ModelSettings(BaseSettings):
|
|
54
|
+
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
|
55
|
+
|
|
56
|
+
# env_prefix='my_prefix_'
|
|
57
|
+
|
|
58
|
+
# openai
|
|
59
|
+
openai_api_key: Optional[str] = None
|
|
60
|
+
openai_api_base: str = "https://api.openai.com/v1"
|
|
61
|
+
|
|
62
|
+
# groq
|
|
63
|
+
groq_api_key: Optional[str] = None
|
|
64
|
+
|
|
65
|
+
# Bedrock
|
|
66
|
+
aws_access_key: Optional[str] = None
|
|
67
|
+
aws_secret_access_key: Optional[str] = None
|
|
68
|
+
aws_region: Optional[str] = None
|
|
69
|
+
bedrock_anthropic_version: Optional[str] = "bedrock-2023-05-31"
|
|
70
|
+
|
|
71
|
+
# anthropic
|
|
72
|
+
anthropic_api_key: Optional[str] = None
|
|
73
|
+
|
|
74
|
+
# ollama
|
|
75
|
+
ollama_base_url: Optional[str] = None
|
|
76
|
+
|
|
77
|
+
# azure
|
|
78
|
+
azure_api_key: Optional[str] = None
|
|
79
|
+
azure_base_url: Optional[str] = None
|
|
80
|
+
# We provide a default here, since usually people will want to be on the latest API version.
|
|
81
|
+
azure_api_version: Optional[str] = (
|
|
82
|
+
"2024-09-01-preview" # https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# google ai
|
|
86
|
+
gemini_api_key: Optional[str] = None
|
|
87
|
+
|
|
88
|
+
# together
|
|
89
|
+
together_api_key: Optional[str] = None
|
|
90
|
+
|
|
91
|
+
# vLLM
|
|
92
|
+
vllm_api_base: Optional[str] = None
|
|
93
|
+
|
|
94
|
+
# openllm
|
|
95
|
+
openllm_auth_type: Optional[str] = None
|
|
96
|
+
openllm_api_key: Optional[str] = None
|
|
97
|
+
|
|
98
|
+
# disable openapi schema generation
|
|
99
|
+
disable_schema_generation: bool = False
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
cors_origins = [
|
|
103
|
+
"http://mirix.localhost",
|
|
104
|
+
"http://localhost:8283",
|
|
105
|
+
"http://localhost:8083",
|
|
106
|
+
"http://localhost:3000",
|
|
107
|
+
"http://localhost:4200",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
# read pg_uri from ~/.mirix/pg_uri or set to none, this is to support Mirix Desktop
|
|
111
|
+
default_pg_uri = None
|
|
112
|
+
|
|
113
|
+
## check if --use-file-pg-uri is passed
|
|
114
|
+
if "--use-file-pg-uri" in sys.argv:
|
|
115
|
+
try:
|
|
116
|
+
with open(Path.home() / ".mirix/pg_uri", "r") as f:
|
|
117
|
+
default_pg_uri = f.read()
|
|
118
|
+
# Note: Using print instead of logger to avoid circular import with mirix.log
|
|
119
|
+
print("Read pg_uri from ~/.mirix/pg_uri")
|
|
120
|
+
except FileNotFoundError:
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class Settings(BaseSettings):
|
|
125
|
+
model_config = SettingsConfigDict(env_prefix="mirix_", extra="ignore")
|
|
126
|
+
|
|
127
|
+
mirix_dir: Optional[Path] = Field(Path.home() / ".mirix", env="MIRIX_DIR")
|
|
128
|
+
# Directory where uploaded/processed images are stored
|
|
129
|
+
# Can be overridden with MIRIX_IMAGES_DIR environment variable
|
|
130
|
+
images_dir: Optional[Path] = Field(
|
|
131
|
+
Path.home() / ".mirix" / "images", env="MIRIX_IMAGES_DIR"
|
|
132
|
+
)
|
|
133
|
+
debug: Optional[bool] = False
|
|
134
|
+
cors_origins: Optional[list] = cors_origins
|
|
135
|
+
|
|
136
|
+
# database configuration
|
|
137
|
+
pg_db: Optional[str] = None
|
|
138
|
+
pg_user: Optional[str] = None
|
|
139
|
+
pg_password: Optional[str] = None
|
|
140
|
+
pg_host: Optional[str] = None
|
|
141
|
+
pg_port: Optional[int] = None
|
|
142
|
+
pg_uri: Optional[str] = Field(
|
|
143
|
+
default_pg_uri, env="MIRIX_PG_URI"
|
|
144
|
+
) # option to specify full uri
|
|
145
|
+
pg_pool_size: int = 80 # Concurrent connections
|
|
146
|
+
pg_max_overflow: int = 30 # Overflow limit
|
|
147
|
+
pg_pool_timeout: int = 30 # Seconds to wait for a connection
|
|
148
|
+
pg_pool_recycle: int = 1800 # When to recycle connections
|
|
149
|
+
pg_echo: bool = False # Logging
|
|
150
|
+
|
|
151
|
+
# Redis configuration (optional - for caching and search acceleration)
|
|
152
|
+
redis_enabled: bool = Field(False, env="MIRIX_REDIS_ENABLED") # Master switch
|
|
153
|
+
redis_host: Optional[str] = Field(None, env="MIRIX_REDIS_HOST")
|
|
154
|
+
redis_port: int = Field(6379, env="MIRIX_REDIS_PORT")
|
|
155
|
+
redis_db: int = Field(0, env="MIRIX_REDIS_DB")
|
|
156
|
+
redis_password: Optional[str] = Field(None, env="MIRIX_REDIS_PASSWORD")
|
|
157
|
+
redis_uri: Optional[str] = Field(None, env="MIRIX_REDIS_URI") # Full URI override
|
|
158
|
+
|
|
159
|
+
# Redis connection pool settings (optimized for production)
|
|
160
|
+
redis_max_connections: int = Field(50, env="MIRIX_REDIS_MAX_CONNECTIONS") # Per container
|
|
161
|
+
redis_socket_timeout: int = Field(5, env="MIRIX_REDIS_SOCKET_TIMEOUT") # Read/write timeout (seconds)
|
|
162
|
+
redis_socket_connect_timeout: int = Field(5, env="MIRIX_REDIS_SOCKET_CONNECT_TIMEOUT") # Connect timeout (seconds)
|
|
163
|
+
redis_socket_keepalive: bool = Field(True, env="MIRIX_REDIS_SOCKET_KEEPALIVE") # Enable TCP keepalive
|
|
164
|
+
redis_retry_on_timeout: bool = Field(True, env="MIRIX_REDIS_RETRY_ON_TIMEOUT") # Retry on timeout errors
|
|
165
|
+
|
|
166
|
+
# Redis TTL settings (cache expiration times in seconds)
|
|
167
|
+
redis_ttl_default: int = Field(3600, env="MIRIX_REDIS_TTL_DEFAULT") # 1 hour default TTL
|
|
168
|
+
redis_ttl_blocks: int = Field(7200, env="MIRIX_REDIS_TTL_BLOCKS") # 2 hours for hot data (blocks)
|
|
169
|
+
redis_ttl_messages: int = Field(7200, env="MIRIX_REDIS_TTL_MESSAGES") # 2 hours for messages
|
|
170
|
+
redis_ttl_organizations: int = Field(43200, env="MIRIX_REDIS_TTL_ORGANIZATIONS") # 12 hours for organizations
|
|
171
|
+
redis_ttl_users: int = Field(43200, env="MIRIX_REDIS_TTL_USERS") # 12 hours for users
|
|
172
|
+
redis_ttl_agents: int = Field(43200, env="MIRIX_REDIS_TTL_AGENTS") # 12 hours for agents
|
|
173
|
+
redis_ttl_tools: int = Field(43200, env="MIRIX_REDIS_TTL_TOOLS") # 12 hours for tools
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def mirix_redis_uri(self) -> Optional[str]:
|
|
177
|
+
"""Construct Redis URI from components or return explicit URI."""
|
|
178
|
+
if not self.redis_enabled:
|
|
179
|
+
return None
|
|
180
|
+
|
|
181
|
+
if self.redis_uri:
|
|
182
|
+
return self.redis_uri
|
|
183
|
+
elif self.redis_host:
|
|
184
|
+
auth = f":{self.redis_password}@" if self.redis_password else ""
|
|
185
|
+
return f"redis://{auth}{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
|
186
|
+
else:
|
|
187
|
+
return None
|
|
188
|
+
|
|
189
|
+
# multi agent settings
|
|
190
|
+
multi_agent_send_message_max_retries: int = 3
|
|
191
|
+
multi_agent_send_message_timeout: int = 20 * 60
|
|
192
|
+
multi_agent_concurrent_sends: int = 50
|
|
193
|
+
|
|
194
|
+
# telemetry logging
|
|
195
|
+
verbose_telemetry_logging: bool = False
|
|
196
|
+
otel_exporter_otlp_endpoint: Optional[str] = (
|
|
197
|
+
None # otel default: "http://localhost:4317"
|
|
198
|
+
)
|
|
199
|
+
disable_tracing: bool = False
|
|
200
|
+
|
|
201
|
+
# uvicorn settings
|
|
202
|
+
uvicorn_workers: int = 1
|
|
203
|
+
uvicorn_reload: bool = False
|
|
204
|
+
uvicorn_timeout_keep_alive: int = 5
|
|
205
|
+
|
|
206
|
+
# event loop parallelism
|
|
207
|
+
event_loop_threadpool_max_workers: int = 43
|
|
208
|
+
|
|
209
|
+
# experimental toggle
|
|
210
|
+
use_experimental: bool = False
|
|
211
|
+
|
|
212
|
+
# logging configuration
|
|
213
|
+
log_level: str = Field("INFO", env="MIRIX_LOG_LEVEL")
|
|
214
|
+
log_file: Optional[Path] = Field(None, env="MIRIX_LOG_FILE") # If set, enables file logging
|
|
215
|
+
log_to_console: bool = Field(True, env="MIRIX_LOG_TO_CONSOLE") # Console logging is default
|
|
216
|
+
log_max_bytes: int = Field(10 * 1024 * 1024, env="MIRIX_LOG_MAX_BYTES") # 10 MB
|
|
217
|
+
log_backup_count: int = Field(5, env="MIRIX_LOG_BACKUP_COUNT")
|
|
218
|
+
|
|
219
|
+
# LLM provider client settings
|
|
220
|
+
httpx_max_retries: int = 5
|
|
221
|
+
httpx_timeout_connect: float = 10.0
|
|
222
|
+
httpx_timeout_read: float = 60.0
|
|
223
|
+
httpx_timeout_write: float = 30.0
|
|
224
|
+
httpx_timeout_pool: float = 10.0
|
|
225
|
+
httpx_max_connections: int = 500
|
|
226
|
+
httpx_max_keepalive_connections: int = 500
|
|
227
|
+
httpx_keepalive_expiry: float = 120.0
|
|
228
|
+
|
|
229
|
+
# cron job parameters
|
|
230
|
+
enable_batch_job_polling: bool = False
|
|
231
|
+
poll_running_llm_batches_interval_seconds: int = 5 * 60
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def mirix_pg_uri(self) -> str:
|
|
235
|
+
if self.pg_uri:
|
|
236
|
+
return self.pg_uri
|
|
237
|
+
elif (
|
|
238
|
+
self.pg_db
|
|
239
|
+
and self.pg_user
|
|
240
|
+
and self.pg_password
|
|
241
|
+
and self.pg_host
|
|
242
|
+
and self.pg_port
|
|
243
|
+
):
|
|
244
|
+
return f"postgresql+pg8000://{self.pg_user}:{self.pg_password}@{self.pg_host}:{self.pg_port}/{self.pg_db}"
|
|
245
|
+
else:
|
|
246
|
+
return "postgresql+pg8000://mirix:mirix@localhost:5432/mirix"
|
|
247
|
+
|
|
248
|
+
# add this property to avoid being returned the default
|
|
249
|
+
# reference: https://github.com/mirix-ai/mirix/issues/1362
|
|
250
|
+
@property
|
|
251
|
+
def mirix_pg_uri_no_default(self) -> str:
|
|
252
|
+
if self.pg_uri:
|
|
253
|
+
return self.pg_uri
|
|
254
|
+
elif (
|
|
255
|
+
self.pg_db
|
|
256
|
+
and self.pg_user
|
|
257
|
+
and self.pg_password
|
|
258
|
+
and self.pg_host
|
|
259
|
+
and self.pg_port
|
|
260
|
+
):
|
|
261
|
+
return f"postgresql+pg8000://{self.pg_user}:{self.pg_password}@{self.pg_host}:{self.pg_port}/{self.pg_db}"
|
|
262
|
+
else:
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class TestSettings(Settings):
|
|
267
|
+
model_config = SettingsConfigDict(env_prefix="mirix_test_", extra="ignore")
|
|
268
|
+
|
|
269
|
+
mirix_dir: Optional[Path] = Field(Path.home() / ".mirix/test", env="MIRIX_TEST_DIR")
|
|
270
|
+
images_dir: Optional[Path] = Field(
|
|
271
|
+
Path.home() / ".mirix/test" / "images", env="MIRIX_TEST_IMAGES_DIR"
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# singleton
|
|
276
|
+
settings = Settings(_env_parse_none_str="None")
|
|
277
|
+
test_settings = TestSettings()
|
|
278
|
+
model_settings = ModelSettings()
|
|
279
|
+
tool_settings = ToolSettings()
|
|
280
|
+
summarizer_settings = SummarizerSettings()
|
mirix/system.py
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import uuid
|
|
3
|
+
import warnings
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from .constants import (
|
|
7
|
+
INITIAL_BOOT_MESSAGE,
|
|
8
|
+
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG,
|
|
9
|
+
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,
|
|
10
|
+
MESSAGE_SUMMARY_WARNING_STR,
|
|
11
|
+
)
|
|
12
|
+
from .helpers.datetime_helpers import get_local_time
|
|
13
|
+
from .helpers.json_helpers import json_dumps
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_initial_boot_messages(version="startup"):
|
|
17
|
+
if version == "startup":
|
|
18
|
+
initial_boot_message = INITIAL_BOOT_MESSAGE
|
|
19
|
+
messages = [
|
|
20
|
+
{"role": "assistant", "content": initial_boot_message},
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
elif version == "startup_with_send_message":
|
|
24
|
+
tool_call_id = str(uuid.uuid4())
|
|
25
|
+
messages = [
|
|
26
|
+
# first message includes both inner monologue and function call to send_message
|
|
27
|
+
{
|
|
28
|
+
"role": "assistant",
|
|
29
|
+
"content": INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,
|
|
30
|
+
# "function_call": {
|
|
31
|
+
# "name": "send_message",
|
|
32
|
+
# "arguments": '{\n "message": "' + f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}" + '"\n}',
|
|
33
|
+
# },
|
|
34
|
+
"tool_calls": [
|
|
35
|
+
{
|
|
36
|
+
"id": tool_call_id,
|
|
37
|
+
"type": "function",
|
|
38
|
+
"function": {
|
|
39
|
+
"name": "send_message",
|
|
40
|
+
"arguments": '{\n "message": "'
|
|
41
|
+
+ f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}"
|
|
42
|
+
+ '"\n}',
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
# obligatory function return message
|
|
48
|
+
{
|
|
49
|
+
# "role": "function",
|
|
50
|
+
"role": "tool",
|
|
51
|
+
"name": "send_message", # NOTE: technically not up to spec, this is old functions style
|
|
52
|
+
"content": package_function_response(True, None),
|
|
53
|
+
"tool_call_id": tool_call_id,
|
|
54
|
+
},
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
elif version == "startup_with_send_message_gpt35":
|
|
58
|
+
tool_call_id = str(uuid.uuid4())
|
|
59
|
+
messages = [
|
|
60
|
+
# first message includes both inner monologue and function call to send_message
|
|
61
|
+
{
|
|
62
|
+
"role": "assistant",
|
|
63
|
+
"content": "*inner thoughts* Still waiting on the user. Sending a message with function.",
|
|
64
|
+
# "function_call": {"name": "send_message", "arguments": '{\n "message": "' + f"Hi, is anyone there?" + '"\n}'},
|
|
65
|
+
"tool_calls": [
|
|
66
|
+
{
|
|
67
|
+
"id": tool_call_id,
|
|
68
|
+
"type": "function",
|
|
69
|
+
"function": {
|
|
70
|
+
"name": "send_message",
|
|
71
|
+
"arguments": '{\n "message": "'
|
|
72
|
+
+ "Hi, is anyone there?"
|
|
73
|
+
+ '"\n}',
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
# obligatory function return message
|
|
79
|
+
{
|
|
80
|
+
# "role": "function",
|
|
81
|
+
"role": "tool",
|
|
82
|
+
"name": "send_message",
|
|
83
|
+
"content": package_function_response(True, None),
|
|
84
|
+
"tool_call_id": tool_call_id,
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
else:
|
|
89
|
+
raise ValueError(version)
|
|
90
|
+
|
|
91
|
+
return messages
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_contine_chaining(
|
|
95
|
+
reason="Automated timer",
|
|
96
|
+
include_location=False,
|
|
97
|
+
location_name="San Francisco, CA, USA",
|
|
98
|
+
):
|
|
99
|
+
# Package the message with time and location
|
|
100
|
+
formatted_time = get_local_time()
|
|
101
|
+
packaged_message = {
|
|
102
|
+
"type": "contine_chaining",
|
|
103
|
+
"reason": reason,
|
|
104
|
+
"time": formatted_time,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if include_location:
|
|
108
|
+
packaged_message["location"] = location_name
|
|
109
|
+
|
|
110
|
+
return json_dumps(packaged_message)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def get_login_event(
|
|
114
|
+
last_login="Never (first login)",
|
|
115
|
+
include_location=False,
|
|
116
|
+
location_name="San Francisco, CA, USA",
|
|
117
|
+
):
|
|
118
|
+
# Package the message with time and location
|
|
119
|
+
formatted_time = get_local_time()
|
|
120
|
+
packaged_message = {
|
|
121
|
+
"type": "login",
|
|
122
|
+
"last_login": last_login,
|
|
123
|
+
"time": formatted_time,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if include_location:
|
|
127
|
+
packaged_message["location"] = location_name
|
|
128
|
+
|
|
129
|
+
return json_dumps(packaged_message)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def package_user_message(
|
|
133
|
+
user_message: str,
|
|
134
|
+
time: Optional[str] = None,
|
|
135
|
+
include_location: bool = False,
|
|
136
|
+
location_name: Optional[str] = "San Francisco, CA, USA",
|
|
137
|
+
name: Optional[str] = None,
|
|
138
|
+
):
|
|
139
|
+
# Package the message with time and location
|
|
140
|
+
formatted_time = time if time else get_local_time()
|
|
141
|
+
packaged_message = {
|
|
142
|
+
"type": "user_message",
|
|
143
|
+
"message": user_message,
|
|
144
|
+
"time": formatted_time,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if include_location:
|
|
148
|
+
packaged_message["location"] = location_name
|
|
149
|
+
|
|
150
|
+
if name:
|
|
151
|
+
packaged_message["name"] = name
|
|
152
|
+
|
|
153
|
+
return json_dumps(packaged_message)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def package_function_response(was_success, response_string, timestamp=None):
|
|
157
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
158
|
+
packaged_message = {
|
|
159
|
+
"status": "OK" if was_success else "Failed",
|
|
160
|
+
"message": response_string,
|
|
161
|
+
"time": formatted_time,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return json_dumps(packaged_message)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def package_system_message(system_message, message_type="system_alert", time=None):
|
|
168
|
+
formatted_time = time if time else get_local_time()
|
|
169
|
+
packaged_message = {
|
|
170
|
+
"type": message_type,
|
|
171
|
+
"message": system_message,
|
|
172
|
+
"time": formatted_time,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return json.dumps(packaged_message)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def package_summarize_message(
|
|
179
|
+
summary,
|
|
180
|
+
summary_message_count,
|
|
181
|
+
hidden_message_count,
|
|
182
|
+
total_message_count,
|
|
183
|
+
timestamp=None,
|
|
184
|
+
):
|
|
185
|
+
context_message = (
|
|
186
|
+
f"Note: prior messages ({hidden_message_count} of {total_message_count} total messages) have been hidden from view due to conversation memory constraints.\n"
|
|
187
|
+
+ f"The following is a summary of the previous {summary_message_count} messages:\n {summary}"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
191
|
+
packaged_message = {
|
|
192
|
+
"type": "system_alert",
|
|
193
|
+
"message": context_message,
|
|
194
|
+
"time": formatted_time,
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return json_dumps(packaged_message)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def package_summarize_message_no_summary(
|
|
201
|
+
hidden_message_count, timestamp=None, message=None
|
|
202
|
+
):
|
|
203
|
+
"""Add useful metadata to the summary message"""
|
|
204
|
+
|
|
205
|
+
# Package the message with time and location
|
|
206
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
207
|
+
context_message = (
|
|
208
|
+
message
|
|
209
|
+
if message
|
|
210
|
+
else f"Note: {hidden_message_count} prior messages with the user have been hidden from view due to conversation memory constraints. Older messages are stored in Recall Memory and can be viewed using functions."
|
|
211
|
+
)
|
|
212
|
+
packaged_message = {
|
|
213
|
+
"type": "system_alert",
|
|
214
|
+
"message": context_message,
|
|
215
|
+
"time": formatted_time,
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return json_dumps(packaged_message)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def get_token_limit_warning():
|
|
222
|
+
formatted_time = get_local_time()
|
|
223
|
+
packaged_message = {
|
|
224
|
+
"type": "system_alert",
|
|
225
|
+
"message": MESSAGE_SUMMARY_WARNING_STR,
|
|
226
|
+
"time": formatted_time,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return json_dumps(packaged_message)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def unpack_message(packed_message) -> str:
|
|
233
|
+
"""Take a packed message string and attempt to extract the inner message content"""
|
|
234
|
+
|
|
235
|
+
try:
|
|
236
|
+
message_json = json.loads(packed_message)
|
|
237
|
+
except (ValueError, TypeError):
|
|
238
|
+
warnings.warn(
|
|
239
|
+
f"Was unable to load message as JSON to unpack: '{packed_message}'"
|
|
240
|
+
)
|
|
241
|
+
return packed_message
|
|
242
|
+
|
|
243
|
+
if "message" not in message_json:
|
|
244
|
+
if "type" in message_json and message_json["type"] in [
|
|
245
|
+
"login",
|
|
246
|
+
"contine_chaining",
|
|
247
|
+
]:
|
|
248
|
+
# This is a valid user message that the ADE expects, so don't print warning
|
|
249
|
+
return packed_message
|
|
250
|
+
warnings.warn(
|
|
251
|
+
f"Was unable to find 'message' field in packed message object: '{packed_message}'"
|
|
252
|
+
)
|
|
253
|
+
return packed_message
|
|
254
|
+
else:
|
|
255
|
+
message_type = message_json["type"]
|
|
256
|
+
if message_type != "user_message":
|
|
257
|
+
warnings.warn(
|
|
258
|
+
f"Expected type to be 'user_message', but was '{message_type}', so not unpacking: '{packed_message}'"
|
|
259
|
+
)
|
|
260
|
+
return packed_message
|
|
261
|
+
return message_json.get("message")
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
jl_ecms_client-0.2.7.dist-info/licenses/LICENSE,sha256=8fOrt8t-9Lb_RKUa_xmj1_bVzbbluGEXERWSfM7rXfY,10758
|
|
2
|
-
mirix/client/__init__.py,sha256=QOjO6HJdl5CBK9QrSvAILmlCWfoobt8CNBnRWsoZFBs,2383
|
|
3
|
-
mirix/client/client.py,sha256=9RK7BP5Fjonn5wKfUK5WK2fZS5--1mtdbmO50gQmdNs,88727
|
|
4
|
-
mirix/client/constants.py,sha256=6NVFu3yZqm1HW6vKA1HCpNc8l-ds6yGPyUGf-tqXJ78,2011
|
|
5
|
-
mirix/client/remote_client.py,sha256=P0sTbGlqeuT_cIvGh243NK1Uf4a2JgNkQLdLvN950HQ,42646
|
|
6
|
-
mirix/client/utils.py,sha256=xPAvR3slBQ5srOFLtYTqpL3PeD5n0YsxBRR1sLgKBdY,786
|
|
7
|
-
mirix/helpers/__init__.py,sha256=2QXDAywb0wF3JNLC7GgMDJb_kQpwvlb6ZCnjuLmOfPw,78
|
|
8
|
-
mirix/helpers/converters.py,sha256=WuYkra4c9-JRC2lRo7LmmFMH42qf3k6ox3OGOYlDQLk,13504
|
|
9
|
-
mirix/helpers/datetime_helpers.py,sha256=7U5ZJkE0cLki4sG8ukIHZSAoFfQpLWQu2kFekETy6Zg,2633
|
|
10
|
-
mirix/helpers/json_helpers.py,sha256=2iq1Lyxa8Ofes38QHAOBZHE7I2jS65h-zkAXWJzpm3k,1222
|
|
11
|
-
mirix/helpers/message_helpers.py,sha256=xOn2Uwx5XK4C1ahYKmFe9ak7QjE5vcPVuZBcLDYxkZA,2571
|
|
12
|
-
mirix/helpers/tool_rule_solver.py,sha256=LM9YuugmYtxxtcrD7GakbCNvmnuLK4Zp5KV8vA-UNSA,6542
|
|
13
|
-
mirix/schemas/__init__.py,sha256=HPrtil4I9_KC2u6eJZpBJ2dbl_YxOj_ZeYnKYq3RSGM,24
|
|
14
|
-
mirix/schemas/agent.py,sha256=SYiLURW1PYAHSXAaBOx8N8kaP_5Qt7ujWVxf2uA4BDM,15854
|
|
15
|
-
mirix/schemas/block.py,sha256=NhqaSCOHKACHb77F77NhET-Sy8bZqSJJnenQaC7pBR4,5145
|
|
16
|
-
mirix/schemas/cloud_file_mapping.py,sha256=i_5N41hNt0rEl-fvnGoPggLMbFdEk97wI71qQTjHKIg,977
|
|
17
|
-
mirix/schemas/embedding_config.py,sha256=aHySSdkn5BeL_i6UQLuyDmjo40FCWvKW1Yfc01hQYak,4050
|
|
18
|
-
mirix/schemas/enums.py,sha256=7Z4Wotyndp_eghhIvSdjFA3nMp_Vh_pcK1A_MrkBFRA,1357
|
|
19
|
-
mirix/schemas/environment_variables.py,sha256=mSL5U2NYxJHO4fb2dF3YgPyINgYgelsSzMqQ6nsjzng,2573
|
|
20
|
-
mirix/schemas/episodic_memory.py,sha256=KXr1hHXEqceF5wjMDpAN6MMkRthY-GBnFUcW_QDYUTg,6330
|
|
21
|
-
mirix/schemas/file.py,sha256=J92aWus84jPoF71wRtKIvoAPSdIDt4McEM6yDWzHiqg,2064
|
|
22
|
-
mirix/schemas/health.py,sha256=zT6mYovvD17iJRuu2rcaQQzbEEYrkwvAE9TB7iU824c,139
|
|
23
|
-
mirix/schemas/knowledge_vault.py,sha256=i9qOXp7D8tOgjpRlThDIBDBB4TvOtO7fpSCgaLZW3Lg,6316
|
|
24
|
-
mirix/schemas/llm_config.py,sha256=ZTJtqlD-J8wsEx4_aAMbqHaL0vxDrDjsgwD5RK07zcs,7256
|
|
25
|
-
mirix/schemas/memory.py,sha256=ORWX_qxQBirsHN9vTlr3d_UYLiUB9tlP8DnIh_obIfA,11991
|
|
26
|
-
mirix/schemas/message.py,sha256=_alOnt4BjdBw92Etg_i4vUhcWwdvD-54r5yuuydPBkc,53990
|
|
27
|
-
mirix/schemas/mirix_base.py,sha256=DMkOMZw1mw8Vte8yCGK9xAhqgY2O2CO6uYD9pgf9e6A,3859
|
|
28
|
-
mirix/schemas/mirix_message.py,sha256=WQHdA1dhLiwh0I3y710JMZx42fFmFkXBKdQdl1XdiDY,15334
|
|
29
|
-
mirix/schemas/mirix_message_content.py,sha256=xdgTM5AkkONe4mjgcZNuKkbKk_fEY4rqzobD7cvy5cA,6815
|
|
30
|
-
mirix/schemas/mirix_request.py,sha256=A2CwbKaIQcc1KchT0U3Ro82mBe6RerpDPFguDN_JFCo,1399
|
|
31
|
-
mirix/schemas/mirix_response.py,sha256=w_hTYJs_cpBdx1mWfezzbiV49U4MWHKEfwFrYSMAVR0,7444
|
|
32
|
-
mirix/schemas/organization.py,sha256=tHjE4CmboPJV8OMZ1BfGuFanMJKCED5rh1IBpNQhGTc,1120
|
|
33
|
-
mirix/schemas/procedural_memory.py,sha256=XdX0tfX3LLRXngEP7c3Y2A6KEx7b9dY_ADKOrCdSqQg,5509
|
|
34
|
-
mirix/schemas/providers.py,sha256=PNXCRGw2UqAwNgk3y2xqXa9bbH9ySVInLeU8qftTca4,30552
|
|
35
|
-
mirix/schemas/resource_memory.py,sha256=0w6tRynshimSviPd7fkXG77KqCxEBeuHsnjpYXILTVQ,4907
|
|
36
|
-
mirix/schemas/sandbox_config.py,sha256=X89bm-6QCE7n-ugQ7GyNfan6ZxKXU1UOwdWP0_PXnc4,4460
|
|
37
|
-
mirix/schemas/semantic_memory.py,sha256=vpDs9X1h6BRaAWnGkF0Il6oiYqosbmxahFh1OFb8WA0,5993
|
|
38
|
-
mirix/schemas/source.py,sha256=9Qe-E15sDXcopd3UPW0-sC3lFHIjlV44t_lV7KxkCWY,3050
|
|
39
|
-
mirix/schemas/step.py,sha256=msWn5uBdaR3dYmjTuCwmvq3Mm-kP0Ha8e3-2sfCvG1Y,1826
|
|
40
|
-
mirix/schemas/tool.py,sha256=ypkDYr8dikfyUU7tgnEF-CCam97TYYbTtaJ3K6PTebg,10487
|
|
41
|
-
mirix/schemas/tool_rule.py,sha256=uwyrOX38Vtp-6V1CbHnvBI3DzmWpW2zy7UPtYPmewus,6877
|
|
42
|
-
mirix/schemas/usage.py,sha256=QX7uIaK7-GgrZDMgeot-1ae2n-ol0yif3E7JsLF0Sxk,1166
|
|
43
|
-
mirix/schemas/user.py,sha256=9ywAkPX__q3Ja4lfs-YIiCKQkFmE3-poIimt0owGz_E,2476
|
|
44
|
-
mirix/schemas/openai/__init__.py,sha256=u3PhqJOMwv1fPfMOD6TNZ6zsWvEBpmur4Ypwj733UB0,24
|
|
45
|
-
mirix/schemas/openai/chat_completion_request.py,sha256=eC4fMMJRucHtXfCUVPZu7ZeSt_LUPAsZtu_Z-hzfW6c,3395
|
|
46
|
-
mirix/schemas/openai/chat_completion_response.py,sha256=1hF0Gaxvd03oBdKupz37qk_2LVFoev0T8GVEHHyVLfo,4054
|
|
47
|
-
mirix/schemas/openai/chat_completions.py,sha256=PfC4MOiADLW_BfgmUohqK033VB4IO5fLIR1416C1DCE,3616
|
|
48
|
-
mirix/schemas/openai/embedding_response.py,sha256=WKIZpXab1Av7v6sxKG8feW3ZtpQUNosmLVSuhXYa_xU,357
|
|
49
|
-
mirix/schemas/openai/openai.py,sha256=gXfYwdGRJ-co15zVKw3lua0iZL_lJBBo03XMWsw1uTI,8394
|
|
50
|
-
jl_ecms_client-0.2.7.dist-info/METADATA,sha256=T7mM1EjJebIwmHGR_8Ma5ln6dKEUfaY1fRsGOUPFO2Q,10843
|
|
51
|
-
jl_ecms_client-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
52
|
-
jl_ecms_client-0.2.7.dist-info/top_level.txt,sha256=hQ_Eh5KYzEGkhtEyWHdBYJ5iCom6_nlj0zQ6-v0WDIY,6
|
|
53
|
-
jl_ecms_client-0.2.7.dist-info/RECORD,,
|
mirix/client/constants.py
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|