@elizaos/python 2.0.0-alpha.11 → 2.0.0-alpha.27
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.
- package/elizaos/advanced_capabilities/__init__.py +6 -41
- package/elizaos/advanced_capabilities/actions/__init__.py +1 -21
- package/elizaos/advanced_capabilities/actions/add_contact.py +21 -11
- package/elizaos/advanced_capabilities/actions/follow_room.py +28 -28
- package/elizaos/advanced_capabilities/actions/image_generation.py +13 -26
- package/elizaos/advanced_capabilities/actions/mute_room.py +13 -26
- package/elizaos/advanced_capabilities/actions/remove_contact.py +16 -2
- package/elizaos/advanced_capabilities/actions/roles.py +13 -27
- package/elizaos/advanced_capabilities/actions/search_contacts.py +17 -3
- package/elizaos/advanced_capabilities/actions/send_message.py +317 -9
- package/elizaos/advanced_capabilities/actions/settings.py +16 -2
- package/elizaos/advanced_capabilities/actions/unfollow_room.py +13 -26
- package/elizaos/advanced_capabilities/actions/unmute_room.py +13 -26
- package/elizaos/advanced_capabilities/actions/update_contact.py +16 -2
- package/elizaos/advanced_capabilities/actions/update_entity.py +16 -2
- package/elizaos/advanced_capabilities/evaluators/__init__.py +2 -9
- package/elizaos/advanced_capabilities/evaluators/reflection.py +3 -132
- package/elizaos/advanced_capabilities/evaluators/relationship_extraction.py +5 -201
- package/elizaos/advanced_capabilities/providers/__init__.py +1 -12
- package/elizaos/advanced_capabilities/providers/knowledge.py +24 -3
- package/elizaos/advanced_capabilities/services/__init__.py +2 -9
- package/elizaos/advanced_memory/actions/reset_session.py +11 -0
- package/elizaos/advanced_memory/evaluators/reflection.py +134 -0
- package/elizaos/advanced_memory/evaluators/relationship_extraction.py +203 -0
- package/elizaos/advanced_memory/test_advanced_memory.py +357 -0
- package/elizaos/advanced_planning/actions/schedule_follow_up.py +222 -0
- package/elizaos/basic_capabilities/__init__.py +0 -2
- package/elizaos/basic_capabilities/providers/__init__.py +0 -3
- package/elizaos/basic_capabilities/providers/agent_settings.py +64 -0
- package/elizaos/basic_capabilities/providers/contacts.py +79 -0
- package/elizaos/basic_capabilities/providers/facts.py +87 -0
- package/elizaos/basic_capabilities/providers/follow_ups.py +117 -0
- package/elizaos/basic_capabilities/providers/knowledge.py +97 -0
- package/elizaos/basic_capabilities/providers/relationships.py +107 -0
- package/elizaos/basic_capabilities/providers/roles.py +96 -0
- package/elizaos/basic_capabilities/providers/settings.py +56 -0
- package/elizaos/bootstrap/autonomy/__init__.py +5 -1
- package/elizaos/bootstrap/autonomy/action.py +161 -0
- package/elizaos/bootstrap/autonomy/evaluators.py +217 -0
- package/elizaos/bootstrap/autonomy/service.py +8 -0
- package/elizaos/bootstrap/plugin.py +7 -0
- package/elizaos/bootstrap/providers/knowledge.py +26 -3
- package/elizaos/bootstrap/services/embedding.py +156 -1
- package/elizaos/runtime.py +63 -18
- package/elizaos/services/message_service.py +173 -23
- package/elizaos/types/generated/eliza/v1/agent_pb2.py +16 -16
- package/elizaos/types/generated/eliza/v1/agent_pb2.pyi +2 -4
- package/elizaos/types/model.py +27 -0
- package/elizaos/types/runtime.py +5 -1
- package/elizaos/utils/validation.py +76 -0
- package/package.json +2 -2
- package/tests/test_actions_provider_examples.py +58 -1
- package/tests/test_async_embedding.py +124 -0
- package/tests/test_autonomy.py +13 -2
- package/tests/test_validation.py +141 -0
- package/tests/verify_memory_architecture.py +192 -0
- package/elizaos/basic_capabilities/providers/capabilities.py +0 -62
package/elizaos/runtime.py
CHANGED
|
@@ -29,7 +29,7 @@ from elizaos.types.components import (
|
|
|
29
29
|
PreEvaluatorResult,
|
|
30
30
|
Provider,
|
|
31
31
|
)
|
|
32
|
-
from elizaos.types.database import AgentRunSummaryResult, IDatabaseAdapter, Log
|
|
32
|
+
from elizaos.types.database import AgentRunSummaryResult, IDatabaseAdapter, Log, MemorySearchOptions
|
|
33
33
|
from elizaos.types.environment import Entity, Room, World
|
|
34
34
|
from elizaos.types.events import EventType
|
|
35
35
|
from elizaos.types.memory import Memory
|
|
@@ -144,7 +144,7 @@ class AgentRuntime(IAgentRuntime):
|
|
|
144
144
|
conversation_length: int = 32,
|
|
145
145
|
log_level: str = "ERROR",
|
|
146
146
|
disable_basic_capabilities: bool = False,
|
|
147
|
-
|
|
147
|
+
advanced_capabilities: bool = False,
|
|
148
148
|
action_planning: bool | None = None,
|
|
149
149
|
llm_mode: LLMMode | None = None,
|
|
150
150
|
check_should_respond: bool | None = None,
|
|
@@ -163,7 +163,7 @@ class AgentRuntime(IAgentRuntime):
|
|
|
163
163
|
is_anonymous = True
|
|
164
164
|
|
|
165
165
|
self._capability_disable_basic = disable_basic_capabilities
|
|
166
|
-
self.
|
|
166
|
+
self._capability_advanced = advanced_capabilities
|
|
167
167
|
self._capability_enable_autonomy = enable_autonomy
|
|
168
168
|
self._is_anonymous_character = is_anonymous
|
|
169
169
|
self._action_planning_option = action_planning
|
|
@@ -340,8 +340,8 @@ class AgentRuntime(IAgentRuntime):
|
|
|
340
340
|
disable_basic = self._capability_disable_basic or (
|
|
341
341
|
char_settings.get("DISABLE_BASIC_CAPABILITIES") in (True, "true")
|
|
342
342
|
)
|
|
343
|
-
|
|
344
|
-
char_settings.get("
|
|
343
|
+
advanced_capabilities = self._capability_advanced or (
|
|
344
|
+
char_settings.get("ADVANCED_CAPABILITIES") in (True, "true")
|
|
345
345
|
)
|
|
346
346
|
skip_character_provider = self._is_anonymous_character
|
|
347
347
|
|
|
@@ -349,12 +349,12 @@ class AgentRuntime(IAgentRuntime):
|
|
|
349
349
|
char_settings.get("ENABLE_AUTONOMY") in (True, "true")
|
|
350
350
|
)
|
|
351
351
|
|
|
352
|
-
if disable_basic or
|
|
352
|
+
if disable_basic or advanced_capabilities or skip_character_provider or enable_autonomy:
|
|
353
353
|
from elizaos.bootstrap import CapabilityConfig, create_bootstrap_plugin
|
|
354
354
|
|
|
355
355
|
config = CapabilityConfig(
|
|
356
356
|
disable_basic=disable_basic,
|
|
357
|
-
|
|
357
|
+
advanced_capabilities=advanced_capabilities,
|
|
358
358
|
skip_character_provider=skip_character_provider,
|
|
359
359
|
enable_autonomy=enable_autonomy,
|
|
360
360
|
)
|
|
@@ -1136,12 +1136,17 @@ class AgentRuntime(IAgentRuntime):
|
|
|
1136
1136
|
include_list: list[str] | None = None,
|
|
1137
1137
|
only_include: bool = False,
|
|
1138
1138
|
skip_cache: bool = False,
|
|
1139
|
+
trajectory_phase: str | None = None,
|
|
1139
1140
|
) -> State:
|
|
1140
1141
|
# If we're running inside a trajectory step, always bypass the state cache
|
|
1141
1142
|
# so providers are executed and logged for training/benchmark traces.
|
|
1142
1143
|
traj_step_id: str | None = None
|
|
1143
1144
|
if message.metadata is not None:
|
|
1144
1145
|
maybe_step = getattr(message.metadata, "trajectoryStepId", None)
|
|
1146
|
+
if not maybe_step and hasattr(message.metadata, "message"):
|
|
1147
|
+
# Check nested MessageMetadata for parsing parity
|
|
1148
|
+
maybe_step = message.metadata.message.trajectory_step_id
|
|
1149
|
+
|
|
1145
1150
|
if isinstance(maybe_step, str) and maybe_step:
|
|
1146
1151
|
traj_step_id = maybe_step
|
|
1147
1152
|
skip_cache = True
|
|
@@ -1212,6 +1217,9 @@ class AgentRuntime(IAgentRuntime):
|
|
|
1212
1217
|
out[k] = _as_json_scalar(v)
|
|
1213
1218
|
return out
|
|
1214
1219
|
|
|
1220
|
+
# Resolve the purpose label for trajectory provider accesses
|
|
1221
|
+
traj_purpose = f"compose_state:{trajectory_phase}" if trajectory_phase else "compose_state"
|
|
1222
|
+
|
|
1215
1223
|
text_parts: list[str] = []
|
|
1216
1224
|
for provider in providers_to_run:
|
|
1217
1225
|
if provider.private:
|
|
@@ -1234,18 +1242,18 @@ class AgentRuntime(IAgentRuntime):
|
|
|
1234
1242
|
|
|
1235
1243
|
# Log provider access to trajectory service (if available)
|
|
1236
1244
|
if traj_step_id and traj_logger is not None:
|
|
1237
|
-
|
|
1238
|
-
|
|
1245
|
+
# Trajectory logging must never break core message flow.
|
|
1246
|
+
with contextlib.suppress(Exception):
|
|
1239
1247
|
traj_logger.log_provider_access(
|
|
1240
1248
|
step_id=traj_step_id,
|
|
1241
1249
|
provider_name=provider.name,
|
|
1242
|
-
data=
|
|
1243
|
-
|
|
1244
|
-
|
|
1250
|
+
data={
|
|
1251
|
+
"textLength": len(result.text) if result.text else 0,
|
|
1252
|
+
"hasValues": bool(result.values),
|
|
1253
|
+
"hasData": bool(result.data),
|
|
1254
|
+
},
|
|
1255
|
+
purpose=traj_purpose,
|
|
1245
1256
|
)
|
|
1246
|
-
except Exception:
|
|
1247
|
-
# Trajectory logging must never break core message flow.
|
|
1248
|
-
pass
|
|
1249
1257
|
|
|
1250
1258
|
state.text = "\n".join(text_parts)
|
|
1251
1259
|
# Match TypeScript behavior: expose providers text under {{providers}}.
|
|
@@ -1339,16 +1347,25 @@ class AgentRuntime(IAgentRuntime):
|
|
|
1339
1347
|
max_tokens_raw = params.get("maxTokens") if isinstance(params, dict) else None
|
|
1340
1348
|
max_tokens = int(max_tokens_raw) if isinstance(max_tokens_raw, int) else 0
|
|
1341
1349
|
|
|
1350
|
+
# Truncate embedding vectors to avoid bloating trajectory files
|
|
1351
|
+
result_str = str(result)
|
|
1352
|
+
is_embedding = "EMBEDDING" in str(effective_model_type).upper()
|
|
1353
|
+
if is_embedding and len(result_str) > 200:
|
|
1354
|
+
dim = result_str.count(",") + 1
|
|
1355
|
+
result_str = f"[embedding vector dim={dim}]"
|
|
1356
|
+
elif len(result_str) > 2000:
|
|
1357
|
+
result_str = result_str[:2000]
|
|
1358
|
+
|
|
1342
1359
|
traj_svc.log_llm_call( # type: ignore[call-arg]
|
|
1343
1360
|
step_id=step_id,
|
|
1344
1361
|
model=str(effective_model_type),
|
|
1345
1362
|
system_prompt=system_prompt,
|
|
1346
|
-
user_prompt=prompt,
|
|
1347
|
-
response=
|
|
1363
|
+
user_prompt=prompt[:2000] if prompt else "",
|
|
1364
|
+
response=result_str,
|
|
1348
1365
|
temperature=temperature,
|
|
1349
1366
|
max_tokens=max_tokens,
|
|
1350
1367
|
purpose="action",
|
|
1351
|
-
action_type="runtime.
|
|
1368
|
+
action_type="runtime.useModel",
|
|
1352
1369
|
latency_ms=max(0, end_ms - start_ms),
|
|
1353
1370
|
)
|
|
1354
1371
|
except Exception:
|
|
@@ -1727,6 +1744,12 @@ class AgentRuntime(IAgentRuntime):
|
|
|
1727
1744
|
if self._adapter:
|
|
1728
1745
|
await self._adapter.delete_component(component_id)
|
|
1729
1746
|
|
|
1747
|
+
async def search_memories(self, params: MemorySearchOptions) -> list[Memory]:
|
|
1748
|
+
"""Search memories by embedding."""
|
|
1749
|
+
if not self._adapter:
|
|
1750
|
+
raise RuntimeError("Database adapter not set")
|
|
1751
|
+
return await self._adapter.search_memories(params)
|
|
1752
|
+
|
|
1730
1753
|
async def get_memories(
|
|
1731
1754
|
self,
|
|
1732
1755
|
params: dict[str, Any] | None = None,
|
|
@@ -2381,6 +2404,28 @@ end code: {final_code}
|
|
|
2381
2404
|
# Flush extractor and get final state
|
|
2382
2405
|
extractor.flush()
|
|
2383
2406
|
response_str = "".join(response_parts)
|
|
2407
|
+
|
|
2408
|
+
# Log streaming response to trajectory (streaming bypasses use_model hook)
|
|
2409
|
+
try:
|
|
2410
|
+
from elizaos.trajectory_context import CURRENT_TRAJECTORY_STEP_ID
|
|
2411
|
+
|
|
2412
|
+
step_id = CURRENT_TRAJECTORY_STEP_ID.get()
|
|
2413
|
+
traj_svc = self.get_service("trajectory_logger")
|
|
2414
|
+
if step_id and traj_svc is not None and hasattr(traj_svc, "log_llm_call"):
|
|
2415
|
+
traj_svc.log_llm_call( # type: ignore[call-arg]
|
|
2416
|
+
step_id=step_id,
|
|
2417
|
+
model=stream_model_type,
|
|
2418
|
+
system_prompt="",
|
|
2419
|
+
user_prompt=str(params.get("prompt", ""))[:2000],
|
|
2420
|
+
response=response_str[:2000],
|
|
2421
|
+
temperature=0.0,
|
|
2422
|
+
max_tokens=int(params.get("maxTokens", 0)),
|
|
2423
|
+
purpose="action",
|
|
2424
|
+
action_type="dynamic_prompt_exec.stream",
|
|
2425
|
+
latency_ms=0,
|
|
2426
|
+
)
|
|
2427
|
+
except Exception:
|
|
2428
|
+
pass
|
|
2384
2429
|
else:
|
|
2385
2430
|
# Non-streaming mode: use use_model
|
|
2386
2431
|
response = await self.use_model(model_type_str, params)
|
|
@@ -262,7 +262,7 @@ def _parse_params_from_xml(xml_response: str) -> dict[str, list[dict[str, str]]]
|
|
|
262
262
|
if not params_content:
|
|
263
263
|
return result
|
|
264
264
|
|
|
265
|
-
# First try XML parsing of the inner params content
|
|
265
|
+
# First try strict XML parsing of the inner params content
|
|
266
266
|
try:
|
|
267
267
|
root = ET.fromstring(f"<params>{params_content}</params>")
|
|
268
268
|
for action_elem in list(root):
|
|
@@ -270,7 +270,8 @@ def _parse_params_from_xml(xml_response: str) -> dict[str, list[dict[str, str]]]
|
|
|
270
270
|
action_params: dict[str, str] = {}
|
|
271
271
|
|
|
272
272
|
for param_elem in list(action_elem):
|
|
273
|
-
|
|
273
|
+
# Use itertext() to capture ALL text including mixed content
|
|
274
|
+
value_text = "".join(param_elem.itertext()).strip()
|
|
274
275
|
action_params[param_elem.tag] = value_text
|
|
275
276
|
|
|
276
277
|
# If the action block contains text but no nested tags, try JSON-in-action.
|
|
@@ -283,35 +284,69 @@ def _parse_params_from_xml(xml_response: str) -> dict[str, list[dict[str, str]]]
|
|
|
283
284
|
for k, v in loaded.items():
|
|
284
285
|
action_params[str(k)] = str(v)
|
|
285
286
|
except json.JSONDecodeError:
|
|
286
|
-
|
|
287
|
+
pass # Fall through to regex fallback
|
|
287
288
|
|
|
288
289
|
if action_params:
|
|
289
290
|
result.setdefault(action_name, []).append(action_params)
|
|
290
291
|
|
|
291
|
-
|
|
292
|
+
if result:
|
|
293
|
+
return result
|
|
292
294
|
except ET.ParseError:
|
|
293
|
-
|
|
295
|
+
pass # Fall through to regex-based extraction
|
|
294
296
|
|
|
295
|
-
#
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
# Regex-based fallback for content that breaks XML parsing
|
|
298
|
+
# (e.g. C code with <stdio.h>, shell commands with < > &, etc.)
|
|
299
|
+
# Look for <ACTION_NAME>...<param>...</param>...</ACTION_NAME> patterns
|
|
300
|
+
action_block_pattern = re.compile(r"<([A-Z_]+)>(.*?)</\1>", re.DOTALL | re.IGNORECASE)
|
|
301
|
+
param_pattern = re.compile(r"<(\w+)>(.*?)</\1>", re.DOTALL)
|
|
298
302
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
for action_match in action_block_pattern.finditer(params_content):
|
|
304
|
+
action_name = action_match.group(1).upper()
|
|
305
|
+
action_body = action_match.group(2).strip()
|
|
306
|
+
action_params: dict[str, str] = {}
|
|
307
|
+
|
|
308
|
+
# Try JSON inside the action block first
|
|
309
|
+
if action_body.startswith("{"):
|
|
310
|
+
try:
|
|
311
|
+
loaded = json.loads(action_body)
|
|
312
|
+
if isinstance(loaded, dict):
|
|
313
|
+
for k, v in loaded.items():
|
|
314
|
+
action_params[str(k)] = str(v)
|
|
315
|
+
except json.JSONDecodeError:
|
|
316
|
+
pass
|
|
317
|
+
|
|
318
|
+
# Extract nested param tags via regex
|
|
319
|
+
if not action_params:
|
|
320
|
+
for param_match in param_pattern.finditer(action_body):
|
|
321
|
+
param_name = param_match.group(1)
|
|
322
|
+
param_value = param_match.group(2).strip()
|
|
323
|
+
# Skip if the param name looks like an action (all caps)
|
|
324
|
+
if param_name == param_name.upper() and len(param_name) > 2:
|
|
325
|
+
continue
|
|
326
|
+
action_params[param_name] = param_value
|
|
327
|
+
|
|
328
|
+
if action_params:
|
|
329
|
+
result.setdefault(action_name, []).append(action_params)
|
|
303
330
|
|
|
304
|
-
if
|
|
331
|
+
if result:
|
|
305
332
|
return result
|
|
306
333
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
334
|
+
# Fall back to JSON inside <params>...</params>
|
|
335
|
+
if params_content.startswith("{") or params_content.startswith("["):
|
|
336
|
+
try:
|
|
337
|
+
loaded_any = json.loads(params_content)
|
|
338
|
+
except json.JSONDecodeError:
|
|
339
|
+
return result
|
|
340
|
+
|
|
341
|
+
if isinstance(loaded_any, dict):
|
|
342
|
+
for action_name, action_params_raw in loaded_any.items():
|
|
343
|
+
if not isinstance(action_params_raw, dict):
|
|
344
|
+
continue
|
|
345
|
+
params_out: dict[str, str] = {}
|
|
346
|
+
for k, v in action_params_raw.items():
|
|
347
|
+
params_out[str(k)] = str(v)
|
|
348
|
+
if params_out:
|
|
349
|
+
result.setdefault(str(action_name).upper(), []).append(params_out)
|
|
315
350
|
|
|
316
351
|
return result
|
|
317
352
|
|
|
@@ -366,6 +401,9 @@ class DefaultMessageService(IMessageService):
|
|
|
366
401
|
traj_step_id: str | None = None
|
|
367
402
|
if message.metadata is not None:
|
|
368
403
|
maybe_step = getattr(message.metadata, "trajectoryStepId", None)
|
|
404
|
+
if not maybe_step and hasattr(message.metadata, "message"):
|
|
405
|
+
nested_meta = message.metadata.message
|
|
406
|
+
maybe_step = getattr(nested_meta, "trajectory_step_id", None)
|
|
369
407
|
if isinstance(maybe_step, str) and maybe_step:
|
|
370
408
|
traj_step_id = maybe_step
|
|
371
409
|
|
|
@@ -448,12 +486,13 @@ class DefaultMessageService(IMessageService):
|
|
|
448
486
|
existing_memory = await runtime.get_memory_by_id(message.id)
|
|
449
487
|
if not existing_memory:
|
|
450
488
|
await runtime.create_memory(message, "messages")
|
|
489
|
+
_spawn_embedding_generation(runtime, message)
|
|
451
490
|
except RuntimeError:
|
|
452
491
|
# No database adapter - skip persistence (benchmark mode)
|
|
453
492
|
runtime.logger.debug("No database adapter, skipping message persistence")
|
|
454
493
|
|
|
455
494
|
# Step 2: Compose state from providers
|
|
456
|
-
state = await runtime.compose_state(message)
|
|
495
|
+
state = await runtime.compose_state(message, trajectory_phase="generate")
|
|
457
496
|
|
|
458
497
|
# Optional: multi-step strategy (TypeScript parity)
|
|
459
498
|
use_multi_step = _parse_bool(runtime.get_setting("USE_MULTI_STEP"))
|
|
@@ -684,6 +723,9 @@ class DefaultMessageService(IMessageService):
|
|
|
684
723
|
},
|
|
685
724
|
)
|
|
686
725
|
|
|
726
|
+
# Spawn async embedding generation for response
|
|
727
|
+
_spawn_embedding_generation(runtime, response_memory)
|
|
728
|
+
|
|
687
729
|
responses = [response_memory]
|
|
688
730
|
|
|
689
731
|
# Step 7: Process actions via runtime.process_actions()
|
|
@@ -697,6 +739,20 @@ class DefaultMessageService(IMessageService):
|
|
|
697
739
|
# Simple chat-style response
|
|
698
740
|
await callback(response_content)
|
|
699
741
|
|
|
742
|
+
# Complete trajectory step with actual action data
|
|
743
|
+
if traj_step_id and traj_logger is not None:
|
|
744
|
+
try:
|
|
745
|
+
if hasattr(traj_logger, "complete_step_by_step_id"):
|
|
746
|
+
traj_logger.complete_step_by_step_id(
|
|
747
|
+
step_id=traj_step_id,
|
|
748
|
+
action_type=",".join(actions) if actions else "REPLY",
|
|
749
|
+
action_name=",".join(actions) if actions else "REPLY",
|
|
750
|
+
success=True,
|
|
751
|
+
reward=0.1,
|
|
752
|
+
)
|
|
753
|
+
except Exception as e:
|
|
754
|
+
runtime.logger.debug(f"Trajectory step completion failed: {e}")
|
|
755
|
+
|
|
700
756
|
# Step 8: Run evaluators via runtime.evaluate()
|
|
701
757
|
runtime.logger.debug("Running evaluators")
|
|
702
758
|
await runtime.evaluate(
|
|
@@ -722,6 +778,22 @@ class DefaultMessageService(IMessageService):
|
|
|
722
778
|
runtime.logger.error(
|
|
723
779
|
f"Error processing message: {e}\n{''.join(_tb.format_exception(e))}"
|
|
724
780
|
)
|
|
781
|
+
|
|
782
|
+
# Mark trajectory step as failed on error
|
|
783
|
+
if traj_step_id and traj_logger is not None:
|
|
784
|
+
try:
|
|
785
|
+
if hasattr(traj_logger, "complete_step_by_step_id"):
|
|
786
|
+
traj_logger.complete_step_by_step_id(
|
|
787
|
+
step_id=traj_step_id,
|
|
788
|
+
action_type="ERROR",
|
|
789
|
+
action_name="ERROR",
|
|
790
|
+
success=False,
|
|
791
|
+
reward=-0.1,
|
|
792
|
+
error=str(e)[:500],
|
|
793
|
+
)
|
|
794
|
+
except Exception:
|
|
795
|
+
pass
|
|
796
|
+
|
|
725
797
|
raise
|
|
726
798
|
finally:
|
|
727
799
|
CURRENT_TRAJECTORY_STEP_ID.reset(token)
|
|
@@ -829,6 +901,7 @@ class DefaultMessageService(IMessageService):
|
|
|
829
901
|
include_list=["RECENT_MESSAGES", "ACTION_STATE", "ACTIONS", "PROVIDERS"],
|
|
830
902
|
only_include=True,
|
|
831
903
|
skip_cache=True,
|
|
904
|
+
trajectory_phase="multi_step_iteration",
|
|
832
905
|
)
|
|
833
906
|
state.data.action_results = list(trace_results)
|
|
834
907
|
state.values["actionResults"] = _format_action_results(trace_results)
|
|
@@ -914,6 +987,7 @@ class DefaultMessageService(IMessageService):
|
|
|
914
987
|
include_list=providers,
|
|
915
988
|
only_include=True,
|
|
916
989
|
skip_cache=True,
|
|
990
|
+
trajectory_phase="multi_step_provider",
|
|
917
991
|
)
|
|
918
992
|
|
|
919
993
|
if action_name:
|
|
@@ -949,6 +1023,7 @@ class DefaultMessageService(IMessageService):
|
|
|
949
1023
|
include_list=["RECENT_MESSAGES", "ACTION_STATE", "ACTIONS", "PROVIDERS"],
|
|
950
1024
|
only_include=True,
|
|
951
1025
|
skip_cache=True,
|
|
1026
|
+
trajectory_phase="multi_step_summary",
|
|
952
1027
|
)
|
|
953
1028
|
state.data.action_results = list(trace_results)
|
|
954
1029
|
state.values["actionResults"] = _format_action_results(trace_results)
|
|
@@ -1172,7 +1247,7 @@ class DefaultMessageService(IMessageService):
|
|
|
1172
1247
|
await runtime.create_memory(message, "messages")
|
|
1173
1248
|
|
|
1174
1249
|
# Compose state from providers
|
|
1175
|
-
state = await runtime.compose_state(message)
|
|
1250
|
+
state = await runtime.compose_state(message, trajectory_phase="generate")
|
|
1176
1251
|
|
|
1177
1252
|
# Build the prompt using canonical template
|
|
1178
1253
|
from elizaos.prompts import MESSAGE_HANDLER_TEMPLATE
|
|
@@ -1242,3 +1317,78 @@ class DefaultMessageService(IMessageService):
|
|
|
1242
1317
|
StreamingMessageResult: Final result with metadata (yielded last)
|
|
1243
1318
|
"""
|
|
1244
1319
|
return self._handle_message_stream_impl(runtime, message)
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
def _spawn_embedding_generation(runtime: IAgentRuntime, memory: Memory) -> None:
|
|
1323
|
+
"""Spawn a background task to generate intent and embedding for a memory."""
|
|
1324
|
+
import asyncio
|
|
1325
|
+
|
|
1326
|
+
# Create a background task for embedding generation
|
|
1327
|
+
# We don't await it here so it doesn't block the main flow
|
|
1328
|
+
try:
|
|
1329
|
+
loop = asyncio.get_running_loop()
|
|
1330
|
+
loop.create_task(_generate_embedding_task(runtime, memory))
|
|
1331
|
+
except RuntimeError:
|
|
1332
|
+
# If no loop is running, we might be in a thread or startup.
|
|
1333
|
+
# Fallback to creating a new loop or skipping?
|
|
1334
|
+
# Standard asyncio usage implies a loop exists.
|
|
1335
|
+
pass
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
async def _generate_embedding_task(runtime: IAgentRuntime, memory: Memory) -> None:
|
|
1339
|
+
try:
|
|
1340
|
+
text = memory.content.text or ""
|
|
1341
|
+
if not text:
|
|
1342
|
+
return
|
|
1343
|
+
|
|
1344
|
+
# 1. Generate Intent (Augmented Query)
|
|
1345
|
+
intent_prompt = (
|
|
1346
|
+
"Analyze the following message and extract the core intent or meaning to be used as a search query for retrieval. "
|
|
1347
|
+
"Return ONLY the intent text, no explanation.\\n\\n"
|
|
1348
|
+
f"Message: {text}"
|
|
1349
|
+
)
|
|
1350
|
+
|
|
1351
|
+
intent = text
|
|
1352
|
+
try:
|
|
1353
|
+
# parsing logic handles string response
|
|
1354
|
+
intent_resp = await runtime.use_model(
|
|
1355
|
+
ModelType.TEXT_SMALL,
|
|
1356
|
+
{"prompt": intent_prompt, "maxTokens": 128, "temperature": 0.0},
|
|
1357
|
+
)
|
|
1358
|
+
if isinstance(intent_resp, str):
|
|
1359
|
+
intent = intent_resp.strip()
|
|
1360
|
+
except Exception as e:
|
|
1361
|
+
runtime.logger.debug(f"Failed to generate intent: {e}")
|
|
1362
|
+
|
|
1363
|
+
# Store intent in metadata
|
|
1364
|
+
if memory.metadata is None:
|
|
1365
|
+
from google.protobuf.struct_pb2 import Struct
|
|
1366
|
+
|
|
1367
|
+
memory.metadata = Struct()
|
|
1368
|
+
|
|
1369
|
+
# Handle both dict access (Python object) and struct access (Protobuf)
|
|
1370
|
+
if hasattr(memory.metadata, "update") and callable(memory.metadata.update):
|
|
1371
|
+
# For dict
|
|
1372
|
+
memory.metadata.update({"intent": intent})
|
|
1373
|
+
elif hasattr(memory.metadata, "__setitem__"):
|
|
1374
|
+
memory.metadata["intent"] = intent
|
|
1375
|
+
|
|
1376
|
+
# 2. Generate Embedding for Intent
|
|
1377
|
+
embedding_resp = await runtime.use_model(
|
|
1378
|
+
ModelType.TEXT_EMBEDDING, {"input": intent, "text": intent}
|
|
1379
|
+
)
|
|
1380
|
+
|
|
1381
|
+
embedding: list[float] | None = None
|
|
1382
|
+
if isinstance(embedding_resp, list):
|
|
1383
|
+
embedding = [float(x) for x in embedding_resp]
|
|
1384
|
+
|
|
1385
|
+
if embedding:
|
|
1386
|
+
memory.embedding = embedding
|
|
1387
|
+
|
|
1388
|
+
# 3. Update Memory in DB
|
|
1389
|
+
if runtime._adapter:
|
|
1390
|
+
await runtime.update_memory(memory)
|
|
1391
|
+
runtime.logger.debug(f"Generated intent and embedding for memory {memory.id}")
|
|
1392
|
+
|
|
1393
|
+
except Exception as e:
|
|
1394
|
+
runtime.logger.debug(f"Async embedding task failed for memory {memory.id}: {e}")
|
|
@@ -26,7 +26,7 @@ from eliza.v1 import primitives_pb2 as eliza_dot_v1_dot_primitives__pb2
|
|
|
26
26
|
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x65liza/v1/agent.proto\x12\x08\x65liza.v1\x1a\x19\x65liza/v1/primitives.proto\x1a\x1cgoogle/protobuf/struct.proto\"Q\n\x0eMessageExample\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12+\n\x07\x63ontent\x18\x02 \x01(\x0b\x32\x11.eliza.v1.ContentR\x07\x63ontent\"k\n\rKnowledgeItem\x12\x14\n\x04path\x18\x01 \x01(\tH\x00R\x04path\x12<\n\tdirectory\x18\x02 \x01(\x0b\x32\x1c.eliza.v1.KnowledgeDirectoryH\x00R\tdirectoryB\x06\n\x04item\"P\n\x12KnowledgeDirectory\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\x12\x1b\n\x06shared\x18\x02 \x01(\x08H\x00R\x06shared\x88\x01\x01\x42\t\n\x07_shared\"\
|
|
29
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x65liza/v1/agent.proto\x12\x08\x65liza.v1\x1a\x19\x65liza/v1/primitives.proto\x1a\x1cgoogle/protobuf/struct.proto\"Q\n\x0eMessageExample\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12+\n\x07\x63ontent\x18\x02 \x01(\x0b\x32\x11.eliza.v1.ContentR\x07\x63ontent\"k\n\rKnowledgeItem\x12\x14\n\x04path\x18\x01 \x01(\tH\x00R\x04path\x12<\n\tdirectory\x18\x02 \x01(\x0b\x32\x1c.eliza.v1.KnowledgeDirectoryH\x00R\tdirectoryB\x06\n\x04item\"P\n\x12KnowledgeDirectory\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\x12\x1b\n\x06shared\x18\x02 \x01(\x08H\x00R\x06shared\x88\x01\x01\x42\t\n\x07_shared\"\xed\t\n\x11\x43haracterSettings\x12\x35\n\x14should_respond_model\x18\x01 \x01(\tH\x00R\x12shouldRespondModel\x88\x01\x01\x12)\n\x0euse_multi_step\x18\x02 \x01(\x08H\x01R\x0cuseMultiStep\x88\x01\x01\x12=\n\x18max_multistep_iterations\x18\x03 \x01(\x05H\x02R\x16maxMultistepIterations\x88\x01\x01\x12\x34\n\x13\x62ootstrap_defllmoff\x18\x04 \x01(\x08H\x03R\x12\x62ootstrapDefllmoff\x88\x01\x01\x12\x33\n\x13\x62ootstrap_keep_resp\x18\x05 \x01(\x08H\x04R\x11\x62ootstrapKeepResp\x88\x01\x01\x12@\n\x1aproviders_total_timeout_ms\x18\x06 \x01(\x05H\x05R\x17providersTotalTimeoutMs\x88\x01\x01\x12@\n\x1amax_working_memory_entries\x18\x07 \x01(\x05H\x06R\x17maxWorkingMemoryEntries\x88\x01\x01\x12;\n\x17\x61lways_respond_channels\x18\x08 \x01(\tH\x07R\x15\x61lwaysRespondChannels\x88\x01\x01\x12\x39\n\x16\x61lways_respond_sources\x18\t \x01(\tH\x08R\x14\x61lwaysRespondSources\x88\x01\x01\x12\x34\n\x13\x64\x65\x66\x61ult_temperature\x18\n \x01(\x01H\tR\x12\x64\x65\x66\x61ultTemperature\x88\x01\x01\x12\x31\n\x12\x64\x65\x66\x61ult_max_tokens\x18\x0b \x01(\x05H\nR\x10\x64\x65\x66\x61ultMaxTokens\x88\x01\x01\x12?\n\x19\x64\x65\x66\x61ult_frequency_penalty\x18\x0c \x01(\x01H\x0bR\x17\x64\x65\x66\x61ultFrequencyPenalty\x88\x01\x01\x12=\n\x18\x64\x65\x66\x61ult_presence_penalty\x18\r \x01(\x01H\x0cR\x16\x64\x65\x66\x61ultPresencePenalty\x88\x01\x01\x12\x41\n\x1a\x64isable_basic_capabilities\x18\x0e \x01(\x08H\rR\x18\x64isableBasicCapabilities\x88\x01\x01\x12-\n\x05\x65xtra\x18\x10 \x01(\x0b\x32\x17.google.protobuf.StructR\x05\x65xtraB\x17\n\x15_should_respond_modelB\x11\n\x0f_use_multi_stepB\x1b\n\x19_max_multistep_iterationsB\x16\n\x14_bootstrap_defllmoffB\x16\n\x14_bootstrap_keep_respB\x1d\n\x1b_providers_total_timeout_msB\x1d\n\x1b_max_working_memory_entriesB\x1a\n\x18_always_respond_channelsB\x19\n\x17_always_respond_sourcesB\x16\n\x14_default_temperatureB\x15\n\x13_default_max_tokensB\x1c\n\x1a_default_frequency_penaltyB\x1b\n\x19_default_presence_penaltyB\x1d\n\x1b_disable_basic_capabilities\"G\n\x0bStyleGuides\x12\x10\n\x03\x61ll\x18\x01 \x03(\tR\x03\x61ll\x12\x12\n\x04\x63hat\x18\x02 \x03(\tR\x04\x63hat\x12\x12\n\x04post\x18\x03 \x03(\tR\x04post\"\xa4\x07\n\tCharacter\x12\x13\n\x02id\x18\x01 \x01(\tH\x00R\x02id\x88\x01\x01\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12\x1f\n\x08username\x18\x03 \x01(\tH\x01R\x08username\x88\x01\x01\x12\x1b\n\x06system\x18\x04 \x01(\tH\x02R\x06system\x88\x01\x01\x12@\n\ttemplates\x18\x05 \x03(\x0b\x32\".eliza.v1.Character.TemplatesEntryR\ttemplates\x12\x10\n\x03\x62io\x18\x06 \x03(\tR\x03\x62io\x12H\n\x10message_examples\x18\x07 \x03(\x0b\x32\x1d.eliza.v1.MessageExampleGroupR\x0fmessageExamples\x12#\n\rpost_examples\x18\x08 \x03(\tR\x0cpostExamples\x12\x16\n\x06topics\x18\t \x03(\tR\x06topics\x12\x1e\n\nadjectives\x18\n \x03(\tR\nadjectives\x12\x35\n\tknowledge\x18\x0b \x03(\x0b\x32\x17.eliza.v1.KnowledgeItemR\tknowledge\x12\x18\n\x07plugins\x18\x0c \x03(\tR\x07plugins\x12<\n\x08settings\x18\r \x01(\x0b\x32\x1b.eliza.v1.CharacterSettingsH\x03R\x08settings\x88\x01\x01\x12:\n\x07secrets\x18\x0e \x03(\x0b\x32 .eliza.v1.Character.SecretsEntryR\x07secrets\x12\x30\n\x05style\x18\x0f \x01(\x0b\x32\x15.eliza.v1.StyleGuidesH\x04R\x05style\x88\x01\x01\x12\x30\n\x11\x61\x64vanced_planning\x18\x10 \x01(\x08H\x05R\x10\x61\x64vancedPlanning\x88\x01\x01\x12,\n\x0f\x61\x64vanced_memory\x18\x11 \x01(\x08H\x06R\x0e\x61\x64vancedMemory\x88\x01\x01\x1a<\n\x0eTemplatesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\x1a:\n\x0cSecretsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\x42\x05\n\x03_idB\x0b\n\t_usernameB\t\n\x07_systemB\x0b\n\t_settingsB\x08\n\x06_styleB\x14\n\x12_advanced_planningB\x12\n\x10_advanced_memory\"K\n\x13MessageExampleGroup\x12\x34\n\x08\x65xamples\x18\x01 \x03(\x0b\x32\x18.eliza.v1.MessageExampleR\x08\x65xamples\"\xd2\x01\n\x05\x41gent\x12\x31\n\tcharacter\x18\x01 \x01(\x0b\x32\x13.eliza.v1.CharacterR\tcharacter\x12\x1d\n\x07\x65nabled\x18\x02 \x01(\x08H\x00R\x07\x65nabled\x88\x01\x01\x12-\n\x06status\x18\x03 \x01(\x0e\x32\x15.eliza.v1.AgentStatusR\x06status\x12\x1d\n\ncreated_at\x18\x04 \x01(\x03R\tcreatedAt\x12\x1d\n\nupdated_at\x18\x05 \x01(\x03R\tupdatedAtB\n\n\x08_enabled*_\n\x0b\x41gentStatus\x12\x1c\n\x18\x41GENT_STATUS_UNSPECIFIED\x10\x00\x12\x17\n\x13\x41GENT_STATUS_ACTIVE\x10\x01\x12\x19\n\x15\x41GENT_STATUS_INACTIVE\x10\x02\x42\x8d\x01\n\x0c\x63om.eliza.v1B\nAgentProtoP\x01Z0github.com/elizaos/eliza/gen/go/eliza/v1;elizav1\xa2\x02\x03\x45XX\xaa\x02\x08\x45liza.V1\xca\x02\x08\x45liza\\V1\xe2\x02\x14\x45liza\\V1\\GPBMetadata\xea\x02\tEliza::V1b\x06proto3')
|
|
30
30
|
|
|
31
31
|
_globals = globals()
|
|
32
32
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
@@ -38,8 +38,8 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
|
38
38
|
_globals['_CHARACTER_TEMPLATESENTRY']._serialized_options = b'8\001'
|
|
39
39
|
_globals['_CHARACTER_SECRETSENTRY']._loaded_options = None
|
|
40
40
|
_globals['_CHARACTER_SECRETSENTRY']._serialized_options = b'8\001'
|
|
41
|
-
_globals['_AGENTSTATUS']._serialized_start=
|
|
42
|
-
_globals['_AGENTSTATUS']._serialized_end=
|
|
41
|
+
_globals['_AGENTSTATUS']._serialized_start=2927
|
|
42
|
+
_globals['_AGENTSTATUS']._serialized_end=3022
|
|
43
43
|
_globals['_MESSAGEEXAMPLE']._serialized_start=91
|
|
44
44
|
_globals['_MESSAGEEXAMPLE']._serialized_end=172
|
|
45
45
|
_globals['_KNOWLEDGEITEM']._serialized_start=174
|
|
@@ -47,17 +47,17 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
|
47
47
|
_globals['_KNOWLEDGEDIRECTORY']._serialized_start=283
|
|
48
48
|
_globals['_KNOWLEDGEDIRECTORY']._serialized_end=363
|
|
49
49
|
_globals['_CHARACTERSETTINGS']._serialized_start=366
|
|
50
|
-
_globals['_CHARACTERSETTINGS']._serialized_end=
|
|
51
|
-
_globals['_STYLEGUIDES']._serialized_start=
|
|
52
|
-
_globals['_STYLEGUIDES']._serialized_end=
|
|
53
|
-
_globals['_CHARACTER']._serialized_start=
|
|
54
|
-
_globals['_CHARACTER']._serialized_end=
|
|
55
|
-
_globals['_CHARACTER_TEMPLATESENTRY']._serialized_start=
|
|
56
|
-
_globals['_CHARACTER_TEMPLATESENTRY']._serialized_end=
|
|
57
|
-
_globals['_CHARACTER_SECRETSENTRY']._serialized_start=
|
|
58
|
-
_globals['_CHARACTER_SECRETSENTRY']._serialized_end=
|
|
59
|
-
_globals['_MESSAGEEXAMPLEGROUP']._serialized_start=
|
|
60
|
-
_globals['_MESSAGEEXAMPLEGROUP']._serialized_end=
|
|
61
|
-
_globals['_AGENT']._serialized_start=
|
|
62
|
-
_globals['_AGENT']._serialized_end=
|
|
50
|
+
_globals['_CHARACTERSETTINGS']._serialized_end=1627
|
|
51
|
+
_globals['_STYLEGUIDES']._serialized_start=1629
|
|
52
|
+
_globals['_STYLEGUIDES']._serialized_end=1700
|
|
53
|
+
_globals['_CHARACTER']._serialized_start=1703
|
|
54
|
+
_globals['_CHARACTER']._serialized_end=2635
|
|
55
|
+
_globals['_CHARACTER_TEMPLATESENTRY']._serialized_start=2419
|
|
56
|
+
_globals['_CHARACTER_TEMPLATESENTRY']._serialized_end=2479
|
|
57
|
+
_globals['_CHARACTER_SECRETSENTRY']._serialized_start=2481
|
|
58
|
+
_globals['_CHARACTER_SECRETSENTRY']._serialized_end=2539
|
|
59
|
+
_globals['_MESSAGEEXAMPLEGROUP']._serialized_start=2637
|
|
60
|
+
_globals['_MESSAGEEXAMPLEGROUP']._serialized_end=2712
|
|
61
|
+
_globals['_AGENT']._serialized_start=2715
|
|
62
|
+
_globals['_AGENT']._serialized_end=2925
|
|
63
63
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -43,7 +43,7 @@ class KnowledgeDirectory(_message.Message):
|
|
|
43
43
|
def __init__(self, path: _Optional[str] = ..., shared: _Optional[bool] = ...) -> None: ...
|
|
44
44
|
|
|
45
45
|
class CharacterSettings(_message.Message):
|
|
46
|
-
__slots__ = ("should_respond_model", "use_multi_step", "max_multistep_iterations", "bootstrap_defllmoff", "bootstrap_keep_resp", "providers_total_timeout_ms", "max_working_memory_entries", "always_respond_channels", "always_respond_sources", "default_temperature", "default_max_tokens", "default_frequency_penalty", "default_presence_penalty", "disable_basic_capabilities", "
|
|
46
|
+
__slots__ = ("should_respond_model", "use_multi_step", "max_multistep_iterations", "bootstrap_defllmoff", "bootstrap_keep_resp", "providers_total_timeout_ms", "max_working_memory_entries", "always_respond_channels", "always_respond_sources", "default_temperature", "default_max_tokens", "default_frequency_penalty", "default_presence_penalty", "disable_basic_capabilities", "extra")
|
|
47
47
|
SHOULD_RESPOND_MODEL_FIELD_NUMBER: _ClassVar[int]
|
|
48
48
|
USE_MULTI_STEP_FIELD_NUMBER: _ClassVar[int]
|
|
49
49
|
MAX_MULTISTEP_ITERATIONS_FIELD_NUMBER: _ClassVar[int]
|
|
@@ -58,7 +58,6 @@ class CharacterSettings(_message.Message):
|
|
|
58
58
|
DEFAULT_FREQUENCY_PENALTY_FIELD_NUMBER: _ClassVar[int]
|
|
59
59
|
DEFAULT_PRESENCE_PENALTY_FIELD_NUMBER: _ClassVar[int]
|
|
60
60
|
DISABLE_BASIC_CAPABILITIES_FIELD_NUMBER: _ClassVar[int]
|
|
61
|
-
ENABLE_EXTENDED_CAPABILITIES_FIELD_NUMBER: _ClassVar[int]
|
|
62
61
|
EXTRA_FIELD_NUMBER: _ClassVar[int]
|
|
63
62
|
should_respond_model: str
|
|
64
63
|
use_multi_step: bool
|
|
@@ -74,9 +73,8 @@ class CharacterSettings(_message.Message):
|
|
|
74
73
|
default_frequency_penalty: float
|
|
75
74
|
default_presence_penalty: float
|
|
76
75
|
disable_basic_capabilities: bool
|
|
77
|
-
enable_extended_capabilities: bool
|
|
78
76
|
extra: _struct_pb2.Struct
|
|
79
|
-
def __init__(self, should_respond_model: _Optional[str] = ..., use_multi_step: _Optional[bool] = ..., max_multistep_iterations: _Optional[int] = ..., bootstrap_defllmoff: _Optional[bool] = ..., bootstrap_keep_resp: _Optional[bool] = ..., providers_total_timeout_ms: _Optional[int] = ..., max_working_memory_entries: _Optional[int] = ..., always_respond_channels: _Optional[str] = ..., always_respond_sources: _Optional[str] = ..., default_temperature: _Optional[float] = ..., default_max_tokens: _Optional[int] = ..., default_frequency_penalty: _Optional[float] = ..., default_presence_penalty: _Optional[float] = ..., disable_basic_capabilities: _Optional[bool] = ...,
|
|
77
|
+
def __init__(self, should_respond_model: _Optional[str] = ..., use_multi_step: _Optional[bool] = ..., max_multistep_iterations: _Optional[int] = ..., bootstrap_defllmoff: _Optional[bool] = ..., bootstrap_keep_resp: _Optional[bool] = ..., providers_total_timeout_ms: _Optional[int] = ..., max_working_memory_entries: _Optional[int] = ..., always_respond_channels: _Optional[str] = ..., always_respond_sources: _Optional[str] = ..., default_temperature: _Optional[float] = ..., default_max_tokens: _Optional[int] = ..., default_frequency_penalty: _Optional[float] = ..., default_presence_penalty: _Optional[float] = ..., disable_basic_capabilities: _Optional[bool] = ..., extra: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ...
|
|
80
78
|
|
|
81
79
|
class StyleGuides(_message.Message):
|
|
82
80
|
__slots__ = ("all", "chat", "post")
|
package/elizaos/types/model.py
CHANGED
|
@@ -56,6 +56,9 @@ class ModelType(str, Enum):
|
|
|
56
56
|
# Research models (deep research)
|
|
57
57
|
RESEARCH = "RESEARCH"
|
|
58
58
|
|
|
59
|
+
# Safeguard models
|
|
60
|
+
SAFEGUARD = "SAFEGUARD"
|
|
61
|
+
|
|
59
62
|
|
|
60
63
|
# Type for model type names - allows string for extensibility
|
|
61
64
|
ModelTypeName = str
|
|
@@ -281,6 +284,30 @@ class ObjectGenerationParams(BaseModel):
|
|
|
281
284
|
model_config = {"populate_by_name": True, "extra": "allow"}
|
|
282
285
|
|
|
283
286
|
|
|
287
|
+
# ============================================================================
|
|
288
|
+
# Safeguard Model Types
|
|
289
|
+
# ============================================================================
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class SafeguardParams(BaseModel):
|
|
293
|
+
"""Parameters for safeguard (content moderation) models."""
|
|
294
|
+
|
|
295
|
+
input: str = Field(..., description="Input text to classify")
|
|
296
|
+
model_type: str = Field(..., alias="modelType", description="Model type (must be SAFEGUARD)")
|
|
297
|
+
|
|
298
|
+
model_config = {"populate_by_name": True}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class SafeguardResult(BaseModel):
|
|
302
|
+
"""Result from a safeguard model classification."""
|
|
303
|
+
|
|
304
|
+
violation: float = Field(..., description="Violation score (0-1)")
|
|
305
|
+
category: str | None = Field(default=None, description="Violation category if any")
|
|
306
|
+
rationale: str | None = Field(default=None, description="Rationale for the classification")
|
|
307
|
+
|
|
308
|
+
model_config = {"populate_by_name": True}
|
|
309
|
+
|
|
310
|
+
|
|
284
311
|
# ============================================================================
|
|
285
312
|
# Research Model Types (Deep Research)
|
|
286
313
|
# ============================================================================
|
package/elizaos/types/runtime.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
7
7
|
from pydantic import BaseModel, Field
|
|
8
8
|
|
|
9
9
|
from elizaos.logger import Logger
|
|
10
|
-
from elizaos.types.database import IDatabaseAdapter
|
|
10
|
+
from elizaos.types.database import IDatabaseAdapter, MemorySearchOptions
|
|
11
11
|
from elizaos.types.primitives import UUID, Content
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
@@ -287,6 +287,7 @@ class IAgentRuntime(ABC):
|
|
|
287
287
|
include_list: list[str] | None = None,
|
|
288
288
|
only_include: bool = False,
|
|
289
289
|
skip_cache: bool = False,
|
|
290
|
+
trajectory_phase: str | None = None,
|
|
290
291
|
) -> State: ...
|
|
291
292
|
|
|
292
293
|
# Model usage
|
|
@@ -456,5 +457,8 @@ class IAgentRuntime(ABC):
|
|
|
456
457
|
@abstractmethod
|
|
457
458
|
async def get_relationships(self, params: dict[str, object]) -> list[object]: ...
|
|
458
459
|
|
|
460
|
+
@abstractmethod
|
|
461
|
+
async def search_memories(self, params: MemorySearchOptions) -> list[Memory]: ...
|
|
462
|
+
|
|
459
463
|
@abstractmethod
|
|
460
464
|
async def search_knowledge(self, query: str, limit: int = 5) -> list[object]: ...
|