llm-config.vue 3.4 KB
Newer Older
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
1
<template>
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
2 3 4 5
	<uni-popup ref="popup" type="top">
		<view class="box">
			<text class="title">请选择llm的model</text>
			<radio-group @change="radioChange" class="radio-group">
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
6 7 8
				<label class="item" v-for="(item, index) in models" :key="item.value">
					<radio :value="item.value" :checked="currentModel === item.value" class="radio" />
					<view class="item-title">{{item.text}}</view>
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
9 10 11 12 13 14 15
				</label>
			</radio-group>
			<view class="btn-box">
				<view @click="cancel" class="btn cancel">取消</view>
				<view @click="confirm" class="btn confirm">确认</view>
			</view>
		</view>
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
16 17 18
	</uni-popup>
</template>

DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
19
<script>
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
20 21 22 23 24
	let confirmCallback = ()=>{}
	export default {
		name: "llm-config",
		data() {
			return {
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
25
				models: [
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
					{
						text:"gpt-4",
						value:"gpt-4"
					},
					{
						text:"gpt-4-0314",
						value:"gpt-4-0314"
					},
					{
						text:"gpt-4-32k",
						value:"gpt-4-32k"
					},
					{
						text:"gpt-4-32k-0314",
						value:"gpt-4-32k-0314"
					},
					{
						text:"gpt-3.5-turbo",
						value:"gpt-3.5-turbo"
					},
					{
						text:"gpt-3.5-turbo-0301",
						value:"gpt-3.5-turbo-0301"
					},
					{
						text:"都不选",
						value:""
					}
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
54 55
				],
				currentModel:''
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
56
			};
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
57 58 59
		},
		mounted() {
			this.currentModel = uni.getStorageSync('uni-ai-chat-llmModel')
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
60
		},
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
61 62 63 64
		methods: {
			open(callback){
				confirmCallback = callback
				this.$refs.popup.open('center')
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
65
			},
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
66 67 68 69 70 71 72 73 74 75 76
			radioChange(event) {
				console.log('event',event.detail.value)
				this.currentModel = event.detail.value
			},
			cancel(){
				this.$refs.popup.close()
			},
			confirm(){
				// console.log(this.models[this.current]);
				confirmCallback(this.currentModel)
				this.$refs.popup.close()
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
77 78 79 80 81
			},
		}
	}
</script>

DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
<style>
	/* #ifndef APP-NVUE */
	.box,
	/* #ifdef H5 */
	.box *,
	/* #endif */
	radio-group,
	label
	{
		display: flex;
		box-sizing: border-box;
	}
	/* #endif */
	.box,.title,.btn-box {
		width: 250px;
	}
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
98 99
	
	.box {
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
		background-color: #fff;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		padding-bottom: 0;
		border-radius: 5px;
	}
	.title {
		font-size: 16px;
		padding: 10px 0;
		padding-bottom: 5px;
		font-weight: 400;
		flex: 1;
		text-align: center;
		/* #ifndef APP-NVUE */
		display: inline-block;
		/* #endif */
	}
	.radio-group {
		flex-direction: column;
		padding: 0 15px;
	}
	.radio {
		transform: scale(0.7);
	}
	.item {
		flex-direction: row;
		margin-bottom: 5px;
		position: relative;
	}
	.item-title {
		font-size: 14px;
		color: #555;
	}
	.btn-box{
		/* #ifdef APP-NVUE */
		border-top:solid 1px #ccc;
		/* #endif */
		height: 48px;
		position: relative;
	}
	/* #ifndef APP-NVUE */
	.btn-box:after {
	    content: " ";
	    position: absolute;
	    left: 0;
	    top: 0;
	    right: 0;
	    height: 1px;
	    border-top: 1px solid #d5d5d6;
	    color: #d5d5d6;
	    transform-origin: 0 0;
	    transform: scaleY(.5);
	}
	/* #endif */
	
	.btn{
		justify-content: center;
		align-items: center;
		width: 150px;
		/* #ifdef H5 */
		cursor: pointer;
		/* #endif */
	}
	
	.confirm {
		color: #007aff;
		position: relative;
		/* #ifdef APP-NVUE */
		border-left:solid 1px #ccc;
		/* #endif */
	}
	
	/* #ifndef APP-NVUE */
	.confirm::before {
	    content: "";
	    position: absolute;
	    left: 0;
	    top: 0;
	    right: 0;
		background-color: #d5d5d6;
	    height: 48px;
		width: 1px;
	    /* border-top: 1px solid #d5d5d6; */
	    /* color: #d5d5d6; */
	    /* transform-origin: 0 0; */
	    transform: scaleX(.5);
	}
DCloud_JSON's avatar
1.0.23  
DCloud_JSON 已提交
188
	/* #endif */
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
189
</style>