Skip to content

Commit

Permalink
[Add] ✨ Copilot Pro Support adams549659584#401
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed Apr 29, 2024
1 parent c29d6b3 commit 13dccf6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
8 changes: 8 additions & 0 deletions frontend/public/js/bing/chat/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ _w['_sydConvConfig'] = {
multimediaSearchFormCode: 'IACMIR',
multimediaSearchEnableMediaCanvas: true,
multimediaSearchMaxImageCount: 5,
// GPT 4 Turbo
enableTurboTone: false,
enableGPT4TurboSwitch: false,
};
_w['_sydThreads'] = {
threads: [],
Expand Down Expand Up @@ -1649,6 +1652,11 @@ if (UserStoreGet('enterpriseEnable')) {
_w['_sydConvTranslation']['inputRaiLabel'] = '你的个人和公司数据在此聊天中受到保护'
}

if (UserStoreGet('copilotProEnable')) {
_w['_sydConvConfig']['enableTurboTone'] = true
_w['_sydConvConfig']['enableGPT4TurboSwitch'] = true
}

_G.Region = UserStoreGet('langRegion') || 'CN'

_w['_sydConvConfig']['enableAutoReopenMic'] = UserStoreGet('autoReopenMic') || true
Expand Down
42 changes: 36 additions & 6 deletions frontend/src/components/ChatNav/ChatNav.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { h, ref, onMounted, inject, defineComponent, render } from 'vue';
import { NDropdown, type DropdownOption, NModal, NInput, NInputNumber, NButton, NGrid, NGridItem, useMessage, NImage, NForm, NFormItem, NSwitch, NTag, NSelect, NSpin, NP, NA, NConfigProvider, NSpace, NRadio, NRadioGroup, NTooltip, lightTheme, darkTheme, useOsTheme, type GlobalTheme } from 'naive-ui';
import { NDropdown, type DropdownOption, NModal, NInput, NInputNumber, NButton, NGrid, NGridItem, useMessage, NImage, NForm, NFormItem, NSwitch, NTag, NSelect, NSpin, NP, NA, NConfigProvider, NSpace, NRadio, NRadioGroup, NTooltip, NIcon, lightTheme, darkTheme, useOsTheme, type GlobalTheme } from 'naive-ui';
import conversationCssText from '@/assets/css/conversation.css?raw';
import settingSvgUrl from '@/assets/img/setting.svg?url';
import { usePromptStore } from '@/stores/modules/prompt';
Expand Down Expand Up @@ -33,7 +33,7 @@ const { isShowChatServiceSelectModal } = storeToRefs(chatStore);
const userStore = useUserStore();
const localVersion = __APP_INFO__.version;
const lastVersion = ref('加载中...');
const { historyEnable, themeMode, uiVersion, langRegion, autoReopenMic, fullCookiesEnable, cookiesStr, enterpriseEnable, customChatNum, gpt4tEnable, sydneyEnable, sydneyPrompt, passServer } = storeToRefs(userStore);
const { historyEnable, themeMode, uiVersion, langRegion, autoReopenMic, fullCookiesEnable, cookiesStr, enterpriseEnable, copilotProEnable, customChatNum, gpt4tEnable, sydneyEnable, sydneyPrompt, passServer } = storeToRefs(userStore);
let cookiesEnable = ref(false);
let cookies = ref('');
Expand All @@ -49,6 +49,7 @@ let settingIconStyle = ref({
})
let passingCFChallenge = ref(false);
const enterpriseSetting = ref(false);
const copilotProSetting = ref(false);
const customChatNumSetting = ref(0);
const gpt4tSetting = ref(true);
const sydneySetting = ref(false);
Expand Down Expand Up @@ -339,6 +340,7 @@ const settingMenu = (key: string) => {
themeModeSetting.value = themeMode.value;
uiVersionSetting.value = uiVersion.value;
langRegionSetting.value = langRegion.value;
copilotProSetting.value = copilotProEnable.value;
enterpriseSetting.value = enterpriseEnable.value;
customChatNumSetting.value = customChatNum.value;
gpt4tSetting.value = gpt4tEnable.value;
Expand Down Expand Up @@ -396,7 +398,8 @@ const saveAdvancedSetting = () => {
const tmpEnterpris = enterpriseEnable.value;
enterpriseEnable.value = enterpriseSetting.value;
customChatNum.value = customChatNumSetting.value;
const tmpGpt4t = gpt4tEnable.value, tmpSydney = sydneyEnable.value, tmpuiVersion = uiVersion.value;
const tmpGpt4t = gpt4tEnable.value, tmpSydney = sydneyEnable.value, tmpuiVersion = uiVersion.value, tmpCopilotPro = copilotProEnable.value;
copilotProEnable.value = copilotProSetting.value;
gpt4tEnable.value = gpt4tSetting.value;
autoReopenMic.value = autoReopenMicSetting.value;
sydneyEnable.value = sydneySetting.value;
Expand Down Expand Up @@ -459,7 +462,7 @@ const saveAdvancedSetting = () => {
}
}
isShowAdvancedSettingModal.value = false;
if (tmpEnterpris != enterpriseSetting.value || tmpSydney != sydneySetting.value || tmpGpt4t != gpt4tSetting.value || tmpuiVersion != uiVersionSetting.value) {
if (tmpEnterpris != enterpriseSetting.value || tmpSydney != sydneySetting.value || tmpGpt4t != gpt4tSetting.value || tmpuiVersion != uiVersionSetting.value || tmpCopilotPro != copilotProSetting.value) {
window.location.href = '/';
}
}
Expand Down Expand Up @@ -877,15 +880,42 @@ const autoPassCFChallenge = async () => {
</NFormItem>
</NGridItem>
<NGridItem>
<NFormItem path="gpt4tEnable" label="GPT4 Turbo">
<NSwitch v-model:value="gpt4tSetting" />
<NFormItem path="copilotProEnable">
<template #label>
Copilot Pro
<NTooltip trigger="hover">
<template #trigger>
<NIcon size="14" style="top: 2px;">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512"><path d="M256 56C145.72 56 56 145.72 56 256s89.72 200 200 200s200-89.72 200-200S366.28 56 256 56zm0 82a26 26 0 1 1-26 26a26 26 0 0 1 26-26zm64 226H200v-32h44v-88h-32v-32h64v120h44z" fill="currentColor"></path></svg>
</NIcon>
</template>
如果有 Copilot Pro 的账号, 可开启此选项
</NTooltip>
</template>
<NSwitch v-model:value="copilotProSetting" />
</NFormItem>
</NGridItem>
<NGridItem>
<NFormItem path="sydneyEnable" label="连续语音对话">
<NSwitch v-model:value="autoReopenMicSetting" />
</NFormItem>
</NGridItem>
<NGridItem>
<NFormItem path="gpt4tEnable">
<template #label>
Copilot 增强
<NTooltip trigger="hover" :style="{ maxWidth: '240px' }">
<template #trigger>
<NIcon size="14" style="top: 2px;">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512"><path d="M256 56C145.72 56 56 145.72 56 256s89.72 200 200 200s200-89.72 200-200S366.28 56 256 56zm0 82a26 26 0 1 1-26 26a26 26 0 0 1 26-26zm64 226H200v-32h44v-88h-32v-32h64v120h44z" fill="currentColor"></path></svg>
</NIcon>
</template>
增强 Microsoft Copilot 的能力, 有可能会导致一些问题
</NTooltip>
</template>
<NSwitch v-model:value="gpt4tSetting" />
</NFormItem>
</NGridItem>
<NGridItem>
<NFormItem path="sydneyEnable" label="越狱模式">
<NSwitch v-model:value="sydneySetting" />
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/stores/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const useUserStore = defineStore(
const langRegion = ref('CN');
const autoReopenMic = ref(true);
const enterpriseEnable = ref(false);
const copilotProEnable = ref(false);
const customChatNum = ref(0);
const gpt4tEnable = ref(true);
const sydneyEnable = ref(false);
Expand Down Expand Up @@ -200,6 +201,7 @@ export const useUserStore = defineStore(
langRegion,
autoReopenMic,
enterpriseEnable,
copilotProEnable,
customChatNum,
gpt4tEnable,
sydneyEnable,
Expand All @@ -211,7 +213,7 @@ export const useUserStore = defineStore(
persist: {
key: 'user-store',
storage: localStorage,
paths: ['historyEnable', 'themeMode', 'uiVersion', 'langRegion', 'autoReopenMic', 'fullCookiesEnable', 'cookiesStr', 'enterpriseEnable', 'customChatNum', 'gpt4tEnable', 'sydneyEnable', 'sydneyPrompt', 'passServer'],
paths: ['historyEnable', 'themeMode', 'uiVersion', 'langRegion', 'autoReopenMic', 'fullCookiesEnable', 'cookiesStr', 'enterpriseEnable', 'copilotProEnable', 'customChatNum', 'gpt4tEnable', 'sydneyEnable', 'sydneyPrompt', 'passServer'],
},
}
);
19 changes: 17 additions & 2 deletions frontend/src/views/chat/components/Chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const isShowHistory = computed(() => {
return (CIB.vm.isMobile && CIB.vm.sidePanel.isVisibleMobile) || (!CIB.vm.isMobile && CIB.vm.sidePanel.isVisibleDesktop);
});
const { themeMode, uiVersion, gpt4tEnable, sydneyEnable, sydneyPrompt, enterpriseEnable } = storeToRefs(userStore);
const { themeMode, uiVersion, gpt4tEnable, sydneyEnable, sydneyPrompt, enterpriseEnable, copilotProEnable } = storeToRefs(userStore);
onMounted(async () => {
await initChat();
Expand Down Expand Up @@ -243,6 +243,9 @@ const hackEnterprise = () => {
}
const initSydney = () => {
if (copilotProEnable.value) {
hackCopilotPro();
}
if (gpt4tEnable.value) {
hackG4t();
}
Expand All @@ -259,8 +262,20 @@ const initSydney = () => {
}
}
const hackCopilotPro = () => {
CIB.config.sydney.request.source = 'cib-ccp'
}
const hackG4t = () => {
CIB.config.sydney.request.optionsSets.push("dlgpt4t")
CIB.config.sydney.request.optionsSets.push(
"dlgpt4t",
"dlbmtc",
"dlbpc4575",
"dlbrngnp",
"dlbtc",
"dlbuc07",
"dlbuf03"
)
}
const hackSydney = (first=true) => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/types/bing/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,10 @@ declare const CIB: {
hostnamesToBypassSecureConnection: string[];
expiryInMinutes: number;
request: {
source: string;
sliceIds: string[];
optionsSets: string[];
}
};
};
messaging: {
/**
Expand Down

0 comments on commit 13dccf6

Please sign in to comment.