Skip to content

Commit

Permalink
✨ Feature(custom): add gpt 3.5 16k model
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Jun 14, 2023
1 parent 3eba33d commit 0881018
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
38 changes: 23 additions & 15 deletions src/pages/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
import { onBeforeMount, ref } from 'vue'
import { AxiosProxyConfig } from 'axios'
import { useRouter } from 'vue-router'
import { localStorageKey, languageMap, buildInPrompt } from '@/utils/constant'
import { localStorageKey, languageMap, buildInPrompt, availableModels } from '@/utils/constant'
import { promptDbInstance } from '@/store/promtStore'
import { IStringKeyMap } from '@/types'
import { CirclePlus, Remove } from '@element-plus/icons-vue'
Expand Down Expand Up @@ -534,31 +534,39 @@ function handelPromptChange (val: string) {
}
onBeforeMount(async () => {
api.value = localStorage.getItem(localStorageKey.api) as 'web-api' | 'official' | 'azure' ?? 'web-api'
replyLanguage.value = localStorage.getItem(localStorageKey.replyLanguage) ?? 'English'
localLanguage.value = localStorage.getItem(localStorageKey.localLanguage) ?? 'en'
apiKey.value = localStorage.getItem(localStorageKey.apiKey) ?? ''
accessToken.value = localStorage.getItem(localStorageKey.accessToken) ?? ''
azureAPIKey.value = localStorage.getItem(localStorageKey.azureAPIKey) ?? ''
webModel.value = localStorage.getItem(localStorageKey.webModel) ?? 'default'
api.value = localStorage.getItem(localStorageKey.api) as 'web-api' | 'official' | 'azure' || 'web-api'
replyLanguage.value = localStorage.getItem(localStorageKey.replyLanguage) || 'English'
localLanguage.value = localStorage.getItem(localStorageKey.localLanguage) || 'en'
apiKey.value = localStorage.getItem(localStorageKey.apiKey) || ''
accessToken.value = localStorage.getItem(localStorageKey.accessToken) || ''
azureAPIKey.value = localStorage.getItem(localStorageKey.azureAPIKey) || ''
webModel.value = localStorage.getItem(localStorageKey.webModel) || 'default'
temperature.value = Number(localStorage.getItem(localStorageKey.temperature)) || 0.7
maxTokens.value = Number(localStorage.getItem(localStorageKey.maxTokens)) || 800
model.value = localStorage.getItem(localStorageKey.model) ?? 'gpt-3.5-turbo'
basePath.value = localStorage.getItem(localStorageKey.basePath) ?? ''
const modelTemp = localStorage.getItem(localStorageKey.model) || availableModels['gpt-3.5']
if (Object.keys(availableModels).includes(modelTemp)) {
model.value = availableModels[modelTemp]
} else if (Object.values(availableModels).includes(modelTemp)) {
model.value = modelTemp
} else {
model.value = availableModels['gpt-3.5']
}
console.log(model.value)
basePath.value = localStorage.getItem(localStorageKey.basePath) || ''
proxy.value = localStorage.getItem(localStorageKey.enableProxy) === 'false'
? false
: JSON.parse(localStorage.getItem(localStorageKey.proxy) || 'false')
azureAPIEndpoint.value = localStorage.getItem(localStorageKey.azureAPIEndpoint) ?? ''
azureDeploymentName.value = localStorage.getItem(localStorageKey.azureDeploymentName) ?? ''
azureAPIEndpoint.value = localStorage.getItem(localStorageKey.azureAPIEndpoint) || ''
azureDeploymentName.value = localStorage.getItem(localStorageKey.azureDeploymentName) || ''
azureMaxTokens.value = Number(localStorage.getItem(localStorageKey.azureMaxTokens)) || 800
azureTemperature.value = Number(localStorage.getItem(localStorageKey.azureTemperature)) || 0.7
insertType.value = localStorage.getItem(localStorageKey.insertType) ?? 'replace' as 'replace' | 'append' | 'newLine' | 'NoAction'
systemPrompt.value = localStorage.getItem(localStorageKey.defaultSystemPrompt) ?? 'Act like a personal assistant.'
insertType.value = localStorage.getItem(localStorageKey.insertType) || 'replace' as 'replace' | 'append' | 'newLine' | 'NoAction'
systemPrompt.value = localStorage.getItem(localStorageKey.defaultSystemPrompt) || 'Act like a personal assistant.'
await getSystemPromptList()
if (systemPromptList.value.find((item) => item.value === systemPrompt.value)) {
systemPromptSelected.value = systemPrompt.value
}
prompt.value = localStorage.getItem(localStorageKey.defaultPrompt) ?? ''
prompt.value = localStorage.getItem(localStorageKey.defaultPrompt) || ''
await getPromptList()
if (promptList.value.find((item) => item.value === prompt.value)) {
promptSelected.value = prompt.value
Expand Down
6 changes: 4 additions & 2 deletions src/pages/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,13 @@ function initData () {
webModel.value = localStorage.getItem(localStorageKey.webModel) || 'default'
// official API
apiKey.value = localStorage.getItem(localStorageKey.apiKey) || ''
const modelTemp = localStorage.getItem(localStorageKey.model) || 'gpt-3.5-turbo'
const modelTemp = localStorage.getItem(localStorageKey.model) || availableModels['gpt-3.5']
if (Object.keys(availableModels).includes(modelTemp)) {
model.value = availableModels[modelTemp]
} else {
} else if (Object.values(availableModels).includes(modelTemp)) {
model.value = modelTemp
} else {
model.value = availableModels['gpt-3.5']
}
temperature.value = forceNumber(localStorage.getItem(localStorageKey.temperature)) || 0.7
maxTokens.value = forceNumber(localStorage.getItem(localStorageKey.maxTokens)) || 800
Expand Down
8 changes: 6 additions & 2 deletions src/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ export const languageMap: IStringKeyMap = {
// Openai API 可用的模型
export const availableModels: IStringKeyMap = {
'gpt-3.5': 'gpt-3.5-turbo',
'gpt-3.5-0613': 'gpt-3.5-turbo-0613',
'gpt-3.5-16k': 'gpt-3.5-turbo-16k',
'gpt-3.5-16k-0613': 'gpt-3.5-turbo-16k-0613',
'text-davinci-003': 'text-davinci-003',
gtp4: 'gpt-4',
'gpt4-0314': 'gpt-4-0314',
'gpt4-0613': 'gpt-4-0613',
'gpt4-32k': 'gpt-4-32k',
'gpt4-32k-0314': 'gpt-4-32k-0314'
'gpt4-32k-0613': 'gpt-4-32k-0613'
}

// Web API 可用的模型
Expand Down

0 comments on commit 0881018

Please sign in to comment.