chatGPT部分完成
This commit is contained in:
@@ -17,7 +17,7 @@ export default {
|
||||
components: {Settings, Chat},
|
||||
data() {
|
||||
return {
|
||||
showSettings: false,
|
||||
showSettings: true,
|
||||
setting: {
|
||||
model: new ChatGPT(),
|
||||
stream: true
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
<el-form-item label="API KEY">
|
||||
<el-input v-model="settings.model.apiKey" clearable @change="v=>settings.model.setApiKey(v),getModelAccount()"/>
|
||||
</el-form-item>
|
||||
<el-button type="text" @click="getModelAccount">刷新账号信息</el-button>
|
||||
<el-row>
|
||||
<el-form-item label="账号用户" class="fill color-999">{{ account.username }}</el-form-item>
|
||||
<el-form-item label="账户余额" class="fill color-999">{{ [account.usage, account.total].join(" / ") }}</el-form-item>
|
||||
<el-row v-loading="loadingAccount" element-loading-background="#272A37">
|
||||
<el-form-item label="账号用户" class="fill">{{ account.username }}</el-form-item>
|
||||
<el-form-item label="账户余额" class="fill">{{ [account.usage, account.total].join(" / ") }}</el-form-item>
|
||||
<el-button type="text" @click="getModelAccount">刷新</el-button>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</section>
|
||||
@@ -26,7 +26,6 @@
|
||||
import AiModel from "../ui/AiModel";
|
||||
import AiSelect from "../ui/AiSelect";
|
||||
import * as models from "../utils/models";
|
||||
import {scopy} from "../utils/tools";
|
||||
|
||||
|
||||
export default {
|
||||
@@ -38,14 +37,15 @@ export default {
|
||||
emits: ["update:modelValue"],
|
||||
data() {
|
||||
return {
|
||||
settings: {}
|
||||
settings: {},
|
||||
loadingAccount: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
modelValue: {
|
||||
immediate: true,
|
||||
handler(v) {
|
||||
this.settings = scopy(v)
|
||||
this.settings = v
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -55,8 +55,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getModelAccount() {
|
||||
console.log(this.settings.model)
|
||||
this.settings.model.getAccount?.().then(v => this.settings.account = v)
|
||||
const ai = this.settings.model
|
||||
if (ai.getAccount) {
|
||||
this.loadingAccount = true
|
||||
ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false)
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -70,6 +73,10 @@ export default {
|
||||
|
||||
:deep(.el-form) {
|
||||
.el-form-item__label {
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.el-form-item__content {
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export class ChatGPT extends BaseModel {
|
||||
if (endDate) {
|
||||
const startDate = new Date(endDate - 90 * 24 * 60 * 60);
|
||||
const formattedDate = time => dayjs(time).format("YYYY-MM-DD")
|
||||
return axios.get(`${ChatGPT.base}/v1/dashboard/billing/usage?start_date=${formattedDate(startDate * 1000)}&end_date=${formattedDate(endDate * 1000)}`,
|
||||
return await axios.get(`${ChatGPT.base}/v1/dashboard/billing/usage?start_date=${formattedDate(startDate * 1000)}&end_date=${formattedDate(endDate * 1000)}`,
|
||||
{headers}).then(res => res.json()).then(res => {
|
||||
usages.total_usage = res.total_usage
|
||||
const names = usages.account_name.split(" ")
|
||||
|
||||
Reference in New Issue
Block a user