Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### Reference Issues/PRs

#### What does this implement/fix? Explain your changes.
#### What does this implement/fix? Explain your changes

#### Any other comments?

3 changes: 2 additions & 1 deletion examples/dataframe_usage/1_secure_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"My budget is around $7,200. I'm trying to keep track of flight costs, hotels, and food. Do you need any contact information?",
"Here is my email just in case: personal.email@example.com. What are the options I have for the flight?",
"I'm thinking of booking a multi-city flight. Found one for $1240 on Lufthansa. Do you need more information?",
"OK! Here's a chunk of my notes: " + "lorem ipsum " * 400 + "\n\nCan you book it for me if I give you my information?", # intentionally long
"OK! Here's a chunk of my notes: " + "lorem ipsum " * 400 +
"\n\nCan you book it for me if I give you my information?", # intentionally long
"My passport number is X12345678. Please remind me to renew it, it's a bit old. Should we start the daily plan of the trip?",
"Can you help me create a daily itinerary for France first?",
]
Expand Down
1 change: 1 addition & 0 deletions examples/dataframe_usage/3_trimmed_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# Anonymize names inside remaining messages
NAME_REGEX = re.compile(r"\b[A-Z][a-z]{1,20}\s[A-Z][a-z]{1,20}\b")


def anonymize_names(text: str) -> str:
"""
Anonymize the text by replacing names with [REDACTED_NAME].
Expand Down
1 change: 1 addition & 0 deletions memor/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

DATAFRAME_MAIN_COLUMNS = ["type", "message", "role", "id", "date_created", "date_modified"]


class Role(Enum):
"""Role enum."""

Expand Down
5 changes: 1 addition & 4 deletions memor/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ def to_dict(self) -> Dict[str, Any]:
}
return data


def to_dataframe(self) -> pd.DataFrame:
"""Convert the session to a pandas DataFrame."""
records = []
Expand All @@ -472,11 +471,10 @@ def to_dataframe(self) -> pd.DataFrame:
records.append(record)
return pd.DataFrame(records)


def from_dataframe(self, dataframe: pd.DataFrame) -> None:
"""
Reconstruct a session object from a pandas DataFrame.

:param dataframe: input dataframe
"""
messages = []
Expand Down Expand Up @@ -505,7 +503,6 @@ def from_dataframe(self, dataframe: pd.DataFrame) -> None:
self.reset_render_counter()
self._mark_modified()


def get_size(self) -> int:
"""Get the size of the session in bytes."""
json_str = json.dumps(self.to_json())
Expand Down
4 changes: 2 additions & 2 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ def test_size_warning1():
response.set_size_warning(threshold=10)
assert response._warnings["size"]["enable"]
assert response._warnings["size"]["threshold"] == 10
with pytest.warns(RuntimeWarning, match="Message {message_id} exceeded size threshold \({current_size} > {threshold}\).".format(message_id=response.id, current_size=response.get_size(),
threshold=10)):
with pytest.warns(RuntimeWarning, match="Message {message_id} exceeded size threshold \\({current_size} > {threshold}\\).".format(message_id=response.id, current_size=response.get_size(),
threshold=10)):
_ = response.render(RenderFormat.AI_STUDIO)
response.reset_size_warning()
assert not response._warnings["size"]["enable"]
Expand Down