improves service info page

This commit is contained in:
nai-degen 2023-04-10 04:44:38 -05:00 committed by nai-degen
parent de5833e1e5
commit 111fb1a7c5
3 changed files with 14 additions and 6 deletions

8
info-page.md Normal file
View File

@ -0,0 +1,8 @@
<!-- This file is loaded by the server's status page. It is a good place to put
friendly welcome messages and instructions for connecting to your deployment. -->
# 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)

View File

@ -37,9 +37,7 @@ function getInfoPageHtml(host: string) {
const info = { const info = {
uptime: process.uptime(), uptime: process.uptime(),
timestamp: Date.now(), timestamp: Date.now(),
// Describes the URLs each client app and adapter should use to connect
appUrls: { appUrls: {
baseUrl: host,
tavern: { tavern: {
kobold: host, kobold: host,
openai: host + "/proxy/openai/v1", openai: host + "/proxy/openai/v1",
@ -50,12 +48,12 @@ function getInfoPageHtml(host: string) {
}, },
}, },
proompts: keys.reduce((acc, k) => acc + k.promptCount, 0), proompts: keys.reduce((acc, k) => acc + k.promptCount, 0),
...(config.modelRateLimit ? { proomptingNow: getUniqueIps() } : {}), ...(config.modelRateLimit ? { proomptersNow: getUniqueIps() } : {}),
keyInfo, keyInfo,
config: listConfig(), 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 readmeBody = readme.split("---")[2] || readme;
const converter = new showdown.Converter(); const converter = new showdown.Converter();
const html = converter.makeHtml(readmeBody); const html = converter.makeHtml(readmeBody);

View File

@ -26,14 +26,16 @@ type GetUsageResponse = {
total_usage: number; total_usage: number;
}; };
type UpdateFn = typeof KeyPool.prototype.update;
export class KeyChecker { export class KeyChecker {
private readonly keys: Key[]; private readonly keys: Key[];
private log = logger.child({ module: "KeyChecker" }); private log = logger.child({ module: "KeyChecker" });
private timeout?: NodeJS.Timeout; private timeout?: NodeJS.Timeout;
private updateKey: typeof KeyPool.prototype.update; private updateKey: UpdateFn;
private lastCheck = 0; private lastCheck = 0;
constructor(keys: Key[], updateKey: typeof KeyPool.prototype.update) { constructor(keys: Key[], updateKey: UpdateFn) {
this.keys = keys; this.keys = keys;
this.updateKey = updateKey; this.updateKey = updateKey;
} }