mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 13:34:08 +08:00
简化ai设置中添加配置的操作
This commit is contained in:
parent
ffbae3f33f
commit
3fb17dcd99
@ -2,19 +2,16 @@
|
|||||||
<q-card style="width: 800px" class="q-pa-sm">
|
<q-card style="width: 800px" class="q-pa-sm">
|
||||||
<div class="text-h5 q-my-md q-px-sm">API配置</div>
|
<div class="text-h5 q-my-md q-px-sm">API配置</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex q-mb-md q-px-sm" style="height: 26px">
|
<div class="q-pa-sm row q-gutter-sm">
|
||||||
<ButtonGroup
|
<q-btn
|
||||||
v-model="apiToAdd"
|
v-for="option in aiOptions"
|
||||||
class="col"
|
:key="option.value"
|
||||||
:options="aiOptions"
|
icon="add_link"
|
||||||
height="26px"
|
dense
|
||||||
/>
|
|
||||||
<q-icon
|
|
||||||
name="add_box"
|
|
||||||
@click="addModel"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="26px"
|
:label="option.label"
|
||||||
class="cursor-pointer q-ml-sm"
|
@click="addModel(option.value)"
|
||||||
|
class="col"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<q-scroll-area
|
<q-scroll-area
|
||||||
@ -76,11 +73,9 @@
|
|||||||
:placeholder="
|
:placeholder="
|
||||||
aiConfig.apiType === 'openai'
|
aiConfig.apiType === 'openai'
|
||||||
? '例:https://api.openai.com'
|
? '例:https://api.openai.com'
|
||||||
: aiConfig.apiType === 'ollama'
|
: '例:http://localhost:11434'
|
||||||
? '例:http://localhost:11434'
|
|
||||||
: '无需配置'
|
|
||||||
"
|
"
|
||||||
:disable="aiConfig.apiType === 'utools'"
|
v-show="aiConfig.apiType !== 'utools'"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-badge
|
<q-badge
|
||||||
@ -182,31 +177,31 @@
|
|||||||
<script>
|
<script>
|
||||||
import { defineComponent, ref } from "vue";
|
import { defineComponent, ref } from "vue";
|
||||||
import { dbManager } from "js/utools.js";
|
import { dbManager } from "js/utools.js";
|
||||||
import ButtonGroup from "components/composer/common/ButtonGroup.vue";
|
|
||||||
import draggable from "vuedraggable";
|
import draggable from "vuedraggable";
|
||||||
import { getUniqueId } from "js/common/uuid.js";
|
import { getUniqueId } from "js/common/uuid.js";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "AIConfig",
|
name: "AIConfig",
|
||||||
components: {
|
components: {
|
||||||
ButtonGroup,
|
|
||||||
draggable,
|
draggable,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
const initAiOptions = utools.allAiModels
|
||||||
|
? [{ label: "uTools内置AI", value: "utools" }]
|
||||||
|
: [];
|
||||||
|
|
||||||
const aiOptions = ref([
|
const aiOptions = ref([
|
||||||
{ label: "OPENAI接口", value: "openai" },
|
...initAiOptions,
|
||||||
|
{ label: "OPENAI接口(需Key)", value: "openai" },
|
||||||
{ label: "OLLAMA接口", value: "ollama" },
|
{ label: "OLLAMA接口", value: "ollama" },
|
||||||
]);
|
]);
|
||||||
if (utools.allAiModels) {
|
|
||||||
aiOptions.value.push({ label: "uTools内置", value: "utools" });
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
aiOptions,
|
aiOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
apiToAdd: "openai",
|
|
||||||
aiConfigs: [],
|
aiConfigs: [],
|
||||||
models: [],
|
models: [],
|
||||||
tokenInputTypes: [],
|
tokenInputTypes: [],
|
||||||
@ -248,17 +243,17 @@ export default defineComponent({
|
|||||||
deleteModel(index) {
|
deleteModel(index) {
|
||||||
this.aiConfigs.splice(index, 1);
|
this.aiConfigs.splice(index, 1);
|
||||||
},
|
},
|
||||||
addModel() {
|
addModel(apiType) {
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
id: getUniqueId(),
|
id: getUniqueId(),
|
||||||
apiType: this.apiToAdd,
|
apiType: apiType,
|
||||||
apiUrl: "",
|
apiUrl: "",
|
||||||
apiToken: "",
|
apiToken: "",
|
||||||
model: "",
|
model: "",
|
||||||
name: "",
|
name: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.apiToAdd === "utools") {
|
if (apiType === "utools") {
|
||||||
defaultConfig.apiUrl = "";
|
defaultConfig.apiUrl = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user