Skip to content

Commit

Permalink
Python: check if timestamp exists (microsoft#4977)
Browse files Browse the repository at this point in the history
### Motivation and Context
fix microsoft#4975 

### Description

check if the key timestamp exists before setting it as it's optional

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
  • Loading branch information
john0isaac authored Feb 13, 2024
1 parent 48b6bb2 commit f37b3dc
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def get(self, collection_name: str, key: str, with_embedding: bool) -> Mem
text=result["text"],
description=result["description"],
additional_metadata=result["metadata"],
timestamp=result["timestamp"],
timestamp=result.get("timestamp", None),
)

async def get_batch(self, collection_name: str, keys: List[str], with_embeddings: bool) -> List[MemoryRecord]:
Expand All @@ -117,7 +117,7 @@ async def get_batch(self, collection_name: str, keys: List[str], with_embeddings
text=result["text"],
description=result["description"],
additional_metadata=result["metadata"],
timestamp=result["timestamp"],
timestamp=result.get("timestamp", None),
)
for result in results
]
Expand Down Expand Up @@ -163,7 +163,7 @@ async def get_nearest_matches(
text=aggResult["document"]["text"],
description=aggResult["document"]["description"],
additional_metadata=aggResult["document"]["metadata"],
timestamp=aggResult["document"]["timestamp"],
timestamp=aggResult["document"].get("timestamp", None),
)
if aggResult["similarityScore"] < min_relevance_score:
continue
Expand Down

0 comments on commit f37b3dc

Please sign in to comment.