-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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]: Core/API Split #1506
Conversation
✅ Deploy Preview for localai canceled.
|
please stand-by @dave-gray101 the PR is quite big so will take some time for me to review it, but will try to have a look at it asap to avoid merge conflicts |
@dave-gray101 had to cut 2.3.1 with a couple of bugfixes so we can safely merge this too. Although now there are conflicts (sorry!) |
@mudler Pr has been updated, merged, and passes CI if now is a more clear merge window. Thanks! |
As LocalAI is designed to make use of multiple, independent model galleries, those are maintained seperately. The following public model galleries are available for use: | ||
|
||
* [go-skynet/model-gallery](https://github.com/go-skynet/model-gallery) - The original gallery, the `golang` huggingface scraper ran into limits and was largely retired, so this now holds handmade yaml configs | ||
* [dave-gray101/model-gallery](https://github.com/dave-gray101/model-gallery) - An automated gallery designed to track HuggingFace uploads and produce best-effort automatically generated configurations for LocalAI. It is designed to produce one LocalAI gallery per repository on HuggingFace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a great addition too, I don't want that to go down unnoticed, maybe also add it in the README? https://github.com/mudler/LocalAI#-community-and-integrations
@@ -183,54 +179,3 @@ func InstallModel(basePath, nameOverride string, config *Config, configOverrides | |||
|
|||
return nil | |||
} | |||
|
|||
type progressWriter struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to understand where you moved the progressWriter
, the diff is quite huge for Github hand hard to follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processWriter got moved down into pkg/utils/uri.go since unless I made a merging error somewhere along the way, it's only used within uri.go's DownloadFile
function
ok I give it a first-pass, but even if the changes are refactors/moving functions around, github makes quite difficult to read the diff, hang on and will check it once more, but it's looking in the good direction up to now. I'll have a look later at it again for a second pass |
Co-authored-by: Ettore Di Giacinto <[email protected]> Signed-off-by: Dave <[email protected]>
@dave-gray101 I think it's missing #1522 |
re-adding it back in #1532 |
A closer look made me realize this changeset skipped entirely tests as moving things to Line 339 in ab7b4d5
I'm trying to re-add it in #1532, but if many failures are getting in the way we might need to revert it |
also parts of c1888a8 are missing |
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.