-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
DRAFT: Big Refactor [prep for mqtt] #1427
Closed
Closed
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
…// HTTP sever in place, skeleton of MQTT stubbed.
…ocalai => redo them!
✅ Deploy Preview for localai canceled.
|
…er services to services
Remove file command
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.
I've ran into circular reference problems a few times while attempting larger projects within LocalAI - so I decided it was time for a major refactor to try and flatten out our dependency hierarchy into a more orderly chain. This way, we can more easily add functionality to the system!
In addition to the refactoring to change up the references, I also refactored the codebase to have a strict split between the HTTP/endpoint code and the actual LocalAI functionality.
There is also a bare stub of the MQTT functionality at this point - while it looks useless, it's actually quite important - it is there to help test for circular references while I refactor!
Below I've pasted a copy of the directory structure info I've added to the devdocs, since it also explains the refactoring here.
Directory Structure of this Repo
The core repository is broken up into the following primary chunks:
/backend
: gRPC protobuf specification and gRPC backends. Subfolders for each language./core
: golang sourcecode for the core LocalAI application. Broken down below./docs
: localai.io website that you are reading now/examples
: example code integrating LocalAI to other projects and/or developer samples and tools/internal
: here be dragons. Don't touch this, it's used for automatic versioning./models
: No code here! This is where models are installed!/pkg
: golang sourcecode that is intended to be reusable or at least widely imported across LocalAI. Broken down below/prompt-templates
: No code here! This is where example prompt templates were historically stored. Somewhat obsolete these days, model-galleries tend to replace manually creating these?/tests
: Does what it says on the tin. Please write tests and put them here when you do.The
core
folder is broken down further:/core/backend
: code that interacts with a gRPC backend to perform AI tasks./core/http
: code specifically related to the REST server/core/http/endpoints
: Has two subdirectories,openai
andlocalai
for binding the respective endpoints to the correct backend or service./core/mqtt
: core specifically related to the MQTT server. Stub for now. Coming soon!/core/services
: code implementing functionality performed bylocal-ai
itself, rather than delegated to a backend./core/startup
: code related specifically to application startup oflocal-ai
. Potentially to be refactored to become a part of/core/services
at a later date, or not.The
pkg
folder is broken down further:/pkg/assets
: Currently contains a single function related to extracting files from archives. Potentially to be refactored to become a part of/core/utils
at a later date?/pkg/datamodel
: Contains the data types and definitions used by the LocalAI project. Imported widely!/pkg/gallery
: Code related to interacting with amodel-gallery
/pkg/grammar
: Code related to BNF / functions for LLM/pkg/grpc
: base classes and interfaces for gRPC backends to implement/pkg/langchain
: langchain related code in golang/pkg/model
: Code related to loading and initializing a model and creating the appropriate gRPC backend./pkg/stablediffusion
: Code related to stablediffusion in golang./pkg/utils
: Every real programmer knows what they are going to find in here... it's our junk drawer of utility functions.