Skip to content

Commit

Permalink
WhiteBox
Browse files Browse the repository at this point in the history
  • Loading branch information
spammenotinoz committed Nov 25, 2023
1 parent 86123a1 commit fe3c934
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 83 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/New Main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and publish Docker image Spam

on:
push:
tags: ["v*"]
branches: ["test-workflow"]
workflow_dispatch:
inputs:
version:
description: "Version tag for the Docker image (semver)"
required: true

env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Clone ChatGPT-Proxy-V4
run: git clone https://github.com/moeakwak/ChatGPT-Proxy-V4.git

# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# go-version: "1.20"
# cache-dependency-path: ChatGPT-Proxy-V4/go.sum

# - name: build ChatGPT-Proxy-V4
# run: |
# cd ChatGPT-Proxy-V4
# go build

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}${{ github.event_name == 'workflow_dispatch' && format(',value={0}', github.event.inputs.version) || '' }}
type=semver,pattern={{major}}.{{minor}}${{ github.event_name == 'workflow_dispatch' && format(',value={0}', github.event.inputs.version) || '' }}
# - name: Create Sentry release
# uses: getsentry/action-release@v1
# env:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
# SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
# # SENTRY_URL: https://sentry.io/
# with:
# environment: production
# sourcemaps: frontend/dist/assets
# version: ${{ github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
12 changes: 2 additions & 10 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<link rel="icon" type="image/png" href="/icon.png" />
<link rel="code-repository" href="https://github.com/moeakwak/chatgpt-web-share" />
<title>ChatGPT Web Share</title>
<link rel="icon" type="image/svg+xml" href="/chatgpt-icon.svg" />
<title>Ultimate AI - ChatGPT</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
<!--
ChatGPT Web Share © 2023
This project is licensed under the GNU General Public License v3.0. This license mandates the inclusion of license and copyright notices, and requires that any derivative works are open source and distributed under the same license terms.
Note: Please do not remove this comment.
-->
19 changes: 3 additions & 16 deletions frontend/src/components/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@
<template #title>
<n-space :align="'center'">
<div class="lt-sm:hidden">
<a href="/" style="text-decoration: none; color: inherit">
<span class="lt-md:hidden">{{ $t('commons.siteTitleFull') }}</span>
<span class="md:hidden">{{ $t('commons.siteTitle') }}</span>
</a>
<a href="/" style="text-decoration: none; color: inherit">{{ $t('commons.siteTitle') }}</a>
</div>
<div class="hidden sm:block">
<a class="h-full inline-block flex" href="https://github.com/moeakwak/chatgpt-web-share" target="_blank">
<n-icon :color="appStore.theme == 'dark' ? 'white' : 'black'" :component="LogoGithub" />
</a>
</div>
<n-tag :bordered="false" type="success" size="small" class="hidden sm:inline-flex">
{{ version }}
</n-tag>
</n-space>
</n-space>
</template>
<template #avatar>
<!-- <ChatGPTAvatar color="green" icon-style="default" :size="32" /> -->
<CWSIcon />
<ChatGPTAvatar color="green" icon-style="default" :size="32" />
</template>
<template #extra>
<n-space>
Expand Down Expand Up @@ -70,7 +58,6 @@ import { useRoute } from 'vue-router';
import { updateUserMeApi } from '@/api/user';
import ChatGPTAvatar from '@/components/ChatGPTAvatar.vue';
import CWSIcon from '@/components/icons/CWSIcon.vue';
import router from '@/router';
import { useAppStore, useUserStore } from '@/store';
import { Preference } from '@/store/types';
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ import { createI18n, type I18n, type Locale } from 'vue-i18n';

import EN from './locales/en-US.json';
import ZH from './locales/zh-CN.json';
import MS from './locales/ms-MY.json';

let i18n: I18n;

const init = () => {
i18n = createI18n({
legacy: false,
locale: useStorage('language', 'zh-CN').value,
locale: useStorage('language', 'en-US').value,
messages: {
'en-US': {
...EN,
},
'ms-MY': {
...MS,
},
'zh-CN': {
...ZH,
},
Expand Down
1 change: 0 additions & 1 deletion frontend/src/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type ListAttr<T> = {
// 用于 UserProfile,复用了一部分 user_manager 代码
export function getUserAttrColumns(): ListAttr<UserRead>[] {
return [
{ title: '#', key: 'id' },
{ title: t('commons.username'), key: 'username' },
{ title: t('commons.email'), key: 'email' },
{ title: t('commons.nickname'), key: 'nickname' },
Expand Down
63 changes: 27 additions & 36 deletions frontend/src/views/conversation/components/NewConversationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"
/>
</n-form-item>
<n-form-item :label="t('labels.source')">
<n-select v-model:value="newConversationInfo.source" :options="availableChatSourceTypes" />
</n-form-item>
<n-form-item :label="t('labels.model')">
<n-select
v-model:value="newConversationInfo.model"
Expand All @@ -33,14 +30,6 @@
)
}}
</div>
<div class="text-xs text-right">
{{ t('commons.remain') }}:
{{
getCountTrans(
userStore.user?.setting[newConversationInfo.source!].per_model_ask_count[newConversationInfo.model!]
)
}}
</div>
</div>
</template>
</n-select>
Expand Down Expand Up @@ -80,6 +69,24 @@ import { Message } from '@/utils/tips';
import NewConversationFormModelSelectionLabel from './NewConversationFormModelSelectionLabel.vue';
import NewConversationFormPluginSelectionLabel from './NewConversationFormPluginSelectionLabel.vue';
//////
import { MdPeople } from '@vicons/ionicons4';
import { EventBusyFilled, QueueFilled } from '@vicons/material';
import { getServerStatusApi } from '@/api/status';
import { CommonStatusSchema } from '@/types/schema';
const serverStatus = ref<CommonStatusSchema>({});
const updateData = () => {
getServerStatusApi().then((res) => {
// console.log(res.data);
serverStatus.value = res.data;
});
};
updateData();
///////
const t = i18n.global.t as any;
const userStore = useUserStore();
Expand Down Expand Up @@ -217,29 +224,8 @@ const renderPluginSelectionTag: SelectRenderTag = ({ option, handleClose }) => {
};
function setDefaultValues() {
// const defaultSource = computed(() => {
if (appStore.lastSelectedSource) {
if (availableChatSourceTypes.value.find((source) => source.value === appStore.lastSelectedSource)) {
newConversationInfo.value.source = appStore.lastSelectedSource;
}
} else {
newConversationInfo.value.source =
availableChatSourceTypes.value.length > 0 ? (availableChatSourceTypes.value[0].value as ChatSourceTypes) : null;
}
if (appStore.lastSelectedModel) {
if (
newConversationInfo.value.source === 'openai_web' &&
availableModels.value.find((model) => model.value === appStore.lastSelectedModel)
) {
newConversationInfo.value.model = appStore.lastSelectedModel;
} else if (
newConversationInfo.value.source === 'openai_api' &&
availableModels.value.find((model) => model.value === appStore.lastSelectedModel)
) {
newConversationInfo.value.model = appStore.lastSelectedModel;
}
}
newConversationInfo.value.source = 'openai_web';
newConversationInfo.value.model = 'gpt_3_5';
}
setDefaultValues();
Expand Down Expand Up @@ -268,10 +254,14 @@ watch(
watch(
() => {
const model = newConversationInfo.value.model;
const gpt4Count = serverStatus.value?.gpt4_count_in_3_hours ?? 0;
const source = (model === 'gpt_4' && gpt4Count > 45) ? 'openai_api' : (model === 'gpt_4') ? 'openai_web' : 'openai_web'; // If GPT Usage is high, then use APIs
return {
title: newConversationInfo.value.title,
source: newConversationInfo.value.source,
model: newConversationInfo.value.model,
source: source,
model: model,
openaiWebPlugins: newConversationInfo.value.openaiWebPlugins,
} as NewConversationInfo;
},
Expand All @@ -288,4 +278,5 @@ watch(
newConversationInfo.value.model = null;
}
);
</script>
18 changes: 4 additions & 14 deletions frontend/src/views/conversation/components/StatusCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div>
<n-icon class="mr-1">
<md-people />
</n-icon>{{ $t('commons.activeUserIn5m') }}
</n-icon>{{ $t('Active Users') }}
</div>
<div>{{ serverStatus.active_user_in_5m }}</div>
</div>
Expand All @@ -18,19 +18,9 @@
<div>
<n-icon class="mr-1">
<md-people />
</n-icon>{{ $t('commons.activeUserIn1h') }}
</n-icon>{{ $t('GPT4 3h usage') }}
</div>
<div>{{ serverStatus.active_user_in_1h }}</div>
</div>
</n-list-item>
<n-list-item>
<div class="flex flex-row justify-between content-center">
<div>
<n-icon class="mr-1">
<md-people />
</n-icon>{{ $t('commons.activeUserIn1d') }}
</div>
<div>{{ serverStatus.active_user_in_1d }}</div>
<div>{{serverStatus.gpt4_count_in_3_hours}}/50</div>
</div>
</n-list-item>
<n-list-item>
Expand All @@ -48,7 +38,7 @@
<div>
<n-icon class="mr-1">
<QueueFilled />
</n-icon>{{ $t('commons.chatbotWaitingCount') }}
</n-icon>{{ $t('Users waiting') }}
</div>
<div>{{ serverStatus.chatbot_waiting_count }}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="mb-6">
<!-- <CWSIcon :color="appStore.theme == 'dark' ? 'white': 'black'" class="w-60" /> -->
<n-gradient-text :size="32" type="success" class="select-none">
ChatGPT● Web Share
ChatGPT
</n-gradient-text>
</div>
<n-card embedded class="w-90 p-6 m-6 rounded-lg">
Expand Down

0 comments on commit fe3c934

Please sign in to comment.