Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyos committed Feb 5, 2024
2 parents 8a0f5dc + a441b59 commit 94bf14c
Show file tree
Hide file tree
Showing 68 changed files with 300 additions and 226 deletions.
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/[email protected]
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/[email protected]
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
2 changes: 1 addition & 1 deletion app/components/emoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getEmojiUrl(unified: string, style: EmojiStyle) {
// Whoever owns this Content Delivery Network (CDN), I am using your CDN to serve emojis
// Old CDN broken, so I had to switch to this one
// Author: https://github.com/H0llyW00dzZ
return `https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`;
return `https://fastly.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`;
}

export function AvatarPicker(props: {
Expand Down
4 changes: 2 additions & 2 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function CheckButton() {
const syncStore = useSyncStore();

const couldCheck = useMemo(() => {
return syncStore.coundSync();
return syncStore.cloudSync();
}, [syncStore]);

const [checkState, setCheckState] = useState<
Expand Down Expand Up @@ -472,7 +472,7 @@ function SyncItems() {
const promptStore = usePromptStore();
const maskStore = useMaskStore();
const couldSync = useMemo(() => {
return syncStore.coundSync();
return syncStore.cloudSync();
}, [syncStore]);

const [showSyncConfigModal, setShowSyncConfigModal] = useState(false);
Expand Down
2 changes: 2 additions & 0 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export const getServerSideConfig = () => {
googleApiKey: process.env.GOOGLE_API_KEY,
googleUrl: process.env.GOOGLE_URL,

gtmId: process.env.GTM_ID,

needCode: ACCESS_CODES.size > 0,
code: process.env.CODE,
codes: ACCESS_CODES,
Expand Down
34 changes: 33 additions & 1 deletion app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Google = {

export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
export const DEFAULT_SYSTEM_TEMPLATE = `
You are ChatGPT, a large language model trained by OpenAI.
You are ChatGPT, a large language model trained by {{ServiceProvider}}.
Knowledge cutoff: {{cutoff}}
Current model: {{model}}
Current time: {{time}}
Expand All @@ -107,8 +107,13 @@ 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",
// After improvements,
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
"gemini-pro": "2023-12",
};

export const DEFAULT_MODELS = [
Expand Down Expand Up @@ -166,6 +171,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 +189,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 All @@ -193,6 +216,15 @@ export const DEFAULT_MODELS = [
providerType: "openai",
},
},
{
name: "gpt-3.5-turbo-0125",
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
},
{
name: "gpt-3.5-turbo-0301",
available: true,
Expand Down
2 changes: 1 addition & 1 deletion app/icons/auto.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 1 addition & 28 deletions app/icons/bot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 94bf14c

Please sign in to comment.