-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
refactor: classes and configs #528
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ctor/ClassesAndConfigs
@cachho : can you please resolve the conflicts here? |
This was
linked to
issues
Sep 5, 2023
taranjeet
pushed a commit
that referenced
this pull request
Sep 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I want to share my WIP refactor and the thoughts behind it.
We currently have a problem with classes and methods being mixed into other classes, where they don't belong. Often times, it doesn't only make little sense from a logical standpoint, it also makes everything harder to maintain. For instance the collection name is clearly a database attribute, yet we go out of our way to assign it to the class.
Here's the new concept:
The app class is the highest in the hierarchy and has multiple equal subclasses
By subclasses I mean logical subclasses and not parent and child classes in python.
llm
is what's currently theQueryConfig
, so the name might change. But it's everything that has to do with how you interact with the llm, such as max tokens, temperature, etc.app.embedding
is a new concept I came up with, that unitesembedding_function
,ChunkerConfig
andLoaderConfig
. From a language standpoint, it might make more sense to call itembedder
.Not coincidentally, these 3 parts are the interchangeable parts.
Each one of these parts has its own config. This way they are all accessible from the main app
AppConfig
is kind of obsolete, because everything falls into one of the three categories. As my PR stands right now, this can already be seen, all that's left islog_level
,id
(which should go to database too) andcollect_metrics
.For the
App
,CustomApp
andOpenSourceApp
the idea is similar to know, it will just take away some of the config options and provide a opinionated default.Outcome
The interface is then
app = App(llm=Llm(), db=VectorDb(), embedding=Embedding())
. In it's longest form with all configs it'sapp = App(llm=Llm(config=LlmConfig()), db=VectorDb(config=DbConfig()), embedding=Embedding(config=EmbeddingConfig()))
. Yes, this is longer, but it's also more logical. If you have an opinionated app, it will also be shorter.Main purpose
The main purpose besides being more logical is that it will make the app easier to serialize. You have hierarchical components.
so in a json format it would be
currently it's something like this, and some options are not even connected to the app.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Please delete options that are not relevant.
Checklist:
Maintainer Checklist