namespace
Namespace service module
Attributes
Classes
NamespaceService
Bases: BaseService
Namespace service layer
Responsible for Namespace management operations as well as create/list objects owned within the namespace
Attributes
memory_collection_dao
instance-attribute
memory_collection_dao = MemoryCollectionDao(
session=_sa_session
)
Functions
create_namespace
create_namespace(
name: str,
description: str = "",
settings: Optional[NamespaceResourceSettings] = None,
managed: bool = False,
enabled: bool = True,
db_transact: bool = True,
) -> Namespace
Creates a new namespace with the given name and enabled status.
Parameters:
-
name
(str
) –The name of the namespace.
-
enabled
(bool
, default:True
) –The enabled status of the namespace. Defaults to True.
-
description
(str
, default:''
) –The description of the namespace. Defaults to “”.
-
settings
(NamespaceResourceSettings
, default:None
) –The resource settings for the namespace. Defaults to None.
-
managed
(bool
, default:False
) –Flag indicating whether the namespace is managed. Defaults to False.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Returns:
-
Namespace
–orm.Namespace: The newly created namespace.
Raises:
-
ServiceError
–If an error occurs while creating the namespace.
delete_namespace
Soft-Deletes a namespace by setting its ‘deleted’ attribute to True.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace to be deleted.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If an error occurs during the deletion process.
delete_participants
delete_participants(
namespace: str,
participant_pkids: Union[str, List[str]],
db_transact: bool = True,
) -> None
Deletes participants from a namespace.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
participant_pkids
(Union[str, List[str]]
) –The primary key(s) of the participant(s) to be deleted.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If the participant(s) or namespace is not found, or if an error occurs during the operation.
get_namespace
get_namespace(
namespace: str,
include_deleted=True,
include_disabled=True,
) -> Namespace
Retrieves a namespace.
Parameters:
-
namespace
(str
) –Namespace match key.
Returns:
-
Namespace
–orm.Namespace: The namespace object.
Raises:
-
ServiceError
–If the namespace is not found or if it is deleted.
get_namespace_openai_models
get_namespace_openai_models() -> List[Model]
Retrieves a list of models available in the namespace.
Returns:
-
List[Model]
–List[Dict[str, str]]: A list of models available in the namespace.
list_activity_sessions
list_activity_sessions(
namespace: str, include_deleted: bool = False
) -> List[ActivitySession]
Retrieve a list of activity sessions for a given namespace.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
include_deleted
(bool
, default:False
) –Flag to include deleted activity sessions. Defaults to False.
Returns:
-
List[ActivitySession]
–List[orm.ActivitySession]: A list of activity sessions.
Raises:
-
ServiceError
–If an error occurs while retrieving the activity sessions.
list_namespaces
list_namespaces(
include_deleted: bool = False,
include_disabled: bool = False,
) -> List[Namespace]
Retrieve a list of namespaces.
Parameters:
-
include_deleted
(bool
, default:False
) –Flag to include deleted namespaces. Defaults to False.
Returns:
-
List[Namespace]
–List[orm.Namespace]: A list of namespaces.
Raises:
-
ServiceError
–If there is an error performing the operation.
list_participants
Retrieve a list of participants in a namespace.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace.
-
include_deleted
(bool
, default:False
) –Flag to include deleted participants. Defaults to False.
Returns:
undelete_namespace
Undeletes a namespace by setting the ‘deleted’ flag to False.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace to undelete.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Raises:
-
ServiceError
–If the namespace is not deleted or an error occurs during the operation.
update_namespace
update_namespace(
namespace: str,
name: Optional[str] = None,
description: Optional[str] = None,
settings: Optional[NamespaceResourceSettings] = None,
managed: Optional[bool] = None,
enabled: Optional[bool] = None,
db_transact: bool = True,
) -> Namespace
Update a namespace with the given attributes.
Parameters:
-
namespace_pkid
(str
) –The primary key of the namespace to update.
-
name
(str
, default:None
) –The new name for the namespace. Defaults to None.
-
description
(str
, default:None
) –The new description for the namespace. Defaults to None.
-
enabled
(bool
, default:None
) –The new enabled status for the namespace. Defaults to None.
-
settings
(NamespaceResourceSettings
, default:None
) –The new resource settings for the namespace. Defaults to None.
-
managed
(bool
, default:None
) –The new managed status for the namespace. Defaults to None.
-
db_transact
(bool
, default:True
) –Flag indicating whether to commit the transaction. Defaults to True.
Returns:
-
Namespace
–orm.Namespace: The updated namespace object.
Raises:
-
ServiceError
–If an error occurs during the update operation.