forked from Harry-zklcdc/go-proxy-bingai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
807aa59
commit d1a3473
Showing
21 changed files
with
88 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { bingapiChat, bingapiModel, bingapiModels } from '../../cloudflare/bingapi.js' | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
supportsResponseStreaming: true, | ||
}; | ||
|
||
export default function ChatHandler(request) { | ||
const CUSTOM_OPTIONS = { | ||
cookie: request.headers.get('Cookie') || '', | ||
BYPASS_SERVER: 'https://bypass.zklcdc.xyz', | ||
APIKEY: process.env.APIKEY, | ||
} | ||
|
||
const currentUrl = new URL(request.url); | ||
if ((currentUrl.pathname.startsWith('/v1/models/')) || (currentUrl.pathname.startsWith('/api/v1/models/'))) { | ||
return bingapiModel(request, CUSTOM_OPTIONS); | ||
} | ||
if ((currentUrl.pathname === '/v1/models') || (currentUrl.pathname === '/api/v1/models')) { | ||
return bingapiModels(request, CUSTOM_OPTIONS); | ||
} | ||
if ((currentUrl.pathname === '/v1/chat/completions') || (currentUrl.pathname === '/api/v1/chat/completions')) { | ||
if (request.method == 'OPTIONS') { | ||
return Response.json({ code: 200, message: 'OPTIONS', data: null }, { | ||
headers: { | ||
"Allow": "POST, OPTIONS", | ||
"Access-Control-Allow-Origin": "*", | ||
"Access-Control-Allow-Methods": "POST, OPTIONS", | ||
"Access-Control-Allow-Headers": "Content-Type, Authorization, Cookie", | ||
} | ||
}); | ||
} | ||
if (request.method != 'POST') { | ||
return Response.json({ code: 405, message: 'Method Not Allowed', data: null }, { status: 405 }); | ||
} | ||
return bingapiChat(request, CUSTOM_OPTIONS); | ||
} | ||
return Response.json({ code: 404, message: 'API No Found', data: null }, { status: 404 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
{ | ||
"name": "go-proxy-bingai", | ||
"version": 2, | ||
"builds": [ | ||
{ | ||
"src": "/api/{index,web,sydney,edgesvc,designer,sys-config,bypass,challenge,verify}.go", | ||
"use": "@vercel/go" | ||
"functions": { | ||
"api/*.go": { | ||
"runtime": "@vercel/[email protected]" | ||
}, | ||
{ | ||
"src": "/api/v1/{chat,image}.go", | ||
"use": "@vercel/go" | ||
"api/v1/*.js": { | ||
"memory": 512 | ||
} | ||
], | ||
}, | ||
"routes": [ | ||
{ | ||
"src": "/sysconf", | ||
|
@@ -29,20 +27,12 @@ | |
"dest": "/api/verify.go" | ||
}, | ||
{ | ||
"src": "/v1/chat/completions", | ||
"dest": "/api/v1/chat.go" | ||
}, | ||
{ | ||
"src": "/api/v1/chat/completions", | ||
"dest": "/api/v1/chat.go" | ||
}, | ||
{ | ||
"src": "/v1/images/generations", | ||
"dest": "/api/v1/image.go" | ||
"src": "/v1/.*", | ||
"dest": "/api/v1/vercel.js" | ||
}, | ||
{ | ||
"src": "/api/v1/images/generations", | ||
"dest": "/api/v1/image.go" | ||
"src": "/api/v1/.*", | ||
"dest": "/api/v1/vercel.js" | ||
}, | ||
{ | ||
"src": "/designer/.*", | ||
|