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

DRAFT: Big Refactor [prep for mqtt] #1427

Closed
wants to merge 103 commits into from

Conversation

dave-gray101
Copy link
Collaborator

@dave-gray101 dave-gray101 commented Dec 12, 2023

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 and localai 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 by local-ai itself, rather than delegated to a backend.
  • /core/startup: code related specifically to application startup of local-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 a model-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.

Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for localai canceled.

Name Link
🔨 Latest commit 3758727
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/658c9b2f06bd81000812e237

@dave-gray101 dave-gray101 deleted the rf-config-directory branch December 29, 2023 21:09
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.

1 participant