Skip to content

Commit

Permalink
V2 (#227)
Browse files Browse the repository at this point in the history
* chore: Add quickstart notebook

* SDK regeneration

* chore: Version bump

* chore: Add license

* chore: Version bump

* SDK regeneration

* chore: Bump version and add memory context to the example

---------

Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
paul-paliychuk and fern-api[bot] authored Nov 6, 2024
1 parent bf7732e commit 8226d9a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
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

0 comments on commit 8226d9a

Please sign in to comment.