createMemoryServiceFromOptions function
Creates a memory service from CLI options and environment context.
Implementation
BaseMemoryService createMemoryServiceFromOptions({
required Object baseDir,
String? memoryServiceUri,
}) {
final Directory basePath = directoryFromArg(
baseDir,
parameterName: 'baseDir',
);
final ServiceRegistry registry = getServiceRegistry();
if (memoryServiceUri != null && memoryServiceUri.isNotEmpty) {
final BaseMemoryService? service = registry.createMemoryService(
memoryServiceUri,
kwargs: <String, Object?>{'agents_dir': basePath.path},
);
if (service == null) {
throw ArgumentError(
'Unsupported memory service URI: ${redactUriForLog(memoryServiceUri)}',
);
}
return service;
}
return InMemoryMemoryService();
}