Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #227

Merged
merged 11 commits into from
Nov 6, 2024
16 changes: 9 additions & 7 deletions examples/chat_history/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ async def main() -> None:
last_name="Smith",
metadata={"vip": "true"},
)
# await asyncio.sleep(1)
print(f"User added: {user_id}")

session_id = uuid.uuid4().hex # unique session id. can be any alphanum string

Expand All @@ -55,24 +57,26 @@ async def main() -> None:
user_id=user_id,
metadata={"foo": "bar"},
)

# await asyncio.sleep(1)
# Update session metadata
print(f"\n---Updating session: {session_id}")
await client.memory.update_session(session_id=session_id, metadata={"bar": "foo"})

# await asyncio.sleep(3)
# Get session
print(f"\n---Getting session: {session_id}")
session = await client.memory.get_session(session_id)
print(f"Session details: {session}")
# await asyncio.sleep(3)

# Add Memory for session
print(f"\n---Add Memory for Session: {session_id}")
for m in history:
print(f"{m['role']}: {m['content']}")
await client.memory.add(session_id=session_id, messages=[Message(**m)])
# await asyncio.sleep(0.5)

# Wait for the messages to be processed
await asyncio.sleep(20)
await asyncio.sleep(50)

# Synthesize a question from most recent messages.
# Useful for RAG apps. This is faster than using an LLM chain.
Expand All @@ -94,16 +98,14 @@ async def main() -> None:
)
print(f"Classification: {classification}")

all_session_facts = await client.memory.get_session_facts(session_id)
for f in all_session_facts.facts:
print(f"{f.fact}\n")

# Get Memory for session
print(f"\n---Get Perpetual Memory for Session: {session_id}")
memory = await client.memory.get(session_id)
print(f"Memory: {memory}")
print("\n---End of Memory")

print(f"Memory context: {memory.context}")

# Search Memory for session
query = "What are Jane's favorite shoe brands?"
print(f"\n---Searching over summaries for: '{query}'")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zep-cloud"
version = "2.0.1"
version = "2.1.0"
description = ""
readme = "README.md"
authors = []
Expand Down
2 changes: 1 addition & 1 deletion src/zep_cloud/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "zep-cloud",
"X-Fern-SDK-Version": "2.0.1",
"X-Fern-SDK-Version": "2.1.0",
}
headers["Authorization"] = f"Api-Key {self.api_key}"
return headers
Expand Down
5 changes: 5 additions & 0 deletions src/zep_cloud/types/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


class Memory(pydantic_v1.BaseModel):
context: typing.Optional[str] = pydantic_v1.Field(default=None)
"""
Memory context containing relevant facts and entities for the session. Can be put into the prompt directly.
"""

facts: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None)
"""
Most recent list of facts derived from the session. (cloud only)
Expand Down