Giter Site home page Giter Site logo

getzep / zep Goto Github PK

View Code? Open in Web Editor NEW
2.2K 18.0 328.0 16.91 MB

Zep: Long-Term Memory for ‍AI Assistants.

Home Page: https://docs.getzep.com

License: Apache License 2.0

Go 81.85% Makefile 0.47% Dockerfile 0.06% Shell 0.08% CSS 5.41% JavaScript 1.10% HTML 11.03%
language-model vectorsearch llm ai langchain llamaindex

zep's Introduction

Zep Logo

Zep: Long-Term Memory for ‍AI Assistants.

Recall, understand, and extract data from chat histories. Power personalized AI experiences.


Chat on Discord Twitter Follow PyPI - Downloads @getzep/zep-js build/test GoLangCI Lint

Quick Start | Documentation | LangChain and LlamaIndex Support | Discord
www.getzep.com

What is Zep? 💬

Zep is a long-term memory service for AI Assistant apps. With Zep, you can provide AI assistants with the ability to recall past conversations, no matter how distant, while also reducing hallucinations, latency, and cost.

How Zep works

Zep persists and recalls chat histories, and automatically generates summaries and other artifacts from these chat histories. It also embeds messages and summaries, enabling you to search Zep for relevant context from past conversations. Zep does all of this asyncronously, ensuring these operations don't impact your user's chat experience. Data is persisted to database, allowing you to scale out when growth demands.

Zep also provides a simple, easy to use abstraction for document vector search called Document Collections. This is designed to complement Zep's core memory features, but is not designed to be a general purpose vector database.

Zep allows you to be more intentional about constructing your prompt:

  1. automatically adding a few recent messages, with the number customized for your app;
  2. a summary of recent conversations prior to the messages above;
  3. and/or contextually relevant summaries or messages surfaced from the entire chat session.
  4. and/or relevant Business data from Zep Document Collections.

What is Zep Cloud? ⚡️

Zep Cloud is a managed service with Zep Open Source at its core. In addition to Zep Open Source's memory management features, Zep Cloud offers:

  • Fact Extraction: Automatically build fact tables from conversations, without having to define a data schema upfront.
  • Dialog Classification: Instantly and accurately classify chat dialog. Understand user intent and emotion, segment users, and more. Route chains based on semantic context, and trigger events.
  • Structured Data Extraction: Quickly extract business data from chat conversations using a schema you define. Understand what your Assistant should ask for next in order to complete its task.

Why use Zep for long-term memory?

Why not just include the entire chat history in the prompt?

With increased LLM context lengths, it may be tempting to include entire an chat history in a prompt, alongside RAG results, and other instructions. Unfortunately, we've seen poor recall, hallucinations, and slow and expensive inference as a result.

Why not use Redis, Postgres, a Vector Database, or ... to persist chat histories?

Our goal with Zep is to elevate the layer of abstraction for memory management. We believe developer productivity is best served by infrastructure with well-designed abstractions, rather than building peristence, summarization, extraction, embedding management, and search from the ground up.

Is Zep a vector database?

No. Zep uses embeddings and vector database capaiblities under the hood to power many of its features, but is not designed to be a general purpose vector database.

Zep is purpose-built for Assistant applications

Users, Sessions, and Chat Messages are first-class abstractions in Zep. This allows simple and flexible management of chat memory, including the execution of Right To Be Forgetten requests and other privacy compliance-related tasks with single-API call.

Zep Language Support and Ecosystem

Does Zep have Python and TypeScript support?

Yes - Zep offers Python & TypeScript/JS SDKs for easy integration with your Assistant app. We also have examples of using Zep with popular frameworks - see below.

Can I use Zep with LangChain, LlamaIndex, Vercel AI, n8n, FlowWise, ...?

Yes - the Zep team and community contributors have built integrations with Zep, making it simple to, for example, drop Zep's memory components into a LangChain app. Please see the Zep Documentation and your favorite framework's documentation for more.

Zep Open Source LLM Service Dependencies

Zep Open Source relies on an external LLM API service to function. OpenAI, Azure OpenAI, Anthropic, and OpenAI-compatible APIs are all supported.

Learn more

Examples

Create Users, Chat Sessions, and Chat Messages (Zep Python SDK)

user_request = CreateUserRequest(
    user_id=user_id,
    email="[email protected]",
    first_name="Jane",
    last_name="Smith",
    metadata={"foo": "bar"},
)
new_user = client.user.add(user_request)

# create a chat session
session_id = uuid.uuid4().hex # A new session identifier
session = Session(
            session_id=session_id, 
            user_id=user_id,
            metadata={"foo" : "bar"}
        )
client.memory.add_session(session)

# Add a chat message to the session
history = [
     { role: "human", content: "Who was Octavia Butler?" },
]
messages = [Message(role=m.role, content=m.content) for m in history]
memory = Memory(messages=messages)
client.memory.add_memory(session_id, memory)

# Get all sessions for user_id
sessions = client.user.getSessions(user_id)

Persist Chat History with LangChain.js (Zep TypeScript SDK)

const memory = new ZepMemory({
    sessionId,
    baseURL: zepApiURL,
    apiKey: zepApiKey,
});
const chain = new ConversationChain({ llm: model, memory });
const response = await chain.run(
    {
        input="What is the book's relevance to the challenges facing contemporary society?"
    },
);

Hybrid similarity search over a document collection with text input and JSONPath filters (TypeScript)

const query = "Who was Octavia Butler?";
const searchResults = await collection.search({ text: query }, 3);

// Search for documents using both text and metadata
const metadataQuery = {
    where: { jsonpath: '$[*] ? (@.genre == "scifi")' },
};

const newSearchResults = await collection.search(
    {
        text: query,
        metadata: metadataQuery,
    },
    3
);

Create a LlamaIndex Index using Zep as a VectorStore (Python)

from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores import ZepVectorStore
from llama_index.storage.storage_context import StorageContext

vector_store = ZepVectorStore(
    api_url=zep_api_url,
    api_key=zep_api_key,
    collection_name=collection_name
)

documents = SimpleDirectoryReader("documents/").load_data()
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
                            documents,
                            storage_context=storage_context
)

Search by embedding (Zep Python SDK)

# Search by embedding vector, rather than text query
# embedding is a list of floats
results = collection.search(
    embedding=embedding, limit=5
)

Get Started

Install Server

Please see the Zep Quick Start Guide for important configuration information.

docker compose up

Looking for other deployment options?

Install SDK

Please see the Zep Develoment Guide for important beta information and usage instructions.

pip install zep-python

or

npm i @getzep/zep-js

zep's People

Contributors

danielchalef avatar dependabot[bot] avatar ellipsis-dev[bot] avatar petergarbers avatar rsharath avatar sweep-ai[bot] avatar zetaphor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zep's Issues

Session *id* not found in Zep. Returning None

Hey guys,

I'm following the Langchain guide in https://docs.getzep.com/sdk/langchain/#using-zep-as-a-vectorstore-and-document-retriever

I'm running into the following error when I try to execute my agent:

Session *some_session_id* not found in Zep. Returning None

My code looks as follows:

session_id = str(uuid4())

memory = ZepMemory(
    session_id=session_id,
    url="https://my-zep-url",
    api_key="my-api-key",
    memory_key="chat_history",
)

agent = initialize_agent(
    tools,
    llm,
    agent=AgentType.OPENAI_FUNCTIONS,
    verbose=True,
    agent_kwargs=agent_kwargs,
    memory=memory,
)

What am I missing? I'm creating the session id as it is shown in the guide.

Any tip is appreciated.

Question: Anthropic (Claude V2) Compatibility?

I was wanting to see if it was possible to implement this directly with Anthropic's new Claude V2 as a replacement for the LLM model currently defaulted to OpenAI GPT 3.5 Turbo? I know the embeddings can either be OpenAI Ada Embeddings V2 / Local, so I was hoping to see if it is currently possible or in the plans to have the compatibility for other LLMs? Thanks for your time!

-Preston

ERROR: zep_python.exceptions.APIError: API error: {'status_code': 502, 'message': ''}

Hello, I'm not very good at English. If possible, please help me

This is my detailed error message:

File "d:\360MoveData\Users\Administrator\Desktop\bot\memory.py", line 119, in <module>
memory.chat_memory.add_message(
File "D:\ana\envs\pbot\lib\site-packages\langchain\memory\chat_message_histories\zep.py", line 168, in add_message
self.zep_client.add_memory(self.session_id, zep_memory)
File "D:\ana\envs\pbot\lib\site-packages\zep_python\zep_client.py", line 400, in add_memory
self._handle_response(response)
File "D:\ana\envs\pbot\lib\site-packages\zep_python\zep_client.py", line 111, in _handle_response
raise APIError(response)
zep_python.exceptions.APIError: API error: {'status_code': 502, 'message': ''}

This is my code, almost copied from the zepmemory in Python. langchain:

from langchain.memory import ZepMemory
from langchain.retrievers import ZepRetriever
from langchain import OpenAI
from langchain.schema import HumanMessage, AIMessage
from langchain.utilities import WikipediaAPIWrapper
from langchain.agents import initialize_agent, AgentType, Tool
from uuid import uuid4


ZEP_API_URL =  "http://localhost:8000"
ZEP_API_KEY = "gzTpR0Ace87a6Z-0KMmhlzfMtjsSkQXyjfSdIUFjgKN5cNBLaeOZW1Nq5O6lQ_TNzFh3wKRa6I_NksHEKtloYA"

session_id = str(uuid4())  

import getpass

openai_key = "sk-***************************************"


zep_api_key = ZEP_API_KEY


search = WikipediaAPIWrapper()
tools = [
    Tool(
        name="Search",
        func=search.run,
        description="useful for when you need to search online for answers. You should ask targeted questions",
    ),
]


memory = ZepMemory(
    session_id=session_id,
    url=ZEP_API_URL,
    api_key=zep_api_key,
    memory_key="chat_history",
)

llm = OpenAI(temperature=0, openai_api_key=openai_key)
agent_chain = initialize_agent(
    tools,
    llm,
    agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
    verbose=True,
    memory=memory,
)



test_history = [
    {"role": "human", "content": "Who was Octavia Butler?"},
    {
        "role": "ai",
        "content": (
            "Octavia Estelle Butler (June 22, 1947 – February 24, 2006) was an American"
            " science fiction author."
        ),
    },
    {"role": "human", "content": "Which books of hers were made into movies?"},
    {
        "role": "ai",
        "content": (
            "The most well-known adaptation of Octavia Butler's work is the FX series"
            " Kindred, based on her novel of the same name."
        ),
    },
    {"role": "human", "content": "Who were her contemporaries?"},
    {
        "role": "ai",
        "content": (
            "Octavia Butler's contemporaries included Ursula K. Le Guin, Samuel R."
            " Delany, and Joanna Russ."
        ),
    },
    {"role": "human", "content": "What awards did she win?"},
    {
        "role": "ai",
        "content": (
            "Octavia Butler won the Hugo Award, the Nebula Award, and the MacArthur"
            " Fellowship."
        ),
    },
    {
        "role": "human",
        "content": "Which other women sci-fi writers might I want to read?",
    },
    {
        "role": "ai",
        "content": "You might want to read Ursula K. Le Guin or Joanna Russ.",
    },
    {
        "role": "human",
        "content": (
            "Write a short synopsis of Butler's book, Parable of the Sower. What is it"
            " about?"
        ),
    },
    {
        "role": "ai",
        "content": (
            "Parable of the Sower is a science fiction novel by Octavia Butler,"
            " published in 1993. It follows the story of Lauren Olamina, a young woman"
            " living in a dystopian future where society has collapsed due to"
            " environmental disasters, poverty, and violence."
        ),
        "metadata": {"foo": "bar"},
    },
]

for msg in test_history:
    memory.chat_memory.add_message(
        HumanMessage(content=msg["content"])
        if msg["role"] == "human"
        else AIMessage(content=msg["content"]),
        metadata=msg.get("metadata", {}),
    )



agent_chain.run(
    input="What is the book's relevance to the challenges facing contemporary society?",
)

The server uses Docker self deployment, and the ports are all default. Zep: 8000:8000, zep npl: 8080:8080, zep postgres: 5432:5432,

The server is running normally without any errors, and can browse 127.0.0.1:8080 normally. Using telnet, it is possible to ping ports 8080 and 8000 normally

If you need any more information, please let me know. I would be happy to provide it. Thank you. I am not very proficient in English, and all English is translated through translation software. If there is any offense, I sorry

Intent and Entity Extraction Not Executing Automatically

Hi!

I followed roughly your SDK page for Javascript at: https://docs.getzep.com/sdk/#sessions

  1. I loaded Zep with the example memory using the client.addMemory call
  2. I can get the memory for that same session using client.getMemory - that works great

However, neither client.getMemory nor client.searchMemory return any metadata including entities or intents anywhere in the object. (I just did JSON.stringify to dump the entire object from both calls to the console, no intents or entities, just the raw memory.

My .env file has no custom config in it other than the requisite ZEP_OPENAI_API_KEY=sk-... of course. However, I don't know what to turn on to actually get intent and entities since there are no config options shown in https://docs.getzep.com/deployment/config/#configuration-options regarding either intent or entities - I just see the extractors for summaries mentioned, obviously.

I do see that the NER extractor runs async (https://docs.getzep.com/extractors/#embedder-extractor), so I waited ~12 hours to check memory again - still no entities. Also, that page doesn't show anything about enabling/disabling extractors.

Here's the full result from getMemory for my test session:

{
  "messages": [
    {
      "uuid": "f4d3e883-70b5-4889-9dfa-43e322f40a40",
      "created_at": "2023-07-02T05:43:44.271938Z",
      "role": "human",
      "content": "Who was Octavia Butler?",
      "token_count": 8
    },
    {
      "uuid": "125c9f05-9fef-4f60-ac52-f2d987cfa4ef",
      "created_at": "2023-07-02T05:43:44.271938Z",
      "role": "ai",
      "content": "Octavia Estelle Butler (June 22, 1947 – February 24, 2006) was an American science fiction author.",
      "token_count": 31
    },
    {
      "uuid": "4ca16b7c-1451-4c79-bb3e-7c5d03b35d28",
      "created_at": "2023-07-02T05:43:44.271938Z",
      "role": "human",
      "content": "Which books of hers were made into movies?",
      "token_count": 11
    }
  ],
  "metadata": {}
}

Avoiding wrong results in conversationl-ReACT-description bot with zep long term memory

I'm creating a langchain chatbot (Conversationl-ReACT-description) with zep long term memory and that bot has access to real-time data. How do I prevent use the memory when same query asked again few minutes later? The problem is when a tool produced an error or irrelevant result memory will give it agian and agian. Is there any workaround for that?

Zep returns 500 Internal Server Error on GetMessage

JS Example Errors:

  1. First Get from example-index.js calls a Get on a SessionID that doesn't exist.
  2. Second Get from example-index.js calls a Get on a SessionID + memories that were just created.

Issue tends to happen with example-index.js is run in quick succession.

$ node example-index.js 13:38:15
Got error: UnexpectedResponseError: Unexpected status code: 500
at ZepClient. (/Users/sharath/Dropbox/Development/Zep/zep-js/dist/zep-client.js:88:27)
at Generator.throw ()
at rejected (/Users/sharath/Dropbox/Development/Zep/zep-js/dist/zep-client.js:29:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
responseData: undefined
}

Adding new memory for session 1a1a1a
Getting memory for newly added memory with sessionid 1a1a1a
Got error: UnexpectedResponseError: Unexpected status code: 500
at ZepClient. (/Users/sharath/Dropbox/Development/Zep/zep-js/dist/zep-client.js:88:27)
at Generator.throw ()
at rejected (/Users/sharath/Dropbox/Development/Zep/zep-js/dist/zep-client.js:29:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
responseData: undefined
}

Server Log Indicates:
-05-15T20:38:16Z" level=error msg="storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: )))"
zep | time="2023-05-15T20:38:16Z" level=info msg="http://localhost:8000/api/v1/sessions/1a1a1a/memory" bytes=231 category=router duration=2223333 duration_display=2.22375ms method=GET proto=HTTP/1.1 remote_ip=172.19.0.1 status_code=500
zep | time="2023-05-15T20:38:16Z" level=info msg="http://localhost:8000/api/v1/sessions/1a1a1a/memory" bytes=2 category=router duration=4088292 duration_display=4.08875ms method=POST proto=HTTP/1.1 remote_ip=172.19.0.1 status_code=200
zep | time="2023-05-15T20:38:16Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:16Z" level=error msg="storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: )))"
zep | time="2023-05-15T20:38:16Z" level=info msg="http://localhost:8000/api/v1/sessions/1a1a1a/memory" bytes=231 category=router duration=1301125 duration_display=1.301292ms method=GET proto=HTTP/1.1 remote_ip=172.19.0.1 status_code=500


zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:15Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"
zep | time="2023-05-15T20:38:16Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor get memory failed (original error: storage error: failed to get messages (original error: storage error: unable to retrieve last summary point (original error: storage error: message with UUID 0bdfbbea-00fb-4cd0-b91c-e17012799dd2 not found (original error: ))))"

How to restore a session after delete?

I use the python sdk delete_memory function to delete the memory, but then when I try to use the same session id to store messages, it shows up error like API error: {'status_code': 400, 'message': 'storage error: failed to put messages (original error: storage error: session xxxx is deleted (original error: ))\n'}. Also I do not see a specific function within zepclient that handles session creation

Add Support for Custom Headers in LLM Requests

Feature Description

To integrate and proxy requests from Zep through Portkey.ai, we need the ability to add custom headers to our requests to the LLM. Please note that Portkey.ai already has an integration with Langchain.

Portkey.ai requires certain specific headers to be passed in every API call, which can be found in their documentation: https://docs.portkey.ai/how-portkey-works/portkey-headers

Value of Feature

This feature will allow logging Zep's requests to LLM and calculating the cost of LLM calls as a part of Zep-Portkey.ai integration. Custom headers support could also be useful for other potential integrations and use-cases.

Possible Implementation

We could provide the ability to set custom headers through environment variables, a .env file, or the config.yaml file. This provides flexibility in choosing how to supply custom headers, depending on user preferences or security requirements.

Thank You.

Ability to deploy to a serverless environment

It is already possible to deploy a Go server, wrapped into a Docker, into an AWS Lambda now, with an adapter. This could be hugely beneficial for occasional usage scenarios.

But the one thing I am concerned about though is state.

Does Zep maintain any in-memory state for a long time?

Or is it mainly an API layer between the services and the storage (Postgres)?

Will it commit, or drain, the state on SIGTERM?

HTTP Error

zep    |  panic: runtime error: invalid memory address or nil pointer dereference
zep    |
zep    |  -> github.com/uptrace/bun.(*SelectQuery).Where
zep    |  ->   /go/pkg/mod/github.com/uptrace/[email protected]/query_select.go:143
zep    |
zep    |     github.com/getzep/zep/pkg/memorystore.searchMessages
zep    |       /app/pkg/memorystore/postgres_search.go:53
zep    |     github.com/getzep/zep/pkg/memorystore.(*PostgresMemoryStore).SearchMemory
zep    |       /app/pkg/memorystore/postgres.go:191
zep    |     github.com/getzep/zep/pkg/server.SearchMemoryHandler.func1
zep    |       /app/pkg/server/handlers.go:147
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).routeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:444
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).ServeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73
zep    |     github.com/go-chi/chi/v5.(*Mux).Mount.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:316
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).routeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:444
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).ServeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73
zep    |     github.com/go-chi/chi/v5.(*Mux).Mount.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:316
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).routeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:444
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).ServeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73
zep    |     github.com/go-chi/chi/v5.(*Mux).Mount.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:316
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).routeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:444
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5/middleware.Heartbeat.func1.1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/heartbeat.go:21
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5/middleware.RealIP.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/realip.go:36
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5/middleware.RequestID.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/request_id.go:76
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5/middleware.Recoverer.func1
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/recoverer.go:43
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/chi-middleware/logrus-logger.Logger.func1.1
zep    |       /go/pkg/mod/github.com/chi-middleware/[email protected]/middleware.go:48
zep    |     net/http.HandlerFunc.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2122
zep    |     github.com/go-chi/chi/v5.(*Mux).ServeHTTP
zep    |       /go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:90
zep    |     net/http.serverHandler.ServeHTTP
zep    |       /usr/local/go/src/net/http/server.go:2936
zep    |     net/http.(*conn).serve
zep    |       /usr/local/go/src/net/http/server.go:1995
zep    |     created by net/http.(*Server).Serve
zep    |       /usr/local/go/src/net/http/server.go:3089

Zep container throws .env error even when it finds it.

Logs state .env file was missing even when its there and loaded fine.

zep | time="2023-05-20T17:46:52Z" level=info msg="Starting zep server version 0.4.4-c608a29 (2023-05-20T16:52:01+0000)"
zep | time="2023-05-20T17:46:52Z" level=warning msg=".env file not found or unable to load"

[FEAT] Better local LLM support. (Llama)

Is your feature request related to a problem? Please describe.
I'd like to be able to use my local models for inference and embedding in Zep.

Describe the solution you'd like
It would be cool to add support for some of the local inference options: Ollama, llama.cpp, gpt4all ect.

Describe alternatives you've considered
I see there is support for local embeddings through CPU inference but it would be cool to make this more modular.

Summary Max Tokens cuts off summary

So the "max_tokens" feature from open ai sounds great, but in reality it just cuts the response off at the given limit. So if the response is 700 tokens but you ask it to cap it off at 512, then it will literally just cut the response off at 512.

... The AI discusses how challenges are part of",

It doesn't care if it doesn't make any sense, it just drops anything after 512 which makes the summary less cohesive. I do like being able to limit the summary because if not, you can have a really long summary after a long chat conversation which can get really expensive.

What I've found works better than sending in "max_tokens" is to make it part of the prompt. "Summarize the following in 512 tokens or less". This will make sure that the response is less than a certain amount, without cutting off the response prematurely.

It would also be great if this number was easily configurable from langchain so we didn't have to worry about the config file when finding which amount works best for our use case.

Update:
Here's a draft PR with my proposed solution minus making it configurable from langchain. I've never worked on a Go project before but you should be able to see what I'm trying to do here. Let me know what you think and I can keep working on it if you'd like. #130

Search occasionally Returns 500 (unable to look up api.openai.com - no such host error)

Search occasionally returns a 500

zep | time="2023-05-15T20:56:56Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor summarize failed (original error: Post "https://api.openai.com/v1/chat/completions\": dial tcp: lookup api.openai.com on 127.0.0.11:53: no such host)"
zep | time="2023-05-15T20:56:56Z" level=error msg="EmbeddingExtractor extract failed: extractor error: EmbeddingExtractor embed messages failed (original error: llm error: error while creating embedding (original error: Post "https://api.openai.com/v1/embeddings\": dial tcp: lookup api.openai.com on 127.0.0.11:53: no such host))"
zep | time="2023-05-15T20:56:56Z" level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor summarize failed (original error: Post "https://api.openai.com/v1/chat/completions\": dial tcp: lookup api.openai.com on 127.0.0.11:53: no such host)"

Summary does not reflect all history if you ask for fewer than 12 messages

The size of our prompt was leaving our AI slow. With doc stores and history our prompts were getting into the 1,000 token range and prompt eval time got up to 2 minutes.

When I tried to limit the history to the last 5 messages, I noticed that the summary was never returned until there were 12 messages in history. When the summary is returned, it is only a summary for the messages > 12.

<s>[INST] <<SYS>>
You are cordial, professional, honest and you do not make up answers. You avoid answers that make you sound like an AI or large language model.
You don't feel the need to introduce yourself or greet someone when starting a response.

Use the following context to help answer the question if it is available and relevant to the question asked.


Here is a memory of our conversation. My questions are labeled 'human' and your responses are labeled 'ai'. Use this to help answer questions if it is relevant.
Summary: The human asks about the state of the union in America. The AI responds by stating that the State of the Union is strong and provides examples of job creation and global cooperation. The human then asks about The Witcher, and the AI explains that it is a popular Netflix show based on a fantasy book series by Andrzej Sapkowski. The AI mentions the main character, Geralt of Rivia, and the talented cast of the show. The human further asks about the love interest in the book, and the AI identifies Yennefer as Geralt's love interest and provides background information on her character. The AI also mentions the actress who portrays Yennefer in the Netflix series. The human then asks about another character, Ciri. The AI responds by giving a detailed description of Ciri, her role in the book series and the Netflix adaptation, and her relationships with Geralt and Yennefer. The AI summarizes the book series, mentioning Geralt's role as a witcher, his encounters with mythical creatures and political intrigue, and the complex relationships between the main characters. The human then inquires about the reception of the Netflix series, and the AI explains that it has generally received positive reviews for its production values, acting, and faithfulness to the source material. The AI highlights the strong portrayal of the female characters and provides examples of praise from Variety and The New York Times. However, the AI acknowledges that some reviewers have mentioned pacing issues and confusion for viewers unfamiliar with the books. Overall, the Netflix series has been widely praised for its quality and faithfulness to the books.
ai:
Ah, Freya Allan! She portrays Ciri in the Netflix series "The Witcher" and has received positive reviews for her performance. Reviewers have praised her ability to bring depth and vulnerability to the character, particularly in her portrayal of Ciri's emotional struggles and relationships with the other characters.
For example, The Telegraph wrote, "Freya Allan shines as the young princess Ciri, bringing a sense of vulnerability and determination to the role." The Independent stated, "Allan delivers a standout performance as the fierce and determined Ciri."
However, some reviewers have noted that Allan's performance may not be to everyone's taste, particularly if viewers are familiar with the book series or previous adaptations of "The Witcher". Nevertheless, her portrayal of Ciri has been widely praised for its faithfulness to the source material and her ability to bring the character to life on screen.
human: Who is the villian in this book?
ai: Ah, the villain in "The Witcher" book series! That would be the sorceress, Yennefer of Vengerberg. She is a complex and multifaceted character who plays a pivotal role in the story as both a love interest of Geralt's and a powerful sorceress in her own right.
Yennefer is driven by a desire for power and control, and she will stop at nothing to achieve her goals. She is ruthless and cunning, and will use any means necessary to gain the upper hand. However, she is also a deeply conflicted character, struggling with her own moral ambiguity and the consequences of her actions.
In the Netflix series, Yennefer is portrayed by actress Anya Chalotra, who brings depth and nuance to the character. Her performance has been widely praised for its faithfulness to the source material and her ability to bring the character to life on screen.

<</SYS>>

Question: What books are similar that I might enjoy?[/INST]
</s>

In this instance, the summary does not reflect the questions about Henry Cavill or Freya Allen being good actors nor the answers when asking for only the last three memory messages.

This is easily replicated. Just load 10 messages into history and request the last 4. There will be no summary. Thanks.

[BUG] relation "***" does not exist

Describe the bug
I get the error after several days from installing zep server, when using that.
I don't know exactly what reason is.

If I restart Zep server, that error removed but after a few days it occur again.

Logs
I attached log image.

Environment (please complete the following information):

  • Zep version: [I don't know exactly, how can I see that?]
  • Zep SDK and version: [zep-postgres, zep-nlp]
  • Deployment [using docker compose, to a hosted environment such as Render]

msg540728521-348

How does the automatic-summarization and vector search integrate into the prompts?

I'm trying to understand better how the auto-summarization and vector search get included in the prompt templates when using as part of a LLMChain or Chat Agent. In the documentation and sample it shows it working, but it doesn't show the formated prompt that is used for summarization, or how the search pulls potentially relevant conversations from use in the prediction.

To the end, I tried to hook it up on a simple LLMChain with message template but it doesn't look like it worked. Do you know what may be going on here?

from langchain.prompts import (
    ChatPromptTemplate,
    MessagesPlaceholder,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)
from langchain.chains import ConversationChain
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory, ConversationSummaryBufferMemory


BASE_PROMPT = """
The following is a friendly texting conversation between a Human and an AI. 
The AI is talkative and provides lots of specific details from its context. 
If the AI does not know the answer to a question, tells the human as such.

Please use markdown in your output format.
"""

# Set up Zep Chat History
zep_chat_history = ZepChatMessageHistory(
    session_id='TestSession',
    url=ZEP_API_URL,
)

# Use a standard ConversationBufferMemory to encapsulate the Zep chat history
memory = ConversationBufferMemory(
    memory_key="chat_history", chat_memory=zep_chat_history, ai_prefix="AI", 
)

zep_chat_history.add_user_message("Hello, how are you?")
zep_chat_history.add_ai_message("I am doing well, how are you?")

# Initialize the agent
llm = ChatOpenAI(temperature=0.8)

prompt = ChatPromptTemplate.from_messages(
    [
        SystemMessagePromptTemplate.from_template(BASE_PROMPT),
        MessagesPlaceholder(variable_name="chat_history"),
        HumanMessagePromptTemplate.from_template("{input}"),
    ]
)
conversation = ConversationChain(memory=memory, prompt=prompt, llm=llm)

result = conversation.run(input="Great! Thanks for asking!")

The output error

Cell In[26], line 46
     37 prompt = ChatPromptTemplate.from_messages(
     38     [
     39         SystemMessagePromptTemplate.from_template(BASE_PROMPT),
   (...)
     42     ]
     43 )
     44 conversation = ConversationChain(memory=memory, prompt=prompt, llm=llm)
---> 46 result = conversation.run(input="Great! Thanks for asking!")

File [c:\Users\jayfd\anaconda3\envs\family-gpt\lib\site-packages\langchain\chains\base.py:239](file:///C:/Users/jayfd/anaconda3/envs/family-gpt/lib/site-packages/langchain/chains/base.py:239), in Chain.run(self, callbacks, *args, **kwargs)
    236     return self(args[0], callbacks=callbacks)[self.output_keys[0]]
    238 if kwargs and not args:
--> 239     return self(kwargs, callbacks=callbacks)[self.output_keys[0]]
    241 if not kwargs and not args:
    242     raise ValueError(
    243         "`run` supported with either positional arguments or keyword arguments,"
    244         " but none were provided."
    245     )

File [c:\Users\jayfd\anaconda3\envs\family-gpt\lib\site-packages\langchain\chains\base.py:140](file:///C:/Users/jayfd/anaconda3/envs/family-gpt/lib/site-packages/langchain/chains/base.py:140), in Chain.__call__(self, inputs, return_only_outputs, callbacks)
    138 except (KeyboardInterrupt, Exception) as e:
    139     run_manager.on_chain_error(e)
...
     47 for v in value:
     48     if not isinstance(v, BaseMessage):

ValueError: variable chat_history should be a list of base messages, got Human: Hello, how are you?
AI: I am doing well, how are you?

Hi, Zep team, there is a scenario for discussion

hi, Zep team:

Thanks for the project!
Here is the scenario:
I am building an AI assistant APP, AI will be told something in the conversation.
Currently, the session_id is a must for query, but for my case, I need to query all the related chat history.

For example, the user could told AI something in one conversation, and need to extract memory in another conversation.
Is there a way to do this or is it in the future plan?

Thanks.

not a bug, but can you share more detailed documentation on authentication process for render?

hi, am posting here as i didn't see a discussions tab.

just wondering, is there more detailed documentation on the authentication process for render setup / deployment?

not sure if i need to the command linds in the "shell" tab, or else where?

hopefully future people looking to deploy via render will also find this informative?

thank you so much! look forward to "zepping" my memory away!

Question: Langchain entities and vector chat memory support?

Hey, first of all great work here. This is pretty awesome. I'm trying to use this to enable long term memory in a chat bot application. My first question is regarding entities. I know you extract entities but is that supported with langchain? I'm not seeing the entities metadata in my chat messages that I retrieve from memory.

Also, I can do the vector search using the retriever in langchain, but it returns documents with no information on who those messages belong to (AI or Human). Is there a way to get that information?

I'd be more than happy to help any way I can, just let know. Thanks!

Zep_summary agent tool

Hello everyone, I have set up a Zep server to provide my AI agent with long-term memory.
The server is functioning as intended, but I am now trying to implement a tool that allows the agent to handle and retrieve a summary of our previous discussions.

However, I'm facing a problem - it simply doesn't work. I'm particularly confused about the second code snippet and can't wrap my head around it. I'm hoping for some assistance from a more experienced coder.

Thank you so much.

from langchain.memory.chat_message_histories import ZepChatMessageHistory

'memory.py'

`def memory():

session_id = str(uuid.uuid4())  # This is a unique identifier for the user
load_dotenv()
True
# Set up Zep Chat History
zep_chat_history = ZepChatMessageHistory(
    session_id=session_id,
    url="http://localhost:8080",
)

template = """You are an AI agent created by davesoma

{chat_history}
Human: {human_input}
Chatbot:"""

prompt = PromptTemplate(
    input_variables=["chat_history", "human_input"], 
    template=template
)
memory = ConversationBufferMemory(memory_key="chat_history", chat_memory = zep_chat_history)

return {"memory": memory, "zep_chat_history": zep_chat_history.zep_summary}`

Then, the idea is to retrieve 'zep_chat_history' and use it as a parameter for the following tool

`zep_chat_history = memory()["zep_chat_history"]

def memory_summary(zep_chat_history):
for m in zep_chat_history:
print(m.to_dict())

    return zep_chat_history.zep_summary`

If I try to run it in a separate script, it throws this error.

Session bc42e300-289a-4af4-9324-95d74eb64eca not found in Zep. Returning None Traceback (most recent call last): File "/home/davesoma/ds/zep_summary.py", line 13, in <module> print(zep_chat_history.zep_summary) AttributeError: 'NoneType' object has no attribute 'zep_summary'

Here's a snippet of the retrieve tool in 'main.py'

Tool( name="Long-term memory", func=memory_summary, description="usefull to retrieve past discussions", ),

Great package, excited to use it, unable to get it working on myside

Hi Zep,

Great package. I'm having a bit of difficulty getting the local development quick start to work. It looks like it is failing on the "Search" section, where it also failed when i was trying the langchain implementation. Here's the error message from zep:

failure2.txt

I was running this line from the sample quickstart code in zep-python.
search_payload = SearchPayload(text="Who is Yuri Gagarin?")

Any ideas what may have gone wrong with my local install?

Langchain agent

Hello. I am trying to integrate Zep into my AI agent, but I have encountered a problem. Given my lack of experience, I am struggling to resolve it, and I trust in your patience to help me through this.

Each time I start my agent, Docker throws me an error. Here it is:

2023-06-19 14:02:00 time="2023-06-19T12:02:00Z" level=info msg="http://localhost:8080/api/v1/sessions/193bff5b-4ebe-4915-b9bb-362cf2933906/memory" bytes=10 category=router duration=95580370 duration_display=95.581852ms method=GET proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=404 2023-06-19 14:02:19 time="2023-06-19T12:02:19Z" level=info msg="http://localhost:8080/api/v1/sessions/193bff5b-4ebe-4915-b9bb-362cf2933906/memory" bytes=2 category=router duration=65056443 duration_display=65.057435ms method=POST proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=200 2023-06-19 14:02:19 time="2023-06-19T12:02:19Z" level=info msg="http://localhost:8080/api/v1/sessions/193bff5b-4ebe-4915-b9bb-362cf2933906/memory" bytes=2 category=router duration=25285558 duration_display=25.28644ms method=POST proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=200 2023-06-19 14:02:20 time="2023-06-19T12:02:20Z" level=error msg="ROLLBACK[1.892µs]: ROLLBACK: sql: transaction has already been committed or rolled back" 2023-06-19 14:02:21 time="2023-06-19T12:02:21Z" level=error msg="ROLLBACK[1.632µs]: ROLLBACK: sql: transaction has already been committed or rolled back"

and this is the memory function from the client side

`
def memory():

session_id = str(uuid.uuid4())  # This is a unique identifier for the user
load_dotenv()
True
# Set up Zep Chat History
zep_chat_history = ZepChatMessageHistory(
    session_id=session_id,
    url="http://localhost:8080",
)

template = """example.

{chat_history}
Human: {human_input}
Chatbot:"""

prompt = PromptTemplate(
    input_variables=["chat_history", "human_input"], 
    template=template
)
memory = ConversationBufferMemory(memory_key="chat_history", chat_memory = zep_chat_history)
# history = ChatMessageHistory()
# memory.chat_memory.add_ai_message("example")



return memory

`

Zep server returns 404 error when queried by LangChain vector store retriever

I have a a conversation retrieval QA setup following these docs. Everything was working fine until the recent updates to the zep-server. Now, I am able to connect to the zep server from the client, but sending queries to the retrieval action ends up in a 404 error on the zep server side. I am on the latest version for both the zep server 0.11.0 and the zep js client 0.7.0

Here are the zep server logs

zep           | time="2023-09-01T23:35:16Z" level=info msg="http://localhost:8000/healthz" bytes=1 category=router duration=468208 duration_display="474.375µs" method=GET proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=200
zep           | time="2023-09-01T23:35:16Z" level=info msg="http://localhost:8000/api/v1/collection/fever" bytes=333 category=router duration=5930709 duration_display=5.931125ms method=GET proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=200
zep           | time="2023-09-01T23:35:16Z" level=info msg="http://localhost:8000/api/v1/collection/fever/search%3Flimit=4" bytes=19 category=router duration=105459 duration_display="105.917µs" method=POST proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=404

Here is the code on the client side that connects to the server and sends the request

const zepConfig: IZepConfig = {
    apiUrl: env.ZEP_SERVER_URL ?? "http://localhost:8000", // the URL of your Zep implementation
    collectionName: "fever",  // the name of your collection. alphanum values only
};

const embeddings = new FakeEmbeddings();

// Connect to the Zep vector store server
const vectorStore = await new ZepVectorStore(embeddings, zepConfig);

const chain = ConversationalRetrievalQAChain.fromLLM(
  streamingModel,
  vectorStore.asRetriever({
      verbose: true,
  }),
  {
      memory: new BufferMemory({
          memoryKey: "chat_history", // Must be set to "chat_history"
          inputKey: "question", // The key for the input to the chain
          outputKey: "text", // The key for the final conversational output of the chain
          returnMessages: true, // If using with a chat model
      }),
      returnSourceDocuments: true,
      questionGeneratorChainOptions: {
          llm: nonStreamingModel,
          template: CUSTOM_QUESTION_GENERATOR_CHAIN_PROMPT
      },
  },
);

Here are some verbose logs on the client side

ZepVectorStore {
  lc_serializable: false,
  lc_kwargs: { apiUrl: 'http://localhost:8000', collectionName: 'fever' },
  lc_namespace: [ 'langchain', 'vectorstores', 'zep' ],
  embeddings: FakeEmbeddings {
    caller: AsyncCaller {
      maxConcurrency: Infinity,
      maxRetries: 6,
      queue: [PQueue]
    }
  },
  client: undefined,
  collection: undefined,
  initPromise: Promise { <pending> },
  autoEmbed: true
}
[retriever/start] [1:retriever:VectorStoreRetriever] Entering Retriever run with input: {
  "query": "test"
}
[retriever/error] [1:retriever:VectorStoreRetriever] [35ms] Retriever run errored with error: "Resource not found."

I get an error if there is no message in the first conversation

If I start a new conversation, I get the error "Missing value for input history" if there is no message stored in the current session id.

Messages are only created when I pass promt variable to ConversationChain class. But this way history does not work.

The node.js code in Langchain official documentation is not working. I replaced chain.call with chain.run.

const sessionId = "TestSession1234";
const zepURL = "http://localhost:8000";

const memory = new ZepMemory({
  sessionId,
  baseURL: zepURL,
});

const model = new ChatOpenAI({
  modelName: "gpt-3.5-turbo",
  temperature: 0,
});

const chain = new ConversationChain({ llm: model, memory });

const res1 = await chain.run("Hi! I'm Jim.");
console.log({ res1 });

const res2 = await chain.run("What did I just say my name was?");
console.log({ res2 });

Azure OpenAI Endpoint

Hi guys great solution, however this does not appear to be working:

"ZEP_OPENAI_API_KEY=*******************************************",
"ZEP_LLM_AZURE_OPENAI_ENDPOINT=**************************",

I get this in the docker logs so it looks like it continues to try and use the key with OpenAI:

level=error msg="SummaryExtractor extract failed: extractor error: SummaryExtractor summarize failed (original error: error, status code: 401, message: Incorrect API key provided: 04e0e844********************2687. You can find your API key at https://platform.openai.com/account/api-keys.)"

The above key and endpoint work and are currently used in my Langchain setup.

I appreciate this feature is experimental but if you could look at it that would be great :)

[FEAT] Publish a JSON Schema of the configuration file

Is your feature request related to a problem? Please describe.

I want to generate types for TypeScript for the config file.

Describe the solution you'd like

Ideally, an official and published JSON Schema for the config file would be great.

This can also enable users to use it in the IDE, given a $schema key and the URL of the schema in the config file.

Describe alternatives you've considered

N/A

Additional context

I think something like this should work?

https://github.com/invopop/jsonschema

ModuleNotFoundError: No module named 'zep_python'

I installed the module with "pip install zep_python" and I use "pip show zep_python"

Name: zep-python
Version: 0.30
Summary: Zep stores, manages, enriches, indexes, and searches long-term memory for conversational AI applications. This is the Python client for the Zep service.
Home-page:
Author: Daniel Chalef
Author-email: [email protected]
License:
Location: D:\OneDrive\David\Learning\SIF\ChatGPT\zep\myenv\Lib\site-packages
Requires: httpx, pydantic
Required-by:

But when I run the app, it always said ModuleNotFoundError: No module named 'zep_python'

when I want to install the newest version (0.5.1), it said "WARNING: Package(s) not found: zep_python==0.5.1"

Can you help ? TIA

Add a way to customize the session summarization prompt template via settings

User story:
As a ZEP user, I would like to be able to customize the prompt text and input variables used to process the memory of a session

Initial discussion:
I would like to implement this feature into zep. I do not have much knowledge of golang but would like to give this a try. Couple questions:

  • Is the config/config.go file the place I should place this config setting?
  • Any suggestions you have in mind about how to approach this?

Authentication Example has Syntax Errors (Javascript)

Hi!

On the SDK page at https://docs.getzep.com/sdk/#installation

This line was given:

// Replace with Zep API URL and (optionally) API key
const zep = new ZepClient("http://localhost:8000", apiKey="optional_key");

Sadly, that is not valid javascript syntax - looks like it was copied from the python example.

I tried inspecting the SDK source, and the 2nd arg to the ZepClient constructor is some axios options object. I assumed that perhaps I could set some header value with the JWT for the key, but I couldn't find any examples anywhere on the docs site of authentication even with plain REST, and the REST page itself doesn't mention authentication (https://docs.getzep.com/sdk/api/)

I was able to get the javscript SDK working without authentication, but I would like to use authentication if possible. Can you tell me how I should supply the JWT I generated to your SDK? Thank you for your help!

Add session doesn't store metadata in postgres

Hi,
I am using the below snippet to add a session corresponding to a user, but it is not saving the metadata in database. Next time I retrieve it, it gives error that metadata cannot be null. I have checked it in the database as well, session table doesn't have metadata.

zep_session = Session(
                session_id=str(session.id), user_id=str(user_id), metadata={'title': str(session.title), 'is_deleted': False}
            )
print("printing the session to store", zep_session)
try:
    result = self.zep_client.memory.add_session(zep_session)
    print(f"Created session {session} with result: {result}")
except APIError as e:
    print(f"Failed to create session {session}: {e}")
    return saved

[BUG] Kubernetes deployment.yaml file has two issues

I have spent a few days working out the kinks deploying Zep to GCP Kubernetes Engine and I found two major issues that I think I have solutions for. I was going to submit a pull request, but wanted to check here first in case I was missing something.

First, there is seemingly a Typo in the deployment.yaml file. It should be ZEP_STORE_POSTGRES_DSN not ZEP_MEMORY_STORE_POSTGRES_DSN

Second, I had all kinds of trouble with the healthcheck and the solution was to remove host: 127.0.0.1 entirely from the healthcheck and that solved the issue for me.

And not a bug, but in case someone else is looking for this, I was able to use a managed SQL Postgres instance instead of the docker/k8s based one and that seems to be working just fine. I did enable the pgvector extension, but it supports it with no apparent issues.

Thanks all,
-Corey

[BUG] failed to Create documents: failed to insert documents: write tcp 172.18.0.4:48130->172.18.0.3:5432: write: connection reset by peer

I am creating a large index using ZepVectorStore with this code

        llm = OpenAI(model="gpt-3.5-turbo-16k", temperature=0.1)
        
        service_context = ServiceContext.from_defaults(chunk_size=512, llm=llm)

        from llama_index.storage.storage_context import StorageContext
        from llama_index.vector_stores import ZepVectorStore

        zep_api_url = "http://localhost:9000"
        collection_name = "collection_name"

        vector_store = ZepVectorStore(
            api_url=zep_api_url, collection_name=collection_name, embedding_dimensions=1536
        )

        storage_context = StorageContext.from_defaults(vector_store=vector_store)

        index = VectorStoreIndex.from_documents(documents,show_progress=True,service_context=service_context,storage_context=storage_context)

On Zep Docker Logs:

zep-postgres | 2023-10-06 02:41:38.844 UTC [62] LOG:  invalid message length
zep    | time="2023-10-06T02:41:38Z" level=error msg="failed to Create documents: failed to insert documents: write tcp 172.18.0.4:48130->172.18.0.3:5432: write: connection reset by peer"
zep    | time="2023-10-06T02:41:38Z" level=info msg="http://localhost:9000/api/v1/collection/smconfidential/document" bytes=133 category=router duration=79512706290 duration_display=1m19.512710596s method=POST proto=HTTP/1.1 remote_ip=172.18.0.1 status_code=500

In the beginning it saved the index to the postgres without a problem. But I added a few more documents to the index, and now it won't save at all.

Can you point me to the right direction on how to solve this issue?

Thanks in advance.

Intent Extractor error after Session delete

Appears to occur after a session delete.

ERRO[2023-06-24T16:31:45-07:00] BaseMemoryStore NotifyExtractors failed: extractor error: IntentExtractor: Extract Failed (original error: extractor error: IntentExtractor: Extract Failed (original error: extractor error: IntentExtractor failed to put message metadata: storage error: failed to put message metadata (original error: storage error: failed to put message metadata (original error: storage error: failed to retrieve existing metadata (original error: sql: no rows in result set))) (original error: storage error: failed to put message metadata (original error: storage error: failed to put message metadata (original error: storage error: failed to retrieve existing metadata (original error: sql: no rows in result set)))); extractor error: IntentExtractor failed to put message metadata: storage error: failed to put message metadata (original error: storage error: failed to put message metadata (original error: storage error: failed to retrieve existing metadata (original error: sql: no rows in result set))) (original error: storage error: failed to put message metadata (original error: storage error: failed to put message metadata (original error: storage error: failed to retrieve existing metadata (original error: sql: no rows in result set))))))

Hosting Zep in Kubernetes?

Hey wonderful people!

How would I go about hosting Zep in a k8s cluster or docker in general?

Obviously I see you have some Dockerfiles in the repo, just curious about data persistance.

  1. Can I use a PVC? I use DigitalOcean to host my k8s cluster, and I know they can connect a persistent volume to a pod which can obviously store data. (Ref: https://docs.digitalocean.com/products/kubernetes/how-to/add-volumes/)
  2. Can I connect Zep to an external Postgres server, making the Zep docker image stateless? (DO does also have managed hosted Postgres servers that I connect to from my k8s cluster, https://www.digitalocean.com/products/managed-databases-postgresql - so if I can override the DSN or something ...?)

Other than data persistence, any tips or examples of hosting Zep in a k8s cluster?

Exceptions when using

Hello.
Zep looks promising for my needs, and I'm trying to use it with LangChain (currently 0.0.178), and have couple of issues.
Docker is up and running. Below is a code from a part of FastAPI app.

Issue 1:

Following code gives exception:

try:
                    zep_chat_history = ZepChatMessageHistory(
                        session_id=session_id,
                        url=ZEP_API_URL,
                    )
                    zep_chat_history.append(HumanMessage(content="First Message"))
                    print(zep_chat_history.zep_summary)
                    memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=zep_chat_history,
                                                      return_messages=True, )
                except Exception as e:
                    print(f"An exception occurred: {str(e)}")

An exception occurred: this event loop is already running.
Probably something easy, but i'm newbie in Python.

Also tried adding, which gave same result.

import nest_asyncio
nest_asyncio.apply()

Issue 2:

Use following code, followed by agent call:

zep_chat_history = ZepChatMessageHistory(
                        session_id=session_id,
                        url=ZEP_API_URL,
                    )
memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=zep_chat_history,
                                                      return_messages=True, )

agent.run("hello")
Results in trace:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-4' coro=<ZepClient.aget_memory() done, defined at .../lib/python3.10/site-packages/zep_python/zep_client.py:111> exception=NotFoundError('No memory found for session 71e0d8d3-3cc1-4ddf-a19f-5065ea794173')>
Traceback (most recent call last):
  File ".../lib/python3.10/site-packages/zep_python/zep_client.py", line 143, in aget_memory
    raise NotFoundError(f"No memory found for session {session_id}")
zep_python.exceptions.NotFoundError: No memory found for session 71e0d8d3-3cc1-4ddf-a19f-5065ea794173

Any advice please?

EmbeddingExtractor Error on put message vectors

Zep server throws: Duplicate Key Value error on message_embedding_uuid_key. Should we consider returning a Response Body in the 200 OK to provide some additional error information back to the Client SDKs? Or alternatively consider a different Response Code?

zep | time="2023-05-15T20:38:16Z" level=error msg="EmbeddingExtractor extract failed: extractor error: EmbeddingExtractor put message vectors failed (original error: storage error: failed to put embeddings (original error: storage error: failed to insert message vectors (original error: ERROR: duplicate key value violates unique constraint "message_embedding_message_uuid_key" (SQLSTATE=23505))))"

eted_at": ERROR: duplicate key value violates unique constraint "message_embedding_message_uuid_key" (SQLSTATE=23505)"
zep | time="2023-05-15T20:38:17Z" level=error msg="EmbeddingExtractor extract failed: extractor error: EmbeddingExtractor put message vectors failed (original error: storage error: failed to put embeddings (original error: storage error: failed to insert message vectors (original error: ERROR: duplicate key value violates unique constraint "message_embedding_message_uuid_key" (SQLSTATE=23505))))"

[HELP] How to merge multiple indexes into one ?

Hi,

I want to create several collections in my Zep server, and then when a prompt/query arrives, I want to combine several collections into one index and be able to query the combined index.
Is this even possible?

What I tried to do, unsuccessfully, is something like:

def load_zep(collection_name):
        vector_store = ZepVectorStore(
            api_url=zep_api_url, collection_name=collection_name
        )

        return StorageContext.from_defaults(vector_store=vector_store,persist_dir=f'./storage/{collection_name}')
                from llama_index import load_index_from_storage, StorageContext

                #load different collections 
                storage_context1 = load_zep('collection1')
                storage_context2 = load_zep('collection2')
                storage_context3 = load_zep('collection3')

                #some how combine the above 3 collections into one

                #tried various ways like combined = list(), but nothing worked

                #load index from above combined 
                index = load_index_from_storage(combined) 

The logic behind this is I have various user levels and based on the user I want to give them a different index. Higher level users gets more indexes, while low level user gets a single index to query. I don't want to create the same index over and over if I can combine them somehow.

Thanks in advance!

Errors in aadd_session

Working from this blog post:

https://www.getzep.com/session-metadata-alternative-openai-endpoints-and-kubernetes-deployment/

@history_blueprint.route('/history/createSession', methods=['GET', 'POST'])
async def createSession():
  session_id = uuid.uuid4().hex
  print(f"Creating session: {session_id}")
  try:
      session = Session(session_id=session_id, metadata={})
      result = await ZepClient(base_url).aadd_session(session)
      print(result)
      return session_id, 200
  except APIError as e:
      print(f"Unable to create session {session_id} got error: {e}")
      return f"Unable to create session {session_id} got error: {e}", 500

When I try to hit this endpoint, I keep getting a 404 error. The code I have is pretty much what was in the blog post. I'm not sure what I could change to make this work aside from hitting the REST API directly.

Creating session: 7e91fd0398a84c4a8551306f9b932680
127.0.0.1 - - [20/Jul/2023 11:31:22] "GET /history/createSession HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/lidju/Documents/repos/atlantis-gpt/server/history.py", line 17, in createSession
    result = await ZepClient(base_url).aadd_session(session)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/zep_python/zep_client.py", line 290, in aadd_session
    self._handle_response(response, f"Failed to add session {session.session_id}")
  File "/Users/lidju/.pyenv/versions/3.11.0/lib/python3.11/site-packages/zep_python/zep_client.py", line 105, in _handle_response
    raise NotFoundError(missing_message)
zep_python.exceptions.NotFoundError: Failed to add session 7e91fd0398a84c4a8551306f9b932680: None

bug: no /app/config.yaml file

when docker-compose up in the zep project
it outputs

level=fatal msg="Error configuring Zep: open /app/config.yaml: no such file or directory"

where is the /app/config.yaml file ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.