Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #4

Merged
merged 33 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5a7b9ab
Fix: Routes `/api/cors/[...path]` was not configured to run with the …
wyxogo Jan 8, 2024
a06a298
Merge branch 'ChatGPTNextWeb:main' into upstream
wyxogo Jan 11, 2024
7ec29c2
add workflows/deploy preview
Jan 24, 2024
bdc25ad
add delete preview scripts
Jan 24, 2024
3bc771a
add workflow_dispatch
Jan 24, 2024
998c95d
test pr deploy
Jan 24, 2024
04fe9fa
add workflows/deploy preview
Jan 24, 2024
8fb3446
add delete preview scripts
Jan 24, 2024
0739ced
add workflow_dispatch
Jan 24, 2024
2f11e7c
test pr deploy
Jan 25, 2024
94f534f
fix vercel alias domains
Jan 25, 2024
628f3ba
Merge branch 'ChatGPTNextWeb:sgm/cicd' into sgm/cicd
sungaomeng Jan 25, 2024
6206ceb
fix: cicd , add pull_request_target
Jan 25, 2024
04855de
Merge pull request #3789 from wyxogo/upstream
fred-bf Jan 25, 2024
43631a3
fix: cicd, vercel domain suffix secret
Jan 25, 2024
f619e9d
chore: change default submit key
fred-bf Jan 25, 2024
a4c1f1a
Merge branch 'main' into sgm/cicd
sungaomeng Jan 25, 2024
1132816
Merge pull request #2 from sungaomeng/sgm/cicd
sungaomeng Jan 25, 2024
5ce1a55
Merge pull request #3909 from sungaomeng/main
fred-bf Jan 25, 2024
fae82a3
fix: cicd, delete vercel pre
Jan 25, 2024
ba3e7e7
fix: cicd, vercel alias domain
Jan 25, 2024
32bcdb8
fix: cicd, delete vercel pre (#3910)
sungaomeng Jan 25, 2024
b2f7bdc
Merge branch 'ChatGPTNextWeb:main' into main
sungaomeng Jan 25, 2024
15d25df
fix: cicd, delete velcel pre
Jan 25, 2024
ecbab75
fix: cicd, alias domain env name
Jan 25, 2024
ca08062
Merge pull request #3913 from sungaomeng/main
sungaomeng Jan 25, 2024
148c32a
fix: cicd, remove workflow_dispatch
Jan 25, 2024
1c73c6c
Merge pull request #3917 from sungaomeng/main
fred-bf Jan 25, 2024
3fa55f9
fix: cicd, checkout sha
Jan 25, 2024
118e8f5
fix: cicd, checkout sha Merge pull request #3920 from sungaomeng/main
sungaomeng Jan 25, 2024
981a362
Add gpt-4-0125-preview (#3924)
leo4life2 Jan 26, 2024
f6cdda9
update google api region (#3934)
NieXi Jan 27, 2024
91a5f4a
Feat Models [GPT-4-turbo] (#3932)
H0llyW00dzZ Jan 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: VercelPreviewDeployment

on:
pull_request_target:
types:
- opened
- synchronize

env:
VERCEL_TEAM: ${{ secrets.VERCEL_TEAM }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_PR_DOMAIN_SUFFIX: ${{ secrets.VERCEL_PR_DOMAIN_SUFFIX }}

permissions:
contents: read
statuses: write
pull-requests: write

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
id: extract_branch

- name: Hash branch name
uses: pplanel/hash-calculator-action@v1.3.1
id: hash_branch
with:
input: ${{ steps.extract_branch.outputs.branch }}
method: MD5

- name: Set Environment Variables
id: set_env
if: github.event_name == 'pull_request_target'
run: |
echo "VERCEL_ALIAS_DOMAIN=${{ github.event.pull_request.number }}-${{ github.workflow }}.${VERCEL_PR_DOMAIN_SUFFIX}" >> $GITHUB_OUTPUT
- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Cache dependencies
uses: actions/cache@v2
id: cache-npm
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${VERCEL_TOKEN}

- name: Deploy Project Artifacts to Vercel
id: vercel
env:
META_TAG: ${{ steps.hash_branch.outputs.digest }}-${{ github.run_number }}-${{ github.run_attempt}}
run: |
set -e
vercel pull --yes --environment=preview --token=${VERCEL_TOKEN}
vercel build --token=${VERCEL_TOKEN}
vercel deploy --prebuilt --archive=tgz --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }}
DEFAULT_URL=$(vercel ls --token=${VERCEL_TOKEN} --meta base_hash=${{ env.META_TAG }})
ALIAS_URL=$(vercel alias set ${DEFAULT_URL} ${{ steps.set_env.outputs.VERCEL_ALIAS_DOMAIN }} --token=${VERCEL_TOKEN} --scope ${VERCEL_TEAM}| awk '{print $3}')
echo "New preview URL: ${DEFAULT_URL}"
echo "New alias URL: ${ALIAS_URL}"
echo "VERCEL_URL=${ALIAS_URL}" >> "$GITHUB_OUTPUT"
- uses: mshick/add-pr-comment@v2
with:
message: |
Your build has completed!
[Preview deployment](${{ steps.vercel.outputs.VERCEL_URL }})
40 changes: 40 additions & 0 deletions .github/workflows/remove_deploy_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Removedeploypreview

permissions:
contents: read
statuses: write
pull-requests: write

env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
pull_request_target:
types:
- closed

jobs:
delete-deployments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Hash branch name
uses: pplanel/hash-calculator-action@v1.3.1
id: hash_branch
with:
input: ${{ steps.extract_branch.outputs.branch }}
method: MD5

- name: Call the delete-deployment-preview.sh script
env:
META_TAG: ${{ steps.hash_branch.outputs.digest }}
run: |
bash ./scripts/delete-deployment-preview.sh
2 changes: 1 addition & 1 deletion app/api/cors/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ export const POST = handle;
export const GET = handle;
export const OPTIONS = handle;

export const runtime = "nodejs";
export const runtime = "edge";
5 changes: 0 additions & 5 deletions app/api/google/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,14 @@ export const POST = handle;

export const runtime = "edge";
export const preferredRegion = [
"arn1",
"bom1",
"cdg1",
"cle1",
"cpt1",
"dub1",
"fra1",
"gru1",
"hnd1",
"iad1",
"icn1",
"kix1",
"lhr1",
"pdx1",
"sfo1",
"sin1",
Expand Down
20 changes: 20 additions & 0 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export const SUMMARIZE_MODEL = "gpt-3.5-turbo";

export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",
"gpt-4-turbo-preview": "2023-04",
"gpt-4-1106-preview": "2023-04",
"gpt-4-0125-preview": "2023-04",
"gpt-4-vision-preview": "2023-04",
};

Expand Down Expand Up @@ -166,6 +168,15 @@ export const DEFAULT_MODELS = [
providerType: "openai",
},
},
{
name: "gpt-4-turbo-preview",
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
},
{
name: "gpt-4-1106-preview",
available: true,
Expand All @@ -175,6 +186,15 @@ export const DEFAULT_MODELS = [
providerType: "openai",
},
},
{
name: "gpt-4-0125-preview",
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
},
{
name: "gpt-4-vision-preview",
available: true,
Expand Down
2 changes: 1 addition & 1 deletion app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export enum Theme {
export const DEFAULT_CONFIG = {
lastUpdate: Date.now(), // timestamp, to merge state

submitKey: isMacOS() ? SubmitKey.MetaEnter : SubmitKey.CtrlEnter,
submitKey: SubmitKey.Enter,
avatar: "1f603",
fontSize: 14,
theme: Theme.Auto as Theme,
Expand Down
34 changes: 34 additions & 0 deletions scripts/delete-deployment-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Set the pipefail option.
set -o pipefail

# Get the Vercel API endpoints.
GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments"
DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments"

# Create a list of deployments.
deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ")
#deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ")

# Filter the deployments list by meta.base_hash === meta tag.
filtered_deployments=$(echo -E $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")')
filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes

# Clears the values from filtered_deployments
IFS=',' read -ra values <<<"$filtered_deployments"

echo "META_TAG ${META_TAG}"
echo "Filtered deployments ${filtered_deployments}"

# Iterate over the filtered deployments list.
for uid in "${values[@]}"; do
echo "Deleting ${uid}"

delete_url="${DELETE_DEPLOYMENTS_ENDPOINT}/${uid}?teamId=${VERCEL_ORG_ID}"
echo $delete_url

# Make DELETE a request to the /v13/deployments/{id} endpoint.
curl -X DELETE $delete_url -H "Authorization: Bearer $VERCEL_TOKEN"

echo "Deleted!"
done
Loading