Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8175f199d2 | ||
|
|
f8c2f396c1 | ||
|
|
8217647df8 | ||
|
|
288c9eeeca | ||
|
|
4d09ff7c8a |
@@ -1,11 +1,15 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
const dialog = ref(false)
|
const dialog = ref(false)
|
||||||
const currentModel = useCurrentModel()
|
const currentModel = useCurrentModel()
|
||||||
const availableModels = [
|
const availableModels = [
|
||||||
DEFAULT_MODEL.name
|
'gpt-3.5-turbo',
|
||||||
|
'gpt-4'
|
||||||
]
|
]
|
||||||
|
const currentModelDefault = ref(MODELS[currentModel.value.name])
|
||||||
|
|
||||||
watch(currentModel, (newVal, oldVal) => {
|
watch(currentModel, (newVal, oldVal) => {
|
||||||
|
currentModelDefault.value = MODELS[newVal.name]
|
||||||
saveCurrentModel(newVal)
|
saveCurrentModel(newVal)
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
||||||
@@ -83,7 +87,7 @@ watch(currentModel, (newVal, oldVal) => {
|
|||||||
single-line
|
single-line
|
||||||
density="compact"
|
density="compact"
|
||||||
type="number"
|
type="number"
|
||||||
max="2048"
|
:max="currentModelDefault.total_tokens"
|
||||||
step="1"
|
step="1"
|
||||||
style="width: 100px"
|
style="width: 100px"
|
||||||
class="flex-grow-0"
|
class="flex-grow-0"
|
||||||
@@ -93,7 +97,7 @@ watch(currentModel, (newVal, oldVal) => {
|
|||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-slider
|
<v-slider
|
||||||
v-model="currentModel.max_tokens"
|
v-model="currentModel.max_tokens"
|
||||||
:max="2048"
|
:max="currentModelDefault.total_tokens"
|
||||||
:step="1"
|
:step="1"
|
||||||
hide-details
|
hide-details
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
export const useModels = () => useState('models', () => getStoredModels())
|
// export const useModels = () => useState('models', () => getStoredModels())
|
||||||
|
|
||||||
export const useCurrentModel = () => useState('currentModel', () => getCurrentModel())
|
export const useCurrentModel = () => useState('currentModel', () => getCurrentModel())
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
client:
|
client:
|
||||||
|
platform: linux/x86_64
|
||||||
image: wongsaang/chatgpt-ui-client:latest
|
image: wongsaang/chatgpt-ui-client:latest
|
||||||
environment:
|
environment:
|
||||||
- SERVER_DOMAIN=http://backend-web-server
|
- SERVER_DOMAIN=http://backend-web-server
|
||||||
@@ -15,6 +16,7 @@ services:
|
|||||||
- chatgpt_ui_network
|
- chatgpt_ui_network
|
||||||
restart: always
|
restart: always
|
||||||
backend-wsgi-server:
|
backend-wsgi-server:
|
||||||
|
platform: linux/x86_64
|
||||||
image: wongsaang/chatgpt-ui-wsgi-server:latest
|
image: wongsaang/chatgpt-ui-wsgi-server:latest
|
||||||
environment:
|
environment:
|
||||||
- APP_DOMAIN=${APP_DOMAIN:-localhost:9000}
|
- APP_DOMAIN=${APP_DOMAIN:-localhost:9000}
|
||||||
@@ -36,6 +38,7 @@ services:
|
|||||||
- chatgpt_ui_network
|
- chatgpt_ui_network
|
||||||
restart: always
|
restart: always
|
||||||
backend-web-server:
|
backend-web-server:
|
||||||
|
platform: linux/x86_64
|
||||||
image: wongsaang/chatgpt-ui-web-server:latest
|
image: wongsaang/chatgpt-ui-web-server:latest
|
||||||
environment:
|
environment:
|
||||||
- BACKEND_URL=http://backend-wsgi-server:8000
|
- BACKEND_URL=http://backend-wsgi-server:8000
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ const signOut = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const settings = useSettings()
|
||||||
|
const showApiKeySetting = ref(false)
|
||||||
|
watchEffect(() => {
|
||||||
|
if (settings.value) {
|
||||||
|
const settingsValue = toRaw(settings.value)
|
||||||
|
showApiKeySetting.value = settingsValue.open_api_key_setting && settingsValue.open_api_key_setting === 'True'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadConversations()
|
loadConversations()
|
||||||
loadSettings()
|
loadSettings()
|
||||||
@@ -240,7 +249,7 @@ onMounted(async () => {
|
|||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<ApiKeyDialog
|
<ApiKeyDialog
|
||||||
v-if="runtimeConfig.public.customApiKey"
|
v-if="showApiKeySetting"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ModelParameters/>
|
<ModelParameters/>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const fetchReply = async (message) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = Object.assign({}, currentModel.value, {
|
const data = Object.assign({}, currentModel.value, {
|
||||||
openaiApiKey: openaiApiKey.value,
|
openaiApiKey: enableCustomApiKey.value ? openaiApiKey.value : null,
|
||||||
message: message,
|
message: message,
|
||||||
conversationId: currentConversation.value.id
|
conversationId: currentConversation.value.id
|
||||||
}, webSearchParams)
|
}, webSearchParams)
|
||||||
@@ -90,12 +90,13 @@ const fetchReply = async (message) => {
|
|||||||
throw err;
|
throw err;
|
||||||
},
|
},
|
||||||
async onmessage(message) {
|
async onmessage(message) {
|
||||||
// console.log(message)
|
|
||||||
const event = message.event
|
const event = message.event
|
||||||
const data = JSON.parse(message.data)
|
const data = JSON.parse(message.data)
|
||||||
|
|
||||||
if (event === 'error') {
|
if (event === 'error') {
|
||||||
throw new Error(data.error);
|
abortFetch()
|
||||||
|
showSnackbar(data.error)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event === 'userMessageId') {
|
if (event === 'userMessageId') {
|
||||||
@@ -165,6 +166,7 @@ const deleteMessage = (index) => {
|
|||||||
|
|
||||||
const showWebSearchToggle = ref(false)
|
const showWebSearchToggle = ref(false)
|
||||||
const enableWebSearch = ref(false)
|
const enableWebSearch = ref(false)
|
||||||
|
const enableCustomApiKey = ref(false)
|
||||||
|
|
||||||
const settings = useSettings()
|
const settings = useSettings()
|
||||||
|
|
||||||
@@ -172,6 +174,7 @@ watchEffect(() => {
|
|||||||
if (settings.value) {
|
if (settings.value) {
|
||||||
const settingsValue = toRaw(settings.value)
|
const settingsValue = toRaw(settings.value)
|
||||||
showWebSearchToggle.value = settingsValue.open_web_search && settingsValue.open_web_search === 'True'
|
showWebSearchToggle.value = settingsValue.open_web_search && settingsValue.open_web_search === 'True'
|
||||||
|
enableCustomApiKey.value = settingsValue.open_api_key_setting && settingsValue.open_api_key_setting === 'True'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,25 @@ export const STORAGE_KEY = {
|
|||||||
OPENAI_API_KEY: 'openai_api_key',
|
OPENAI_API_KEY: 'openai_api_key',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_MODEL = {
|
export const MODELS = {
|
||||||
name: 'gpt-3.5-turbo',
|
'gpt-3.5-turbo': {
|
||||||
frequency_penalty: 0.0,
|
name: 'gpt-3.5-turbo',
|
||||||
presence_penalty: 0.0,
|
frequency_penalty: 0.0,
|
||||||
max_tokens: 1000,
|
presence_penalty: 0.0,
|
||||||
temperature: 0.7,
|
total_tokens: 4096,
|
||||||
top_p: 1.0
|
max_tokens: 1000,
|
||||||
|
temperature: 0.7,
|
||||||
|
top_p: 1.0
|
||||||
|
},
|
||||||
|
'gpt-4': {
|
||||||
|
name: 'gpt-4',
|
||||||
|
frequency_penalty: 0.0,
|
||||||
|
presence_penalty: 0.0,
|
||||||
|
total_tokens: 8192,
|
||||||
|
max_tokens: 2000,
|
||||||
|
temperature: 0.7,
|
||||||
|
top_p: 1.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_MODEL_NAME = 'gpt-3.5-turbo'
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {MODELS} from "~/utils/enums";
|
||||||
|
|
||||||
const get = (key) => {
|
const get = (key) => {
|
||||||
let val = localStorage.getItem(key)
|
let val = localStorage.getItem(key)
|
||||||
@@ -17,13 +18,13 @@ export const setModels = (val) => {
|
|||||||
models.value = val
|
models.value = val
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStoredModels = () => {
|
// export const getStoredModels = () => {
|
||||||
let models = get(STORAGE_KEY.MODELS)
|
// let models = get(STORAGE_KEY.MODELS)
|
||||||
if (!models) {
|
// if (!models) {
|
||||||
models = [DEFAULT_MODEL]
|
// models = [DEFAULT_MODEL]
|
||||||
}
|
// }
|
||||||
return models
|
// return models
|
||||||
}
|
// }
|
||||||
|
|
||||||
export const saveCurrentModel = (val) => {
|
export const saveCurrentModel = (val) => {
|
||||||
set(STORAGE_KEY.CURRENT_MODEL, val)
|
set(STORAGE_KEY.CURRENT_MODEL, val)
|
||||||
@@ -32,7 +33,7 @@ export const saveCurrentModel = (val) => {
|
|||||||
export const getCurrentModel = () => {
|
export const getCurrentModel = () => {
|
||||||
let model = get(STORAGE_KEY.CURRENT_MODEL)
|
let model = get(STORAGE_KEY.CURRENT_MODEL)
|
||||||
if (!model) {
|
if (!model) {
|
||||||
model = DEFAULT_MODEL
|
model = MODELS[DEFAULT_MODEL_NAME]
|
||||||
}
|
}
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user