langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Zep Retriever - Vector Search Over Chat History

Open danielchalef opened this issue 2 years ago • 4 comments

Zep Retriever - Vector Search Over Chat History with the Zep Long-term Memory Service

More on Zep: https://github.com/getzep/zep

Note: This PR is related to and relies on https://github.com/hwchase17/langchain/pull/4834. I did not want to modify the pyproject.toml file to add the zep-python dependency a second time.

Before submitting

Notebook included in the PR. Integration tests require a Zep service container. Let me know if this is feasible given your CI setup.

Who can review?

Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested:

@dev2049

danielchalef avatar May 11 '23 20:05 danielchalef

@dev2049 Thanks for pointing that out. Removed the class attributes. Note that this PR relies on the other Zep PR for installation of the zep-python client: https://github.com/hwchase17/langchain/pull/4834

danielchalef avatar May 12 '23 16:05 danielchalef

@dev2049 Bump on this one, too. Thanks!

danielchalef avatar May 16 '23 17:05 danielchalef

@dev2049 do you think we could do this at the same time as https://github.com/hwchase17/langchain/pull/4898?

danielchalef avatar May 18 '23 03:05 danielchalef

this seems reasonable to me! i think @dev2049 already merged in the other pr, but lets wait to announce both of them on friday?

Friday's good. Thanks!

danielchalef avatar May 18 '23 13:05 danielchalef

couple small comments but otherwise looks good! do you think it might be useful to add a to_retriever method to ZepChatMessageHistory or a from_message_history method to ZepRetriever (or both) that instantiates retriever from message history (since seems like they're based on same client/params under the hood)

Love the idea. Can we do so in a future PR? We have some other features coming - search and metadata related - that may require an update.

danielchalef avatar May 18 '23 20:05 danielchalef

looking good! could we add some tests as well?

dev2049 avatar May 18 '23 20:05 dev2049

looking good! could we add some tests as well?

Coming up. 10 minutes.

danielchalef avatar May 18 '23 20:05 danielchalef

@dev2049 Tests pushed

Took me a little longer to get the tests written. I hadn't really thought very deeply what popping would do here in terms of testing expected vs actual :-)

def _search_result_to_doc(self, results: List[SearchResult]) -> List[Document]:
        return [
            Document(
                page_content=r.message.pop("content"),
                metadata={"score": r.dist, **r.message},
            )
            for r in results
            if r.message
        ]

danielchalef avatar May 18 '23 22:05 danielchalef

Looks like github is having issues again :-(

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +03d2d1812795c619db355c36408497040e658203:refs/remotes/pull/4533/merge
  Error: fatal: unable to access 'https://github.com/hwchase17/langchain/': The requested URL returned error: 429
  The process '/usr/bin/git' failed with exit code 128
  Waiting 17 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +03d2d1812795c619db355c36408[49](https://github.com/hwchase17/langchain/actions/runs/5018751764/jobs/8998524009?pr=4533#step:2:54)7040e658203:refs/remotes/pull/4533/merge
  Error: fatal: unable to access 'https://github.com/hwchase17/langchain/': The requested URL returned error: 429
  The process '/usr/bin/git' failed with exit code 128
  Waiting 14 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +03d2d1812795c619db355c36408497040e658203:refs/remotes/pull/4533/merge
  Error: fatal: unable to access 'https://github.com/hwchase17/langchain/': The requested URL returned error: 429
  Error: The process '/usr/bin/git' failed with exit code 128

danielchalef avatar May 18 '23 22:05 danielchalef