ChatGLM接入成功
This commit is contained in:
@@ -4,14 +4,17 @@
|
||||
<el-form-item label="语言模型">
|
||||
<el-row class="flexWrap">
|
||||
<ai-model v-for="m in models" :model="m" small :class="{active:settings.model.id==m.id}"
|
||||
@click="settings.model=new m()"/>
|
||||
@click="initModel(m)"/>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-form-item label="流式输出">
|
||||
<el-switch v-model="settings.stream" :active-value="true" :inactive-value="false"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="API KEY">
|
||||
<el-input v-model="settings.model.apiKey" clearable @change="v=>settings.model.setApiKey(v),getModelAccount()"/>
|
||||
<el-row class="w100">
|
||||
<el-input v-model="settings.model.apiKey" clearable class="fill mar-r8"/>
|
||||
<el-button type="text" @click="getModelAccount">应用</el-button>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-row v-loading="loadingAccount" element-loading-background="#272A37">
|
||||
<el-form-item label="账号用户" class="fill">{{ account.username }}</el-form-item>
|
||||
@@ -46,6 +49,7 @@ export default {
|
||||
immediate: true,
|
||||
handler(v) {
|
||||
this.settings = v
|
||||
this.getModelAccount()
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -54,15 +58,23 @@ export default {
|
||||
account: v => v.settings.account || {usage: 0, total: 0}
|
||||
},
|
||||
methods: {
|
||||
initModel(model) {
|
||||
const ins = new model()
|
||||
const timer = setInterval(() => {
|
||||
if (ins.apiKey) {
|
||||
clearInterval(timer)
|
||||
this.settings.model = ins
|
||||
this.getModelAccount()
|
||||
}
|
||||
}, 500)
|
||||
},
|
||||
getModelAccount() {
|
||||
const ai = this.settings.model
|
||||
if (ai.getAccount) {
|
||||
if (ai.apiKey) {
|
||||
this.loadingAccount = true
|
||||
ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false)
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user