2023-03-16 19:54:34 -07:00
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
|
|
2025-06-19 20:34:59 +02:00
|
|
|
import sys
|
|
|
|
|
|
2023-03-16 19:54:34 -07:00
|
|
|
from semantic_kernel.memory.memory_query_result import MemoryQueryResult
|
|
|
|
|
from semantic_kernel.memory.semantic_text_memory_base import SemanticTextMemoryBase
|
2025-06-19 20:34:59 +02:00
|
|
|
|
|
|
|
|
if sys.version_info >= (3, 13):
|
|
|
|
|
from warnings import deprecated
|
|
|
|
|
else:
|
|
|
|
|
from typing_extensions import deprecated
|
2023-03-16 19:54:34 -07:00
|
|
|
|
|
|
|
|
|
2025-06-19 20:34:59 +02:00
|
|
|
@deprecated("This class will be removed in a future version.")
|
2023-03-16 19:54:34 -07:00
|
|
|
class NullMemory(SemanticTextMemoryBase):
|
2024-08-05 18:33:49 +02:00
|
|
|
"""Class for null memory."""
|
|
|
|
|
|
2024-01-26 10:15:35 -07:00
|
|
|
async def save_information(
|
2023-06-07 15:33:51 -07:00
|
|
|
self,
|
|
|
|
|
collection: str,
|
|
|
|
|
text: str,
|
|
|
|
|
id: str,
|
2024-05-21 18:33:08 +02:00
|
|
|
description: str | None = None,
|
|
|
|
|
additional_metadata: str | None = None,
|
2023-03-16 19:54:34 -07:00
|
|
|
) -> None:
|
2024-05-28 17:28:04 +02:00
|
|
|
"""Nullifies behavior of SemanticTextMemoryBase save_information."""
|
2024-05-31 15:06:41 +02:00
|
|
|
return
|
2023-03-16 19:54:34 -07:00
|
|
|
|
2024-01-26 10:15:35 -07:00
|
|
|
async def save_reference(
|
2023-03-16 19:54:34 -07:00
|
|
|
self,
|
|
|
|
|
collection: str,
|
|
|
|
|
text: str,
|
|
|
|
|
external_id: str,
|
|
|
|
|
external_source_name: str,
|
2024-05-21 18:33:08 +02:00
|
|
|
description: str | None = None,
|
|
|
|
|
additional_metadata: str | None = None,
|
2023-03-16 19:54:34 -07:00
|
|
|
) -> None:
|
2024-05-28 17:28:04 +02:00
|
|
|
"""Nullifies behavior of SemanticTextMemoryBase save_reference."""
|
2024-05-31 15:06:41 +02:00
|
|
|
return
|
2023-03-16 19:54:34 -07:00
|
|
|
|
2024-05-21 18:33:08 +02:00
|
|
|
async def get(self, collection: str, query: str) -> MemoryQueryResult | None:
|
2024-05-28 17:28:04 +02:00
|
|
|
"""Nullifies behavior of SemanticTextMemoryBase get."""
|
2023-03-16 19:54:34 -07:00
|
|
|
return None
|
|
|
|
|
|
2024-01-26 10:15:35 -07:00
|
|
|
async def search(
|
2023-03-16 19:54:34 -07:00
|
|
|
self,
|
|
|
|
|
collection: str,
|
|
|
|
|
query: str,
|
|
|
|
|
limit: int = 1,
|
|
|
|
|
min_relevance_score: float = 0.7,
|
2024-05-21 18:33:08 +02:00
|
|
|
) -> list[MemoryQueryResult]:
|
2024-05-28 17:28:04 +02:00
|
|
|
"""Nullifies behavior of SemanticTextMemoryBase search."""
|
2023-03-16 19:54:34 -07:00
|
|
|
return []
|
|
|
|
|
|
2024-05-21 18:33:08 +02:00
|
|
|
async def get_collections(self) -> list[str]:
|
2024-05-28 17:28:04 +02:00
|
|
|
"""Nullifies behavior of SemanticTextMemoryBase get_collections."""
|
2023-03-16 19:54:34 -07:00
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NullMemory.instance = NullMemory() # type: ignore
|