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

Added Check API KEYs file to API.go #1381

Merged
merged 2 commits into from
Dec 5, 2023
Merged

Added Check API KEYs file to API.go #1381

merged 2 commits into from
Dec 5, 2023

Conversation

lunamidori5
Copy link
Collaborator

Description
@mudler I am not super knowing about go, but this PR trys to add a way to save a file and have it checked on request for API keys with out having to fully reset the docker every time.

This PR fixes #
#1355

Notes for Reviewers
Please help if I did something wrong, I really do not know go that well but did my best I know how.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: lunamidori5 <118759930+lunamidori5@users.noreply.github.com>
@lunamidori5 lunamidori5 added the enhancement New feature or request label Dec 4, 2023
@lunamidori5 lunamidori5 self-assigned this Dec 4, 2023
Copy link

netlify bot commented Dec 4, 2023

Deploy Preview for localai canceled.

Name Link
🔨 Latest commit 89f9274
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/656e68e537c86d0008aaef07

@lunamidori5 lunamidori5 marked this pull request as ready for review December 4, 2023 12:51
Copy link
Collaborator

@dave-gray101 dave-gray101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking this over with Luna in discord, I think we can merge this as-is, and I can take over the improvements in a fast follow PR.

validApiKey = true
}
// Check for api_keys.json file
fileContent, err := ioutil.ReadFile("api_keys.json")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunamidori5 - Do we know what the performance impact of ioutil.ReadFile on every request will be? @mudler is more familiar with golang and would know if this is a concern or not - it might be worth some performance testing in the meantime.

Personally, I would be inclined to use something like https://pkg.go.dev/github.com/fsnotify/fsnotify to watch the file and keep options.ApiKeys up-to-date - that way, we aren't hitting the filesystem on every single request?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to keep it simple we can also just load the file once on start and pass the api keys down the line as a list

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mudler needs to be reloaded on request so we dont have to restart the program everytime is the goal, this way we can add keys as its running

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunamidori5 - Do we know what the performance impact of ioutil.ReadFile on every request will be? @mudler is more familiar with golang and would know if this is a concern or not - it might be worth some performance testing in the meantime.

Personally, I would be inclined to use something like https://pkg.go.dev/github.com/fsnotify/fsnotify to watch the file and keep options.ApiKeys up-to-date - that way, we aren't hitting the filesystem on every single request?

I guess? I dont know much about GO...

validApiKey := false
for _, key := range options.ApiKeys {
if apiKey == key {
validApiKey = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can move the c.Next() up here - no need to check further api keys if one passes the test - at least until we need to support per-endpoint api keys or anything weird.

@dave-gray101 dave-gray101 merged commit 563c5b7 into mudler:master Dec 5, 2023
18 checks passed
truecharts-admin added a commit to truecharts/charts that referenced this pull request Dec 18, 2023
…1.0 by renovate (#16284)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [quay.io/go-skynet/local-ai](https://togithub.com/mudler/LocalAI) |
minor | `v2.0.0-cublas-cuda11` -> `v2.1.0-cublas-cuda11` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>mudler/LocalAI (quay.io/go-skynet/local-ai)</summary>

### [`v2.1.0`](https://togithub.com/mudler/LocalAI/releases/tag/v2.1.0)

[Compare
Source](https://togithub.com/mudler/LocalAI/compare/v2.0.0...v2.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at master -->

##### What's Changed

##### Breaking Changes 🛠

- feat(alias): alias llama to llama-cpp, update docs by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1448

##### Bug fixes 🐛

- fix(piper): pin petals, phonemize and espeak by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1393
- update(llama.cpp): update server, correctly propagate LLAMA_VERSION by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1440

##### Exciting New Features 🎉

- Added Check API KEYs file to API.go by
[@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1381
- exllama(v2): fix exllamav1, add exllamav2 by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1384
- Fix: API Key / JSON Fast Follow
[#&#8203;1](https://togithub.com/mudler/LocalAI/issues/1) by
[@&#8203;dave-gray101](https://togithub.com/dave-gray101) in
[mudler/LocalAI#1388
- feat: add transformers-musicgen backend by
[@&#8203;dave-gray101](https://togithub.com/dave-gray101) in
[mudler/LocalAI#1387
- feat(diffusers): update, add autopipeline, controlnet by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1432
- feat(img2vid,txt2vid): Initial support for img2vid,txt2vid by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1442

##### 👒 Dependencies

- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1378
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1379
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1430
- ⬆️ Update mudler/go-piper by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1441
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1434

##### Other Changes

- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1385
- docs: site update fixing old image text / How To update updating GPU
and CPU docker pages by
[@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1399
- feat: cuda transformers by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1401
- feat(entrypoint): optionally prepare extra endpoints by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1405
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1390
- ⬆️ Update mudler/go-piper by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1400
- tests: add diffusers tests by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1419
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1418
- How To Updates / Model Used Switched / Removed "docker-compose" (RIP)
by [@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1417
- fix(transformers\*): add sentence-transformers and
transformers-musicgen tests, fix musicgen wrapper by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1420
- extras: add vllm,bark,vall-e-x tests, bump diffusers by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1422
- Documentation for Hipblas by
[@&#8203;sfxworks](https://togithub.com/sfxworks) in
[mudler/LocalAI#1425
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1391
- docs: add aikit to integrations by
[@&#8203;sozercan](https://togithub.com/sozercan) in
[mudler/LocalAI#1412
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1429
- docs(mixtral): add mixtral example by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1449

##### New Contributors

- [@&#8203;sozercan](https://togithub.com/sozercan) made their first
contribution in
[mudler/LocalAI#1412

**Full Changelog**:
mudler/LocalAI@v2.0.0...v2.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->
truecharts-admin added a commit to truecharts/charts that referenced this pull request Dec 18, 2023
…1.0@f0b3afa by renovate (#16304)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [quay.io/go-skynet/local-ai](https://togithub.com/mudler/LocalAI) |
minor | `v2.0.0-cublas-cuda12-ffmpeg` -> `v2.1.0-cublas-cuda12-ffmpeg` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>mudler/LocalAI (quay.io/go-skynet/local-ai)</summary>

### [`v2.1.0`](https://togithub.com/mudler/LocalAI/releases/tag/v2.1.0)

[Compare
Source](https://togithub.com/mudler/LocalAI/compare/v2.0.0...v2.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at master -->

#### What's Changed

##### Breaking Changes 🛠

- feat(alias): alias llama to llama-cpp, update docs by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1448

##### Bug fixes 🐛

- fix(piper): pin petals, phonemize and espeak by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1393
- update(llama.cpp): update server, correctly propagate LLAMA_VERSION by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1440

##### Exciting New Features 🎉

- Added Check API KEYs file to API.go by
[@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1381
- exllama(v2): fix exllamav1, add exllamav2 by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1384
- Fix: API Key / JSON Fast Follow
[#&#8203;1](https://togithub.com/mudler/LocalAI/issues/1) by
[@&#8203;dave-gray101](https://togithub.com/dave-gray101) in
[mudler/LocalAI#1388
- feat: add transformers-musicgen backend by
[@&#8203;dave-gray101](https://togithub.com/dave-gray101) in
[mudler/LocalAI#1387
- feat(diffusers): update, add autopipeline, controlnet by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1432
- feat(img2vid,txt2vid): Initial support for img2vid,txt2vid by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1442

##### 👒 Dependencies

- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1378
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1379
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1430
- ⬆️ Update mudler/go-piper by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1441
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1434

##### Other Changes

- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1385
- docs: site update fixing old image text / How To update updating GPU
and CPU docker pages by
[@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1399
- feat: cuda transformers by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1401
- feat(entrypoint): optionally prepare extra endpoints by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1405
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1390
- ⬆️ Update mudler/go-piper by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1400
- tests: add diffusers tests by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1419
- ⬆️ Update ggerganov/whisper.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1418
- How To Updates / Model Used Switched / Removed "docker-compose" (RIP)
by [@&#8203;lunamidori5](https://togithub.com/lunamidori5) in
[mudler/LocalAI#1417
- fix(transformers\*): add sentence-transformers and
transformers-musicgen tests, fix musicgen wrapper by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1420
- extras: add vllm,bark,vall-e-x tests, bump diffusers by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1422
- Documentation for Hipblas by
[@&#8203;sfxworks](https://togithub.com/sfxworks) in
[mudler/LocalAI#1425
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1391
- docs: add aikit to integrations by
[@&#8203;sozercan](https://togithub.com/sozercan) in
[mudler/LocalAI#1412
- ⬆️ Update ggerganov/llama.cpp by
[@&#8203;localai-bot](https://togithub.com/localai-bot) in
[mudler/LocalAI#1429
- docs(mixtral): add mixtral example by
[@&#8203;mudler](https://togithub.com/mudler) in
[mudler/LocalAI#1449

#### New Contributors

- [@&#8203;sozercan](https://togithub.com/sozercan) made their first
contribution in
[mudler/LocalAI#1412

**Full Changelog**:
mudler/LocalAI@v2.0.0...v2.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants