Skip to content

Commit

Permalink
MQTT Startup Refactoring Part 1: core/ packages part 1 (#1728)
Browse files Browse the repository at this point in the history
This PR specifically introduces a `core` folder and moves the following packages over, without any other changes:

- `api/backend`
- `api/config`
- `api/options`
- `api/schema`

Once this is merged and we confirm there's no regressions, I can migrate over the remaining changes piece by piece to split up application startup, backend services, http, and mqtt as was the goal of the earlier PRs!
  • Loading branch information
dave-gray101 authored Feb 21, 2024
1 parent 594eb46 commit 255748b
Show file tree
Hide file tree
Showing 38 changed files with 93 additions and 90 deletions.
4 changes: 2 additions & 2 deletions api/localai/backend_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"strings"

config "github.com/go-skynet/LocalAI/api/config"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/pkg/grpc/proto"

"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/options"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"

Expand Down
2 changes: 1 addition & 1 deletion api/localai/gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
json "github.com/json-iterator/go"
"gopkg.in/yaml.v3"

config "github.com/go-skynet/LocalAI/api/config"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/pkg/gallery"
"github.com/go-skynet/LocalAI/pkg/utils"

Expand Down
6 changes: 3 additions & 3 deletions api/localai/localai.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package localai

import (
"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
fiberContext "github.com/go-skynet/LocalAI/api/ctx"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/rs/zerolog/log"

"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/options"
"github.com/gofiber/fiber/v2"
)

Expand Down
8 changes: 4 additions & 4 deletions api/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"strings"
"time"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/go-skynet/LocalAI/pkg/grammar"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/go-skynet/LocalAI/pkg/utils"
Expand Down
8 changes: 4 additions & 4 deletions api/openai/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"fmt"
"time"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/go-skynet/LocalAI/pkg/grammar"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/gofiber/fiber/v2"
Expand Down
8 changes: 4 additions & 4 deletions api/openai/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"time"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
Expand Down
8 changes: 4 additions & 4 deletions api/openai/embeddings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"fmt"
"time"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/google/uuid"

"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/options"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
)
Expand Down
11 changes: 6 additions & 5 deletions api/openai/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"encoding/json"
"errors"
"fmt"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
"os"
"path/filepath"
"time"

config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
)

var uploadedFiles []File
Expand Down
11 changes: 6 additions & 5 deletions api/openai/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ package openai
import (
"encoding/json"
"fmt"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
utils2 "github.com/go-skynet/LocalAI/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
"io"
"mime/multipart"
"net/http"
Expand All @@ -16,6 +11,12 @@ import (
"path/filepath"
"strings"

config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
utils2 "github.com/go-skynet/LocalAI/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"

"testing"
)

Expand Down
8 changes: 4 additions & 4 deletions api/openai/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"strings"
"time"

"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/google/uuid"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
Expand Down
8 changes: 4 additions & 4 deletions api/openai/inference.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package openai

import (
"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
model "github.com/go-skynet/LocalAI/pkg/model"
)

Expand Down
4 changes: 2 additions & 2 deletions api/openai/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package openai
import (
"regexp"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/schema"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/schema"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/gofiber/fiber/v2"
)
Expand Down
6 changes: 3 additions & 3 deletions api/openai/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"net/http"
"strings"

config "github.com/go-skynet/LocalAI/api/config"
fiberContext "github.com/go-skynet/LocalAI/api/ctx"
options "github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
config "github.com/go-skynet/LocalAI/core/config"
options "github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/go-skynet/LocalAI/pkg/grammar"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/gofiber/fiber/v2"
Expand Down
6 changes: 3 additions & 3 deletions api/openai/transcription.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"path"
"path/filepath"

"github.com/go-skynet/LocalAI/api/backend"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/backend"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"

"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
Expand Down
2 changes: 1 addition & 1 deletion backend/go/transcribe/transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/ggerganov/whisper.cpp/bindings/go/pkg/whisper"
"github.com/go-audio/wav"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/schema"
)

func sh(c string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion backend/go/transcribe/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package main
// It is meant to be used by the main executable that is the server for the specific backend type (falcon, gpt3, etc)
import (
"github.com/ggerganov/whisper.cpp/bindings/go/pkg/whisper"
"github.com/go-skynet/LocalAI/api/schema"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/go-skynet/LocalAI/pkg/grpc/base"
pb "github.com/go-skynet/LocalAI/pkg/grpc/proto"
)
Expand Down
4 changes: 2 additions & 2 deletions api/backend/embeddings.go → core/backend/embeddings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package backend
import (
"fmt"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/grpc"
model "github.com/go-skynet/LocalAI/pkg/model"
)
Expand Down
4 changes: 2 additions & 2 deletions api/backend/image.go → core/backend/image.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package backend

import (
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/grpc/proto"
model "github.com/go-skynet/LocalAI/pkg/model"
)
Expand Down
4 changes: 2 additions & 2 deletions api/backend/llm.go → core/backend/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sync"
"unicode/utf8"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/gallery"
"github.com/go-skynet/LocalAI/pkg/grpc"
model "github.com/go-skynet/LocalAI/pkg/model"
Expand Down
4 changes: 2 additions & 2 deletions api/backend/options.go → core/backend/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
pb "github.com/go-skynet/LocalAI/pkg/grpc/proto"
model "github.com/go-skynet/LocalAI/pkg/model"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
)

func modelOpts(c config.Config, o *options.Option, opts []model.Option) []model.Option {
Expand Down
6 changes: 3 additions & 3 deletions api/backend/transcript.go → core/backend/transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/schema"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/schema"

"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/grpc/proto"
model "github.com/go-skynet/LocalAI/pkg/model"
)
Expand Down
7 changes: 3 additions & 4 deletions api/backend/tts.go → core/backend/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"os"
"path/filepath"

api_config "github.com/go-skynet/LocalAI/api/config"
config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/grpc/proto"
model "github.com/go-skynet/LocalAI/pkg/model"
"github.com/go-skynet/LocalAI/pkg/utils"
Expand Down Expand Up @@ -38,7 +37,7 @@ func ModelTTS(backend, text, modelFile string, loader *model.ModelLoader, o *opt

grpcOpts := gRPCModelOpts(c)

opts := modelOpts(api_config.Config{}, o, []model.Option{
opts := modelOpts(config.Config{}, o, []model.Option{
model.WithBackendString(bb),
model.WithModel(modelFile),
model.WithContext(o.Context),
Expand Down
2 changes: 1 addition & 1 deletion api/config/config.go → core/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api_config
package config

import (
"errors"
Expand Down
6 changes: 3 additions & 3 deletions api/config/config_test.go → core/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package api_config_test
package config_test

import (
"os"

. "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/options"
. "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/pkg/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion api/config/prediction.go → core/config/prediction.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api_config
package config

type PredictionOptions struct {

Expand Down
8 changes: 4 additions & 4 deletions api/api.go → core/http/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api
package http

import (
"encoding/json"
Expand All @@ -7,11 +7,11 @@ import (
"os"
"strings"

config "github.com/go-skynet/LocalAI/api/config"
"github.com/go-skynet/LocalAI/api/localai"
"github.com/go-skynet/LocalAI/api/openai"
"github.com/go-skynet/LocalAI/api/options"
"github.com/go-skynet/LocalAI/api/schema"
config "github.com/go-skynet/LocalAI/core/config"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/core/schema"
"github.com/go-skynet/LocalAI/internal"
"github.com/go-skynet/LocalAI/metrics"
"github.com/go-skynet/LocalAI/pkg/assets"
Expand Down
6 changes: 3 additions & 3 deletions api/api_test.go → core/http/api_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api_test
package http_test

import (
"bytes"
Expand All @@ -13,8 +13,8 @@ import (
"path/filepath"
"runtime"

. "github.com/go-skynet/LocalAI/api"
"github.com/go-skynet/LocalAI/api/options"
. "github.com/go-skynet/LocalAI/core/http"
"github.com/go-skynet/LocalAI/core/options"
"github.com/go-skynet/LocalAI/metrics"
"github.com/go-skynet/LocalAI/pkg/downloader"
"github.com/go-skynet/LocalAI/pkg/gallery"
Expand Down
2 changes: 1 addition & 1 deletion api/apt_suite_test.go → core/http/apt_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api_test
package http_test

import (
"testing"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/schema/openai.go → core/schema/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package schema
import (
"context"

config "github.com/go-skynet/LocalAI/api/config"
config "github.com/go-skynet/LocalAI/core/config"

"github.com/go-skynet/LocalAI/pkg/grammar"
)
Expand Down
File renamed without changes.
Loading

0 comments on commit 255748b

Please sign in to comment.