-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to specify topics for memory extraction and retrieval (#93)
This PR introduces the ability for the client to specify topics for extraction and retrieval. Specifically, inside the memory_module config we add the ability to specify a Topic: eg: ``` Topic(name="Device Type", description="The type of device the user has"), Topic(name="Operating System", description="The user's operating system"), Topic(name="Device year", description="The year of the user's device"), ``` Here, we are telling the system to specifically look for these topics during extraction. After extraction, when we store the memories, we also store the associated topic. By default, we provide some general topics that the system uses - these retain the current behavior of the system (See [default topics](https://github.com/microsoft/teams-memory-agents-py/blob/61a1538c7888ddcda4e5f4a4e953d7df91729479/packages/memory_module/config.py#L22-L29)). During retrieval, we now provide the ability to query for memories with topic as well. So if the user specifies a topic, but no query, then all the memories associated for that particular user for that topic will be returned ordered from latest to oldest memory. If a query is specified, then both query and topic will be taken into consideration. The new signature for retrieval is as follows: ```python @AbstractMethod async def retrieve_memories( self, user_id: Optional[str], config: RetrievalConfig, ) -> List[Memory]: """Retrieve relevant memories based on a query.""" pass ``` Here `RetrievalConfig` is: ```python class RetrievalConfig(BaseModel): query: Optional[str] = None topic: Optional[Topic] = None limit: Optional[int] = None ``` TODO: [ ] Add a test for topic retrieval Addresses: #40
- Loading branch information
1 parent
6471376
commit 069677b
Showing
16 changed files
with
718 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.