add model selector

This commit is contained in:
AceDataCloud committed 2023-09-30 11:49:25 +08:00
1 parent b19aeaae55
commit b65e3f90f6
3 files changed
+166 -25

No files matched your search

+23 -18
View File
@@ -1,38 +1,43 @@
<template>
<div class="input">
<div class="input-box">
<el-input v-model="value" :rows="2" type="textarea" placeholder="Please input" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElTooltip, ElButton } from 'element-plus';
import { ElInput, ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_INDEX } from '@/router/constants';
export default defineComponent({
name: 'Sidebar',
name: 'InputBox',
components: {
ElInput,
ElButton,
FontAwesomeIcon
},
props: {
modelValue: {
type: String,
required: true
}
},
emits: ['update:modelValue'],
data() {
return {
links: [
{
route: {
name: ROUTE_CHAT_INDEX
},
icon: 'fa-question'
},
{
route: {
name: 'midjourney-index'
},
icon: 'fa-question'
}
]
value: this.modelValue
};
},
watch: {
value(val) {
this.$emit('update:modelValue', val);
},
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
}
}
});
</script>
+114
View File
@@ -0,0 +1,114 @@
<template>
<div class="model-selector">
<el-dropdown v-for="(group, groupIndex) in groups" :key="groupIndex" @command="onCommandChange">
<el-button type="primary">
{{ group.label }}
<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item v-for="(option, optionIndex) in group.options" :key="optionIndex" :command="option.value">
{{ option.label }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElSelect, ElOption, ElDropdown, ElButton, ElDropdownItem } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_INDEX } from '@/router/constants';
export default defineComponent({
name: 'ModelSelector',
components: {
ElSelect,
ElOption,
ElDropdown,
ElButton,
ElDropdownItem,
FontAwesomeIcon
},
props: {
modelValue: {
type: String,
required: true
}
},
emits: ['update:modelValue'],
data() {
return {
value: this.modelValue,
groups: [
{
label: '基础',
value: 'base',
options: [
{
label: 'AI 问答',
value: 'chatgpt'
},
{
label: 'AI 问答 3.5 - 16K',
value: 'chatgpt-16k'
},
{
label: 'AI 问答 3.5 - 联网版',
value: 'chatgpt-browsing'
}
]
},
{
label: 'Plus',
value: 'plus',
options: [
{
label: 'AI 问答 4.0',
value: 'chatgpt4'
},
{
label: 'AI 问答 4.0 - 联网版',
value: 'chatgpt4-browsing'
}
]
}
]
};
},
watch: {
value(val) {
this.$emit('update:modelValue', val);
},
modelValue(val) {
if (val !== this.value) {
this.value = val;
}
}
},
methods: {
onCommandChange(command: string) {
console.log('val', command);
this.value = command;
}
}
});
</script>
<style lang="scss" scoped>
.sidebar {
display: flex;
flex-direction: column;
align-items: flex-end;
.top {
display: flex;
flex-direction: column;
}
.bottom {
display: flex;
flex-direction: column;
}
}
</style>
+29 -7
View File
@@ -1,11 +1,10 @@
<template>
<div class="page">
<div class="left">3</div>
<div class="right">
<div class="main">
<model-selector v-model="model" class="model-selector" />
<introduction />
<div class="input-wrapper">
</div>
<input-box v-model="question" class="input-box" />
</div>
</div>
</template>
@@ -16,31 +15,54 @@ import { ElMain, ElAside, ElButton, ElDrawer } from 'element-plus';
import LeftNavigator from '@/components/common/LeftNavigator.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import Introduction from '@/components/conversation/Introduction.vue';
import InputBox from '@/components/chat/InputBox.vue';
import ModelSelector from '@/components/chat/ModelSelector.vue';
export default defineComponent({
name: 'ChatIndex',
components: {
Introduction
Introduction,
InputBox,
ModelSelector
},
data() {
return {
drawer: false
model: 'chatgpt',
drawer: false,
question: ''
};
}
});
</script>
<style lang="scss">
<style lang="scss" scoped>
.page {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
.left {
display: none;
width: 300px;
height: 100%;
}
.main {
flex: 1;
overflow: hidden;
position: relative;
.input-box {
display: block;
position: absolute;
bottom: 10px;
right: 10px;
left: 10px;
}
.model-selector {
position: absolute;
top: 30px;
left: 50%;
transform: translate(-50%, 0);
z-index: 100;
}
}
}
</style>