From 111fb1a7c59b723978a0b4cd664653736112050b Mon Sep 17 00:00:00 2001 From: nai-degen <44111-khanon@users.noreply.gitgud.io> Date: Mon, 10 Apr 2023 04:44:38 -0500 Subject: [PATCH] improves service info page --- info-page.md | 8 ++++++++ src/info-page.ts | 6 ++---- src/key-management/key-checker.ts | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 info-page.md diff --git a/info-page.md b/info-page.md new file mode 100644 index 0000000..7bbffaf --- /dev/null +++ b/info-page.md @@ -0,0 +1,8 @@ + + +# OAI Reverse Proxy + +This is a simple reverse proxy for the OpenAI API. To use it, refer to the `appUrls` listed in the Service Info section below and paste them into your preferred front-end. + +[https://github.com/nai-degen/oai-reverse-proxy](https://github.com/nai-degen/oai-reverse-proxy) diff --git a/src/info-page.ts b/src/info-page.ts index 9378088..36e8107 100644 --- a/src/info-page.ts +++ b/src/info-page.ts @@ -37,9 +37,7 @@ function getInfoPageHtml(host: string) { const info = { uptime: process.uptime(), timestamp: Date.now(), - // Describes the URLs each client app and adapter should use to connect appUrls: { - baseUrl: host, tavern: { kobold: host, openai: host + "/proxy/openai/v1", @@ -50,12 +48,12 @@ function getInfoPageHtml(host: string) { }, }, proompts: keys.reduce((acc, k) => acc + k.promptCount, 0), - ...(config.modelRateLimit ? { proomptingNow: getUniqueIps() } : {}), + ...(config.modelRateLimit ? { proomptersNow: getUniqueIps() } : {}), keyInfo, config: listConfig(), }; - const readme = require("fs").readFileSync("README.md", "utf8"); + const readme = require("fs").readFileSync("info-page.md", "utf8"); const readmeBody = readme.split("---")[2] || readme; const converter = new showdown.Converter(); const html = converter.makeHtml(readmeBody); diff --git a/src/key-management/key-checker.ts b/src/key-management/key-checker.ts index 6319262..ba397f9 100644 --- a/src/key-management/key-checker.ts +++ b/src/key-management/key-checker.ts @@ -26,14 +26,16 @@ type GetUsageResponse = { total_usage: number; }; +type UpdateFn = typeof KeyPool.prototype.update; + export class KeyChecker { private readonly keys: Key[]; private log = logger.child({ module: "KeyChecker" }); private timeout?: NodeJS.Timeout; - private updateKey: typeof KeyPool.prototype.update; + private updateKey: UpdateFn; private lastCheck = 0; - constructor(keys: Key[], updateKey: typeof KeyPool.prototype.update) { + constructor(keys: Key[], updateKey: UpdateFn) { this.keys = keys; this.updateKey = updateKey; }