T1ckbase commited on
Commit
862d774
·
1 Parent(s): e5fe435
Files changed (1) hide show
  1. main.ts +7 -7
main.ts CHANGED
@@ -32,12 +32,7 @@ app.get('/v1/models', (c) => {
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
- // body.max_tokens = 33554432;
39
- console.log(body);
40
- console.log(targetUrl);
41
 
42
  const headers = new Headers(c.req.raw.headers);
43
  // headers.delete('Host');
@@ -45,10 +40,15 @@ app.post('/v1/chat/completions', async (c) => {
45
  headers.get('x-use-cache') || headers.set('x-use-cache', 'false');
46
  console.log('headers:', Object.fromEntries(headers));
47
 
 
 
 
 
 
48
  return await fetch(targetUrl, {
49
  method: 'POST',
50
  headers: headers,
51
- body: c.req.raw.body,
52
  });
53
  });
54
 
 
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
+ // console.log(targetUrl);
 
 
 
 
 
36
 
37
  const headers = new Headers(c.req.raw.headers);
38
  // headers.delete('Host');
 
40
  headers.get('x-use-cache') || headers.set('x-use-cache', 'false');
41
  console.log('headers:', Object.fromEntries(headers));
42
 
43
+ const clonedRequest = await c.req.raw.clone();
44
+ const body = await clonedRequest.json();
45
+ body.max_tokens = 33554432;
46
+ console.log('body:', body);
47
+
48
  return await fetch(targetUrl, {
49
  method: 'POST',
50
  headers: headers,
51
+ body: body,
52
  });
53
  });
54