This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gpt-4 model * update docs * ignore * @vercel/node 移到 devDependencies * rename * 移除axios,使用内置的fetch
- Loading branch information
Showing
9 changed files
with
303 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
.vscode | ||
.DS_Store | ||
node_modules | ||
venv | ||
.vercel |
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,22 +1,20 @@ | ||
import axios from 'axios' | ||
|
||
export async function get_access_token(req, res) { | ||
const { email, password } = req.body | ||
if (!email || !password) { | ||
throw new Error('invalid [email] or [password]') | ||
} | ||
|
||
const { data } = await axios({ | ||
const response = await fetch('https://chat.gateway.do/api/auth/login', { | ||
method: 'POST', | ||
url: 'https://chat.gateway.do/api/auth/login', | ||
data: new URLSearchParams({ | ||
body: new URLSearchParams({ | ||
username: email, | ||
password, | ||
}), | ||
}) | ||
if (!data.accessToken) { | ||
throw new Error('failed to get [access_token]') | ||
const json = await response.json() | ||
if (!json?.accessToken) { | ||
throw new Error(json?.detail || 'failed to get [access_token]') | ||
} | ||
|
||
res.json({ access_token: data.accessToken, expires: data.expires }) | ||
res.json({ access_token: json.accessToken, expires: json.expires }) | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
433ad3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chatgpt-api – ./
chatgpt-api-zhuweiyou.vercel.app
zhuweiyou-chatgpt-api.vercel.app
chatgpt-api-git-main-zhuweiyou.vercel.app