T1ckbase commited on
Commit
7fe37cd
·
1 Parent(s): 91cb296

jina-deepsearch-v1

Browse files
Files changed (1) hide show
  1. main.ts +5 -4
main.ts CHANGED
@@ -3,6 +3,7 @@ import { logger } from '@hono/hono/logger';
3
 
4
  // https://api-inference.huggingface.co/v1
5
  const HF_API_URL = 'https://api-inference.huggingface.co';
 
6
 
7
  const app = new Hono();
8
 
@@ -30,10 +31,6 @@ app.get('/v1/models', (c) => {
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
- // console.log(targetUrl);
36
-
37
  const headers = new Headers(c.req.raw.headers);
38
  // headers.delete('Host');
39
  headers.delete('Authorization');
@@ -50,6 +47,10 @@ app.post('/v1/chat/completions', async (c) => {
50
 
51
  console.log('body:', body);
52
 
 
 
 
 
53
  return await fetch(targetUrl, {
54
  method: 'POST',
55
  headers: headers,
 
3
 
4
  // https://api-inference.huggingface.co/v1
5
  const HF_API_URL = 'https://api-inference.huggingface.co';
6
+ const JINA_API_URL = 'https://deepsearch.jina.ai';
7
 
8
  const app = new Hono();
9
 
 
31
  });
32
 
33
  app.post('/v1/chat/completions', async (c) => {
 
 
 
 
34
  const headers = new Headers(c.req.raw.headers);
35
  // headers.delete('Host');
36
  headers.delete('Authorization');
 
47
 
48
  console.log('body:', body);
49
 
50
+ const { pathname, search } = new URL(c.req.url);
51
+ const targetUrl = `${body.model === 'jina-deepsearch-v1' ? JINA_API_URL : HF_API_URL}${pathname}${search}`;
52
+ // console.log(targetUrl);
53
+
54
  return await fetch(targetUrl, {
55
  method: 'POST',
56
  headers: headers,