llm-config.vue 3.1 KB
Newer Older
DCloud_JSON's avatar
1.0.21  
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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
<template>
	<uni-popup ref="popup" type="top">
		<view class="box">
			<text class="title">请选择llm的model</text>
			<radio-group @change="radioChange" class="radio-group">
				<label class="item" v-for="(model, index) in models" :key="model">
					<radio :value="model" :checked="currentModel === model" class="radio" />
					<view class="item-title">{{model}}</view>
				</label>
			</radio-group>
			<view class="btn-box">
				<view @click="cancel" class="btn cancel">取消</view>
				<view @click="confirm" class="btn confirm">确认</view>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	let confirmCallback = ()=>{}
	export default {
		name: "llm-config",
		data() {
			return {
				models: [
					"gpt-4",
					"gpt-4-0314",
					"gpt-4-32k",
					"gpt-4-32k-0314",
					"gpt-3.5-turbo",
					"gpt-3.5-turbo-0301"
				],
				currentModel:''
			};
		},
		mounted() {
			this.currentModel = uni.getStorageSync('uni-ai-chat-llmModel')
		},
		methods: {
			open(callback){
				confirmCallback = callback
				this.$refs.popup.open('center')
			},
			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()
			},
		}
	}
</script>

<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;
	}
	
	.box {
		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);
	}
	/* #endif */
</style>