getzep / zep-python Goto Github PK
View Code? Open in Web Editor NEWZep: Long-Term Memory for AI Assistants (Python Client)
Home Page: https://help.getzep.com
Zep: Long-Term Memory for AI Assistants (Python Client)
Home Page: https://help.getzep.com
Hello.
I'm using zep memory (and probably session in future) for chat history.
I currently use my internal user_id
as session session_id=user_id
.
The issue is that I want to be able to reset the history faster.
When having
purge_every: 1
in config.yaml
and using zep_client.memory.delete_memory(user_id)
or zep_client.memory.get_memory(user_id).messages.clear()
User then starts a new conversation before msg="completed purging memory store"
log, and i get
API error: {'status_code': 400, 'message': 'storage error: session .... is deleted (original error: <nil>)\n'}
Unfortunately, I can not use any new session variable except same user_id.
Is there any way to renew session instantly - or at least remove all messages and session variables?
Thank you for this very helpful solution and advices.
I just installed the following packages in a clean conda environment with python3.8
and I am running into the following error message. It's pretty easy to duplicate.
tiktoken==0.4.0
zep-python==1.1.0
packaging==23.1
zep-seeder | Traceback (most recent call last):
zep-seeder | File "/app/setup.py", line 9, in <module>
zep-seeder | client = ZepClient(base_url=zep_api_url)
zep-seeder | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zep-seeder | File "/usr/local/lib/python3.11/site-packages/zep_python/zep_client.py", line 86, in __init__
zep-seeder | self._healthcheck(base_url)
zep-seeder | File "/usr/local/lib/python3.11/site-packages/zep_python/zep_client.py", line 120, in _healthcheck
zep-seeder | zep_server_version = Version(zep_server_version_str.split("-")[0])
zep-seeder | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zep-seeder | File "/usr/local/lib/python3.11/site-packages/packaging/version.py", line 198, in __init__
zep-seeder | raise InvalidVersion(f"Invalid version: '{version}'")
zep-seeder | packaging.version.InvalidVersion: Invalid version: ''
Pydantic has gone live with their new version
Being that its production ready and as suggested by Pydantic's README:
Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: from pydantic import v1 as pydantic_v1.
It should be safe to upgrade and allow folks using poetry (like me) to resolve dependancies in a way that unblocks upgrading to Pydantic v2, FastAPI v0.100.0, etc
Thx for your jobs! ღ( ´・ᴗ・` )
In the usage scenario of memory, whether it is summarized knowledge, insights, or historical information stored in the time dimension, they will eventually become part of the new question prompt.
Why is it necessary to divide historical information into AI and Human parts?
def save_context(
self,
inputs: Dict[str, Any],
outputs: Dict[str, str],
metadata: Optional[Dict[str, Any]] = None,
) -> None:
"""Save context from this conversation to buffer.
Args:
inputs (Dict[str, Any]): The inputs to the chain.
outputs (Dict[str, str]): The outputs from the chain.
metadata (Optional[Dict[str, Any]], optional): Any metadata to save with
the context. Defaults to None
Returns:
None
"""
input_str, output_str = self._get_input_output(inputs, outputs)
self.chat_memory.add_user_message(input_str, metadata=metadata)
self.chat_memory.add_ai_message(output_str, metadata=metadata)
We are running Zep as a docker container on our virtual server and have proxied it. Our URL is like https://server.com/zep
During deploy, I noticed that we couldn't hit this server. Looking at the module code:
self.base_url = urljoin(base_url, API_BASE_PATH)
Urljoin strips off the path at the end of the base_url string.
>>> print(urljoin("https://server.com/zep", "/v1/foo"))
https://server.com/v1/foo
Thank you for an amazing app!
Title: Error 400 when adding a new memory using REST API
Description:
I have been working with the API to create a session-based memory in my application. I've implemented basic GET and DELETE operations for memory, and they seem to be working properly. However, I'm encountering an Error 400 when trying to add a new memory using the POST method.
I've tried various approaches to pass the Memory object, including using the zep-python library, custom JSON, and other methods, but none of them seem to work. The API documentation lacks examples for the REST API part, making it difficult to troubleshoot the issue.
Steps to Reproduce:
Perform a POST request to add a new memory using the REST API.
Include the necessary parameters in the request (e.g., session ID, memory data).
Observe the Error 400 response.
Expected Behavior:
The POST request should add a new memory to the session without any errors.
Additional Information:
I have successfully used the GET and DELETE methods for memory, which suggests that the authentication and basic functionality of the API are working as expected.
The issue seems to be specific to the POST method when adding a new memory.
Note:
The API documentation lacks clear examples for the REST API part, especially when it comes to the POST method for adding a new memory. This makes it challenging to understand the correct format and parameters required for the request. It would be highly beneficial to include detailed examples in the documentation to help developers use the API effectively.
The Session class is missing from zep_python/init.py. Please import from zep_python.models and add to all
I've used Zep as follows:
memory = ZepMemory(
session_id=session_id,
url=ZEP_API_URL,
memory_key="chat_history",
output_key='answer',
return_messages=True
)
when I pass this into a ConversationalRetrievalChain, it would be really nice if Zep could automatically search chat history and add it on top of retriever context
In the quick start code, it looks like the function signature for "aget_memory" and "asearch_memory" are a bit out of date.
When I run:
memories = await client.aget_memory(session_id)
for memory in memories:
for message in memory.messages:
print(message.to_dict())
It complains:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[26], line 22
20 memories = await client.aget_memory(session_id)
21 for memory in memories:
---> 22 for message in memory.messages:
23 print(message.to_dict())
25 # Search memory
26 # Messages uploaded to Zep are automatically embedded and made available
27 # for vector-based similarity search.
AttributeError: 'tuple' object has no attribute 'messages'
Also when I run
search_payload = SearchPayload({}, "Who is Yuri Gagarin?")
it complains
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[27], line 1
----> 1 search_payload = SearchPayload({}, "Who is Yuri Gagarin?")
File [c:\Users\jayfd\anaconda3\envs\family-gpt\lib\site-packages\pydantic\main.py:332](file:///C:/Users/jayfd/anaconda3/envs/family-gpt/lib/site-packages/pydantic/main.py:332), in pydantic.main.BaseModel.__init__()
TypeError: __init__() takes exactly 1 positional argument (3 given)
Both look like easy fixes that i was able to do, just though it would be good to update the quickstart code in various places if indeed the signature has changed for these functions.
Replace all occurrences of the old docs link with the new one
Replace: https://getzep.github.io/
With: https://docs.getzep.com/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.