-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ludovic LEROUX <ludovic@inpher.io>
- Loading branch information
Showing
20 changed files
with
651 additions
and
602 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "github-actions" | ||
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.) | ||
directory: "/" | ||
schedule: | ||
# Check for updates to GitHub Actions every weekday | ||
interval: "weekly" | ||
- package-ecosystem: "pip" | ||
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.) | ||
directory: "/" | ||
schedule: | ||
# Check for updates to GitHub Actions every weekday | ||
interval: "weekly" | ||
- package-ecosystem: "docker" | ||
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.) | ||
directory: "/" | ||
schedule: | ||
# Check for updates to GitHub Actions every weekday | ||
interval: "weekly" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Dependabot auto-merge | ||
on: | ||
pull_request_target: | ||
types: [review_requested] | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
packages: read | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@v1.3.4 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
skip-commit-verification: true | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Approve a PR if not already approved | ||
run: | | ||
gh pr checkout "$PR_URL" | ||
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; | ||
then | ||
gh pr review --approve "$PR_URL" | ||
else | ||
echo "PR already approved."; | ||
fi | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Enable auto-merge for Dependabot PRs | ||
if: ${{ contains(github.event.pull_request.title, 'bump')}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cli | ||
|
||
import "embed" | ||
|
||
type Context struct { | ||
Debug bool `env:"LOCALAI_DEBUG,DEBUG" default:"false" hidden:"" help:"DEPRECATED, use --log-level=debug instead. Enable debug logging"` | ||
LogLevel *string `env:"LOCALAI_LOG_LEVEL" enum:"error,warn,info,debug" help:"Set the level of logs to output [${enum}]"` | ||
|
||
// This field is not a command line argument/flag, the struct tag excludes it from the parsed CLI | ||
BackendAssets embed.FS `kong:"-"` | ||
} | ||
|
||
var CLI struct { | ||
Context `embed:""` | ||
|
||
Run RunCMD `cmd:"" help:"Run LocalAI, this the default command if no other command is specified. Run 'local-ai run --help' for more information" default:"withargs"` | ||
Models ModelsCMD `cmd:"" help:"Manage LocalAI models and definitions"` | ||
TTS TTSCMD `cmd:"" help:"Convert text to speech"` | ||
Transcript TranscriptCMD `cmd:"" help:"Convert audio to text"` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package cli | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/go-skynet/LocalAI/pkg/gallery" | ||
"github.com/rs/zerolog/log" | ||
"github.com/schollz/progressbar/v3" | ||
) | ||
|
||
type ModelsCMDFlags struct { | ||
Galleries string `env:"LOCALAI_GALLERIES,GALLERIES" help:"JSON list of galleries" group:"models"` | ||
ModelsPath string `env:"LOCALAI_MODELS_PATH,MODELS_PATH" type:"path" default:"${basepath}/models" help:"Path containing models used for inferencing" group:"storage"` | ||
} | ||
|
||
type ModelsList struct { | ||
ModelsCMDFlags `embed:""` | ||
} | ||
|
||
type ModelsInstall struct { | ||
ModelArgs []string `arg:"" optional:"" name:"models" help:"Model configuration URLs to load"` | ||
|
||
ModelsCMDFlags `embed:""` | ||
} | ||
|
||
type ModelsCMD struct { | ||
List ModelsList `cmd:"" help:"List the models avaiable in your galleries" default:"withargs"` | ||
Install ModelsInstall `cmd:"" help:"Install a model from the gallery"` | ||
} | ||
|
||
func (ml *ModelsList) Run(ctx *Context) error { | ||
var galleries []gallery.Gallery | ||
if err := json.Unmarshal([]byte(ml.Galleries), &galleries); err != nil { | ||
log.Error().Err(err).Msg("unable to load galleries") | ||
} | ||
|
||
models, err := gallery.AvailableGalleryModels(galleries, ml.ModelsPath) | ||
if err != nil { | ||
return err | ||
} | ||
for _, model := range models { | ||
if model.Installed { | ||
fmt.Printf(" * %s@%s (installed)\n", model.Gallery.Name, model.Name) | ||
} else { | ||
fmt.Printf(" - %s@%s\n", model.Gallery.Name, model.Name) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (mi *ModelsInstall) Run(ctx *Context) error { | ||
modelName := mi.ModelArgs[0] | ||
|
||
var galleries []gallery.Gallery | ||
if err := json.Unmarshal([]byte(mi.Galleries), &galleries); err != nil { | ||
log.Error().Err(err).Msg("unable to load galleries") | ||
} | ||
|
||
progressBar := progressbar.NewOptions( | ||
1000, | ||
progressbar.OptionSetDescription(fmt.Sprintf("downloading model %s", modelName)), | ||
progressbar.OptionShowBytes(false), | ||
progressbar.OptionClearOnFinish(), | ||
) | ||
progressCallback := func(fileName string, current string, total string, percentage float64) { | ||
progressBar.Set(int(percentage * 10)) | ||
} | ||
err := gallery.InstallModelFromGallery(galleries, modelName, mi.ModelsPath, gallery.GalleryModel{}, progressCallback) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.