-
Notifications
You must be signed in to change notification settings - Fork 60.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from Yidadaa/prompt
feat: improve prompts ux
- Loading branch information
Showing
18 changed files
with
353 additions
and
160 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"./app/**/*.{js,ts,jsx,tsx,json,html,css,scss,md}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
] | ||
} | ||
"./app/**/*.{js,ts,jsx,tsx,json,html,css,md}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
] | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NextRequest } from "next/server"; | ||
|
||
const OPENAI_URL = "api.openai.com"; | ||
const DEFAULT_PROTOCOL = "https"; | ||
const PROTOCOL = process.env.PROTOCOL ?? DEFAULT_PROTOCOL; | ||
const BASE_URL = process.env.BASE_URL ?? OPENAI_URL; | ||
|
||
export async function requestOpenai(req: NextRequest) { | ||
const apiKey = req.headers.get("token"); | ||
const openaiPath = req.headers.get("path"); | ||
|
||
console.log("[Proxy] ", openaiPath); | ||
|
||
return fetch(`${PROTOCOL}://${BASE_URL}/${openaiPath}`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${apiKey}`, | ||
}, | ||
method: req.method, | ||
body: req.body, | ||
}); | ||
} |
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,28 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { requestOpenai } from "../common"; | ||
|
||
async function makeRequest(req: NextRequest) { | ||
try { | ||
const res = await requestOpenai(req); | ||
return new Response(res.body); | ||
} catch (e) { | ||
console.error("[OpenAI] ", req.body, e); | ||
return NextResponse.json( | ||
{ | ||
error: true, | ||
msg: JSON.stringify(e), | ||
}, | ||
{ | ||
status: 500, | ||
}, | ||
); | ||
} | ||
} | ||
|
||
export async function POST(req: NextRequest) { | ||
return makeRequest(req); | ||
} | ||
|
||
export async function GET(req: NextRequest) { | ||
return makeRequest(req); | ||
} |
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
Oops, something went wrong.
d908099
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:
chat-gpt-next-web – ./
chat-gpt-next-web-yidadaa.vercel.app
chat-gpt-next-web-git-main-yidadaa.vercel.app
chat-gpt-next-web.vercel.app
chat.simplenaive.cn