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

Add custom redis cache #33

Merged
merged 28 commits into from
Aug 2, 2023
Merged

Add custom redis cache #33

merged 28 commits into from
Aug 2, 2023

Conversation

grski
Copy link
Collaborator

@grski grski commented Jul 15, 2023

For now, we do the simplest approach possible, meaning we cache the results in Redis. Using exact match strategy. In the future this should be extended to other stores and similarity based matching to enable true semantic caching. For that vector store handling needs to be added. Proper exception handling.

Validations and defaults for environment variables were added using pydantic and python-dotenv for local setup. In the future this should be used to load and validate all the env variables as it's currently the preferred go-to approach in Python world.
Tests need to be added, but for that to happen I think we should refactor the whole testing approach.

Pipelines will fail coz of some lints that are still left out there to be fixed and some tests that were broken since the beginning. We also need to work on that.

Documentation to follow if this implementation is deemed merge-worthy.

@grski grski changed the title Ishaan allow custom vector d bs Add custom redis cache Jul 15, 2023
@grski
Copy link
Collaborator Author

grski commented Jul 15, 2023

Did a small refactor and encapsualted the default cache that you've used. it probably still needs some work to achieve full integration though.

@grski
Copy link
Collaborator Author

grski commented Jul 17, 2023

@ishaan-jaff @krrishdholakia any opinions so far guys? This needs some love & testing, will gladly help, but I need the intial approval to push things forward.

@grski
Copy link
Collaborator Author

grski commented Jul 18, 2023

any feedback here...?

@ishaan-jaff
Copy link
Contributor

Sorry for the delay @grski will take a look and respond by EOD

@grski
Copy link
Collaborator Author

grski commented Jul 18, 2023

thank you very much, no need to hurry if you have other priorities, the information is enough that you have this on the todo list, no worries :)

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI t's failing a test due to a missing redis import. Once that's fixed should be good to merge

reliablegpt/settings.py Show resolved Hide resolved
@grski
Copy link
Collaborator Author

grski commented Jul 21, 2023

@ishaan-jaff @krrishdholakia
It's finally done. The tests pass. Linting applied. No conflicts with main (it's merged into this branch).

@@ -33,7 +33,7 @@ jobs:
with:
poetry-version: 1.3.2
- name: Install dependencies
run: poetry install
run: poetry install --all-extras
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in ci/cd all extras should be included

return {"choices": [{"message": {"content": extracted_result}}]}


class DefaultCache(BaseCache):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the default cache i just moved over, cleaning it up slightly

return self.map_results(extracted_result=extracted_result)


class RedisCache(BaseCache):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple redis exact match case

@grski grski requested a review from ishaan-jaff July 21, 2023 04:55
@krrishdholakia krrishdholakia merged commit faab313 into BerriAI:ishaan-allow-custom-vectorDBs Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants