From 7c399ed15c34ee4bd1104daade15030f4e471554 Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 15 Jan 2024 12:05:30 +0800 Subject: [PATCH] add document when request base page --- src/app.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index 6616fdf..55b83aa 100644 --- a/src/app.ts +++ b/src/app.ts @@ -12,10 +12,31 @@ export const app = new Hono({ strict: true }) const logger = gen_logger(crypto.randomUUID()) c.set("log", logger) await next() - c.set("log", undefined) + c.set("log", undefined as unknown as Logger) }) .options("*", (c) => c.text("", 204)) - .get("/", (c) => c.text(`Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}!`)) + .get("/", (c) => { + const origin = new URL(c.req.url).origin + return c.html( + `
+
+Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! 
+
+You can try it with:
+
+curl ${origin}/v1/chat/completions \\
+-H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\
+-H "Content-Type: application/json" \\
+-d '{
+"model": "gpt-3.5-turbo",
+"messages": [{"role": "user", "content": "Hello"}],
+"temperature": 0.7
+}'
+
+
+
`, + ) + }) .post("/v1/chat/completions", chatProxyHandler) export type ContextWithLogger = Context<{ Variables: { log: Logger } }>