Skip to content

Commit

Permalink
local bot directory improvements & readme update (#80)
Browse files Browse the repository at this point in the history
* load config on doc ready and close modal on save

* readme fix (#73), fix windows install (#76), add backend_config to correct .gitignore

* default backend config

* remove this since aphrodite does it automatically now
  • Loading branch information
ewof authored Jan 17, 2024
1 parent 0af65fd commit d99a4fa
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ node_modules/
.npmrc
.DS_Store
env/
apps/services/backend_config.json
3 changes: 1 addition & 2 deletions apps/bot-directory/src/s3server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import fs from "fs";
import path from "path";
import multer from "multer";
import express, { Express } from "express";
import { Express } from "express";
import { BUCKET } from "@mikugg/bot-utils";
import bodyParser from "body-parser";
export { BUCKET } from "@mikugg/bot-utils";

const dataDir = path.join(__dirname, "../db"); // Directory to store files
Expand Down
14 changes: 14 additions & 0 deletions apps/bot-directory/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ app.post("/save", async (req, res) => {
);
});

app.get("/get", async (req, res) => {
const config = fs.readFileSync(
path.join(__dirname, "../../services/backend_config.json"),
"utf8"
);
const data = JSON.parse(config);

res.send({
apiUrl: data.apiUrl,
apiKey: data.apiKey,
strat: data.strat,
});
});

app.get(`/bot/config/:hash`, (req, res) => {
const file = getS3File(BUCKET.BOTS, req.params.hash);
if (file) {
Expand Down
17 changes: 15 additions & 2 deletions apps/bot-directory/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<p class="text-white w-24">Prompt Strategy</p>
<input class="mb-8 w-full mr-8" type="text" value="" placeholder="alpacarp OR metharmerp" required name="strat" id="strat" />
</div>
<button class="ui button save-button w-64" onclick="save_backend_config()">Save</button>
<button class="ui button save-button w-64" onclick="save_backend_config(); toggle_backend_modal(false)">Save</button>
</div>
</div>

Expand All @@ -165,7 +165,7 @@
<script src="/public/semantic.min.js"></script>
<script src="/public/form.min.js"></script>
<script>
$(document).ready(function() {
$(document).ready(async function() {
$('.dropdown').dropdown();
// toggle button formatting
Expand All @@ -179,6 +179,19 @@
$(".nsfw_toggle:checkbox").on("change", function() {
toggle_nsfw($(this).is(":checked"));
});
const getResult = await fetch("/get", {
method: "GET",
headers: {
"Content-type": "application/json"
}
});
const data = await getResult.json()
document.getElementById('apiUrl').value = data.apiUrl
document.getElementById('apiKey').value = data.apiKey
document.getElementById('strat').value = data.strat
});
function change_theme(dark_mode) {
Expand Down
3 changes: 2 additions & 1 deletion apps/services/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
dist/
_temp/*
!_temp/.gitkeep
!_temp/.gitkeep
backend_config.json
6 changes: 0 additions & 6 deletions docs/src/guides/how-to-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ For example, to run a model like `ludis/tsukasa-120b-qlora-gptq`
./runtime.sh python -m aphrodite.endpoints.openai.api_server --port <YOUR PORT HERE> --model ludis/tsukasa-120b-qlora-gptq -q gptq --dtype float16 --api-keys <YOUR_API_PASSWORD_HERE> -gmu 0.88 -tp 2
```

If you're using multiple GPUs (`-tp` set to a value >1) you might get a speed boost from setting the affinity of Aphrodite's ray processes to a higher value with this command.

```
cpuid=0 ; for pid in $(ps xo '%p %c' | grep ray:: | awk '{print $1;}') ; do taskset -cp $cpuid $pid ; cpuid=$(($cpuid + 1)) ; done
```

### Get a TabbyAPI endpoint

First, download and install [TabbyAPI](https://github.com/theroyallab/tabbyAPI) and run a model.
Expand Down
4 changes: 1 addition & 3 deletions docs/src/guides/run-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ This command will check the dependencies and install the required packages for `

Next, you will be prompted for the environment variables

* `OPENAI_ENDPOINT`, the OAI-like endpoint (Aphrodite/Ooba/Tabby)
* `OPENAI_KEY`, the password for the OAI-like endpoint (Aphrodite/Ooba/Tabby)
* `AZURE_API_KEY`, a valid API for querying Azure TTS models
* `ELEVENLABS_API_KEY`, a valid API for querying ElevenLabs TTS models

An `OPENAI_API_KEY` must be provided for the bots to generate responses. You can take a look at the [How to use the endpoints](/guides/how-to-endpoints) guide for getting one of these values.
Backend API keys and URLs are set in the bot directory config. You can take a look at the [How to use the endpoints](/guides/how-to-endpoints) guide for getting one of these values.

### 3. Run the project
After setting up the `.env` file, you can run the project by running the following command:
Expand Down
2 changes: 1 addition & 1 deletion install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ call npm --version >nul 2>&1 || (
echo Node.js is installed.

echo Installing Node.js dependencies...
del /q/s apps\interactor\node_modules\.vite > nul 2>&1 || exit
rem /q/s apps\interactor\node_modules\.vite > nul 2>&1 || exit
call npm install -g pnpm 0
call pnpm install
if errorlevel 1 (
Expand Down

0 comments on commit d99a4fa

Please sign in to comment.