Compare commits

...

5 Commits

Author SHA1 Message Date
Rafi
8175f199d2 Support GPT-4 2023-03-27 22:17:19 +08:00
Wong Saang
f8c2f396c1 Merge pull request #70 from Paramon/main
#50 add platform to docker-compose
2023-03-25 21:03:50 +08:00
Andrii Paramonov
8217647df8 #50 add platform 2023-03-24 16:44:00 +02:00
Rafi
288c9eeeca Change the functionality of custom API key to be controlled by the admin panel to determine whether it is enabled or not. 2023-03-24 15:43:01 +08:00
Rafi
4d09ff7c8a Added env var NUXT_PUBLIC_CUSTOM_API_KEY to docs 2023-03-24 14:32:38 +08:00
7 changed files with 59 additions and 25 deletions

View File

@@ -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
> >

View File

@@ -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())

View File

@@ -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

View File

@@ -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/>

View File

@@ -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'
} }
}) })

View File

@@ -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 = {
'gpt-3.5-turbo': {
name: 'gpt-3.5-turbo', name: 'gpt-3.5-turbo',
frequency_penalty: 0.0, frequency_penalty: 0.0,
presence_penalty: 0.0, presence_penalty: 0.0,
total_tokens: 4096,
max_tokens: 1000, max_tokens: 1000,
temperature: 0.7, temperature: 0.7,
top_p: 1.0 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'

View File

@@ -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
} }