Skip to content

Commit

Permalink
Update NewConversationForm.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
spammenotinoz authored Oct 16, 2023
1 parent a702c45 commit 4cc9e97
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions frontend/src/views/conversation/components/NewConversationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"
/>
</n-form-item>
<n-form-item :label="t('labels.source')">
<n-select v-model:value="newConversationInfo.source" :options="availableChatSourceTypes" />
</n-form-item>
<n-form-item :label="t('labels.model')">
<n-select
v-model:value="newConversationInfo.model"
Expand All @@ -33,14 +30,6 @@
)
}}
</div>
<div class="text-xs text-right">
{{ t('commons.remain') }}:
{{
getCountTrans(
userStore.user?.setting[newConversationInfo.source!].per_model_ask_count[newConversationInfo.model!]
)
}}
</div>
</div>
</template>
</n-select>
Expand Down Expand Up @@ -80,6 +69,24 @@ import { Message } from '@/utils/tips';
import NewConversationFormModelSelectionLabel from './NewConversationFormModelSelectionLabel.vue';
import NewConversationFormPluginSelectionLabel from './NewConversationFormPluginSelectionLabel.vue';
//////
import { MdPeople } from '@vicons/ionicons4';
import { EventBusyFilled, QueueFilled } from '@vicons/material';
import { getServerStatusApi } from '@/api/status';
import { CommonStatusSchema } from '@/types/schema';
const serverStatus = ref<CommonStatusSchema>({});
const updateData = () => {
getServerStatusApi().then((res) => {
// console.log(res.data);
serverStatus.value = res.data;
});
};
updateData();
///////
const t = i18n.global.t as any;
const userStore = useUserStore();
Expand Down Expand Up @@ -217,29 +224,8 @@ const renderPluginSelectionTag: SelectRenderTag = ({ option, handleClose }) => {
};
function setDefaultValues() {
// const defaultSource = computed(() => {
if (appStore.lastSelectedSource) {
if (availableChatSourceTypes.value.find((source) => source.value === appStore.lastSelectedSource)) {
newConversationInfo.value.source = appStore.lastSelectedSource;
}
} else {
newConversationInfo.value.source =
availableChatSourceTypes.value.length > 0 ? (availableChatSourceTypes.value[0].value as ChatSourceTypes) : null;
}
if (appStore.lastSelectedModel) {
if (
newConversationInfo.value.source === 'openai_web' &&
availableModels.value.find((model) => model.value === appStore.lastSelectedModel)
) {
newConversationInfo.value.model = appStore.lastSelectedModel;
} else if (
newConversationInfo.value.source === 'openai_api' &&
availableModels.value.find((model) => model.value === appStore.lastSelectedModel)
) {
newConversationInfo.value.model = appStore.lastSelectedModel;
}
}
newConversationInfo.value.source = 'openai_web';
newConversationInfo.value.model = 'gpt_3_5';
}
setDefaultValues();
Expand Down Expand Up @@ -268,10 +254,14 @@ watch(
watch(
() => {
const model = newConversationInfo.value.model;
const gpt4Count = serverStatus.value?.gpt4_count_in_3_hours ?? 0;
const source = (model === 'gpt_4' && gpt4Count > 45) ? 'openai_api' : (model === 'gpt_4') ? 'openai_web' : 'openai_web'; // If GPT Usage is high, then use APIs
return {
title: newConversationInfo.value.title,
source: newConversationInfo.value.source,
model: newConversationInfo.value.model,
source: source,
model: model,
openaiWebPlugins: newConversationInfo.value.openaiWebPlugins,
} as NewConversationInfo;
},
Expand All @@ -288,4 +278,5 @@ watch(
newConversationInfo.value.model = null;
}
);
</script>

0 comments on commit 4cc9e97

Please sign in to comment.