forked from ChatGPTNextWeb/NextChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
534 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Auto Rebase | ||
|
||
on: | ||
schedule: | ||
- cron: '0 * * * *' # This will run every hour | ||
push: | ||
branches: | ||
- main # Change this to the branch you want to watch for updates | ||
workflow_dispatch: # Allows manual triggering of the action | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
rebase: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches and tags | ||
|
||
- name: Add upstream remote | ||
run: git remote add upstream https://github.com/comfyanonymous/ComfyUI.git | ||
|
||
- name: Fetch upstream changes | ||
run: git fetch upstream | ||
|
||
- name: Rebase branch | ||
run: | | ||
git config --global user.email jackalcooper@gmail.com | ||
git config --global user.name tsai | ||
git checkout master | ||
git rebase upstream/master | ||
- name: Push changes | ||
run: git push origin master --force |
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,70 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { redirect } from "next/navigation"; | ||
import { cookies } from "next/headers"; | ||
|
||
export async function handle( | ||
req: NextRequest, | ||
{ params }: { params: { path: string[] } }, | ||
) { | ||
console.log("[SF] params ", params); | ||
|
||
if (req.method === "OPTIONS") { | ||
return NextResponse.json({ body: "OK" }, { status: 200 }); | ||
} | ||
const url = new URL(req.url); | ||
const queryParams = new URLSearchParams(url.search); | ||
const code = queryParams.get("code"); | ||
let sfak = ""; | ||
console.log("[SF] code ", code); | ||
try { | ||
const tokenFetch = await fetch( | ||
`${ | ||
process.env.NEXT_PUBLIC_SF_NEXT_CHAT_SF_ACCOUNT_ENDPOINT || | ||
"https://account.siliconflow.cn" | ||
}/oauth?client_id=${ | ||
process.env.NEXT_PUBLIC_SF_NEXT_CHAT_CLIENT_ID | ||
}/api/open/oauth`, | ||
{ | ||
method: "POST", | ||
body: JSON.stringify({ | ||
clientId: process.env.NEXT_PUBLIC_SF_NEXT_CHAT_CLIENT_ID, | ||
secret: process.env.SF_NEXT_CHAT_SECRET, | ||
code, | ||
}), | ||
}, | ||
); | ||
if (!tokenFetch.ok) | ||
return Response.json( | ||
{ status: false, message: "fetch error" }, | ||
{ status: 500 }, | ||
); | ||
const tokenJson = await tokenFetch.json(); | ||
const access_token = tokenJson.status ? tokenJson.data?.access_token : null; | ||
console.log("access_token", access_token); | ||
// uat https://cloud-uat.siliconflow.cn | ||
// prod https://cloud.siliconflow.cn | ||
const apiKey = await fetch( | ||
`${ | ||
process.env.NEXT_PUBLIC_SF_NEXT_CHAT_SF_CLOUD_ENDPOINT || | ||
"https://cloud.siliconflow.cn" | ||
}/api/oauth/apikeys`, | ||
{ | ||
method: "POST", | ||
headers: { | ||
Authorization: `token ${access_token}`, | ||
}, | ||
}, | ||
); | ||
const apiKeysData = await apiKey.json(); | ||
console.log("apiKeysData", apiKeysData); | ||
sfak = apiKeysData.data[0].secretKey; | ||
} catch (error) { | ||
console.log("error", error); | ||
return Response.json( | ||
{ status: false, message: "fetch error" }, | ||
{ status: 500 }, | ||
); | ||
} | ||
cookies().set("sfak", sfak); | ||
redirect(`/`); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.