From b6f227cbd7b8d5a7ca572a3c44022e9545f006ca Mon Sep 17 00:00:00 2001
From: YuShifan <894402575bt@gmail.com>
Date: Fri, 28 Jun 2024 11:32:38 +0800
Subject: [PATCH 1/2] feat(desktop): moonshot llm api support on copilot
---
src/views/settings/index.vue | 147 ++++++++++++++++++++++++++++-------
1 file changed, 117 insertions(+), 30 deletions(-)
diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue
index d07dfbd43..dc8a81c90 100644
--- a/src/views/settings/index.vue
+++ b/src/views/settings/index.vue
@@ -293,11 +293,22 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
+
+
+ @clear="handleAIConfigChanged('model')"
+ @blur="handleAIConfigChanged('model')"
+ @focus="showAIModelsSelect = true"
+ @input="showAIModelsSelect = false"
+ >
@@ -362,9 +384,13 @@ import ExportData from '@/components/ExportData.vue'
import ClearUpHistoryData from '@/components/ClearUpHistoryData.vue'
import CryptoJS from 'crypto-js'
import { ENCRYPT_KEY } from '@/utils/idGenerator'
+import ClickOutside from 'vue-click-outside'
@Component({
components: { ImportData, ExportData, ClearUpHistoryData },
+ directives: {
+ ClickOutside,
+ },
})
export default class Settings extends Vue {
@Action('TOGGLE_THEME') private actionTheme!: (payload: { currentTheme: string }) => void
@@ -394,6 +420,9 @@ export default class Settings extends Vue {
@Getter('openAIAPIKey') private openAIAPIKey!: string
@Getter('model') private model!: AIModel
@Getter('logLevel') private logLevel!: LogLevel
+
+ private showAIModelsSelect = false
+
private langOptions: Options[] = [
{ label: '简体中文', value: 'zh' },
{ label: 'English', value: 'en' },
@@ -407,16 +436,33 @@ export default class Settings extends Vue {
{ label: 'Night', value: 'night' },
]
private AImodelsOptions = [
- { value: 'gpt-3.5-turbo' },
- { value: 'gpt-3.5-turbo-0125' },
- { value: 'gpt-3.5-turbo-1106' },
- { value: 'gpt-3.5-turbo-16k' },
- { value: 'gpt-4' },
- { value: 'gpt-4-32k' },
- { value: 'gpt-4-0613' },
- { value: 'gpt-4-32k-0613' },
- { value: 'gpt-4-turbo' },
- { value: 'gpt-4o' },
+ {
+ value: 'OpenAI',
+ children: [
+ { value: 'gpt-3.5-turbo' },
+ { value: 'gpt-3.5-turbo-0125' },
+ { value: 'gpt-3.5-turbo-1106' },
+ { value: 'gpt-3.5-turbo-16k' },
+ { value: 'gpt-4' },
+ { value: 'gpt-4-32k' },
+ { value: 'gpt-4-0613' },
+ { value: 'gpt-4-32k-0613' },
+ { value: 'gpt-4-turbo' },
+ { value: 'gpt-4o' },
+ ],
+ },
+ {
+ value: 'Moonshot',
+ children: [{ value: 'moonshot-v1-8k' }, { value: 'moonshot-v1-32k' }, { value: 'moonshot-v1-128k' }],
+ },
+ ]
+ private AIAPIHostOptions = [
+ {
+ value: 'https://api.openai.com/v1',
+ },
+ {
+ value: 'https://api.moonshot.cn/v1',
+ },
]
private showImportData = false
private showExportData = false
@@ -503,13 +549,15 @@ export default class Settings extends Vue {
}
}
- private handleAIConfigModelSelected({ value }: { value: string }) {
+ private handleAIConfigModelSelected(value: AIModel) {
this.aiConfig.model = value
this.actionSetModel({ model: value })
+ this.showAIModelsSelect = false
}
- private queryAImodels(queryString: AIModel, cb: (r: any[]) => {}) {
- cb(queryString ? this.AImodelsOptions.filter((item) => item.value.includes(queryString)) : this.AImodelsOptions)
+ private handleAIConfigHostSelected({ value }: { value: string }) {
+ this.aiConfig.openAIAPIHost = value
+ this.actionSetOpenAIAPIHost({ openAIAPIHost: value })
}
private getAIConfigs() {
@@ -526,6 +574,14 @@ export default class Settings extends Vue {
})
}
+ private handleClickPresetOutside() {
+ this.showAIModelsSelect = false
+ }
+
+ private queryAIAPIHost(queryString: string, cb: (r: any[]) => {}) {
+ cb(queryString ? this.AIAPIHostOptions.filter((item) => item.value.includes(queryString)) : this.AIAPIHostOptions)
+ }
+
private created() {
this.getAIConfigs()
}
@@ -616,5 +672,36 @@ export default class Settings extends Vue {
left: 5px;
color: var(--color-text-default);
}
+ .ai-models-select {
+ position: absolute;
+ bottom: 36px;
+ right: 0px;
+ box-shadow: #00000014 0px 4px 12px;
+ background: var(--color-bg-normal);
+ border: 1px solid var(--color-border-default);
+ .el-cascader-menu:last-child {
+ width: 100%;
+ }
+ .el-cascader-menu,
+ i {
+ color: var(--color-text-default);
+ }
+ .el-cascader-menu {
+ border-right: 1px solid var(--color-border-default);
+ &:last-child {
+ border-right: none;
+ }
+ }
+ .el-cascader-node.is-active {
+ .el-icon-check.el-cascader-node__prefix {
+ color: var(--color-main-green);
+ }
+ }
+ .el-cascader-node:not(.is-disabled):hover,
+ .el-cascader-node:not(.is-disabled):focus {
+ background-color: transparent;
+ color: var(--color-main-green);
+ }
+ }
}
From da45382c89617a48c765b17dbf147dd1b2efc2c0 Mon Sep 17 00:00:00 2001
From: YuShifan <894402575bt@gmail.com>
Date: Fri, 28 Jun 2024 14:08:14 +0800
Subject: [PATCH 2/2] fix(desktop): remove useless code on settings
---
src/views/settings/index.vue | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue
index dc8a81c90..27d976755 100644
--- a/src/views/settings/index.vue
+++ b/src/views/settings/index.vue
@@ -308,16 +308,6 @@
@select="handleAIConfigHostSelected"
@change="handleAIConfigChanged('host')"
>
-