Spaces:
Sleeping
Sleeping
T1ckbase
commited on
Commit
·
7541db3
1
Parent(s):
5433c0e
deno.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"tasks": {
|
| 3 |
"dev": "deno --allow-net --allow-read --allow-env --watch main.ts",
|
| 4 |
-
"serve": "deno serve --watch --port 7860 serve.ts"
|
| 5 |
},
|
| 6 |
"imports": {
|
| 7 |
"@hono/hono": "jsr:@hono/hono@^4.7.1"
|
|
|
|
| 1 |
{
|
| 2 |
"tasks": {
|
| 3 |
"dev": "deno --allow-net --allow-read --allow-env --watch main.ts",
|
| 4 |
+
"serve": "deno serve --allow-net --watch --port 7860 serve.ts"
|
| 5 |
},
|
| 6 |
"imports": {
|
| 7 |
"@hono/hono": "jsr:@hono/hono@^4.7.1"
|
main.ts
CHANGED
|
@@ -9,8 +9,9 @@ const app = new Hono();
|
|
| 9 |
app.use(logger());
|
| 10 |
app.get('/', (c) => c.text('Hello Hono!'));
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
object: 'list',
|
| 15 |
data: [
|
| 16 |
{
|
|
@@ -25,12 +26,18 @@ app.get('/v1/models', (c) =>
|
|
| 25 |
'max_context_length': 131072,
|
| 26 |
},
|
| 27 |
],
|
| 28 |
-
})
|
|
|
|
| 29 |
|
| 30 |
-
app.post('
|
| 31 |
const { pathname, search } = new URL(c.req.url);
|
| 32 |
const targetUrl = `${HF_API_URL}${pathname}${search}`;
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
const headers = new Headers(c.req.raw.headers);
|
| 35 |
headers.delete('Authorization');
|
| 36 |
headers.get('x-use-cache') || headers.set('x-use-cache', 'false');
|
|
|
|
| 9 |
app.use(logger());
|
| 10 |
app.get('/', (c) => c.text('Hello Hono!'));
|
| 11 |
|
| 12 |
+
// LM Studio
|
| 13 |
+
app.get('/v1/models', (c) => {
|
| 14 |
+
return c.json({
|
| 15 |
object: 'list',
|
| 16 |
data: [
|
| 17 |
{
|
|
|
|
| 26 |
'max_context_length': 131072,
|
| 27 |
},
|
| 28 |
],
|
| 29 |
+
});
|
| 30 |
+
});
|
| 31 |
|
| 32 |
+
app.post('/v1/chat/completions', async (c) => {
|
| 33 |
const { pathname, search } = new URL(c.req.url);
|
| 34 |
const targetUrl = `${HF_API_URL}${pathname}${search}`;
|
| 35 |
|
| 36 |
+
const clonedRequest = await c.req.raw.clone();
|
| 37 |
+
const body = await clonedRequest.json();
|
| 38 |
+
delete body.max_tokens;
|
| 39 |
+
console.log(body);
|
| 40 |
+
|
| 41 |
const headers = new Headers(c.req.raw.headers);
|
| 42 |
headers.delete('Authorization');
|
| 43 |
headers.get('x-use-cache') || headers.set('x-use-cache', 'false');
|