mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 22:13:59 +00:00
144 lines
6.1 KiB
Vue
144 lines
6.1 KiB
Vue
<template>
|
|
<div class="row">
|
|
<div class="col">
|
|
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
|
<div class="row" v-show="!$store.getters.isLoading(section)">
|
|
<div class="col">
|
|
<div class="row m-b-20">
|
|
<div class="col">
|
|
<h6 class="all-caps m-b-5 bold no-margin">
|
|
{{ data ? "Update" : "Create" }}
|
|
<span v-if="!data">
|
|
{{ selectedModel === "chatgpt" ? "ChatGPT" : "Claude" }}
|
|
</span>
|
|
Prompt
|
|
</h6>
|
|
</div>
|
|
</div>
|
|
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
|
<div class="col">
|
|
<small class="bold fs-10 text-danger">{{error}}</small>
|
|
</div>
|
|
</div>
|
|
<div class="row m-b-10" v-if="!data">
|
|
<div class="col">
|
|
<label>AI Model</label>
|
|
<div>
|
|
<div class="form-check form-check-inline">
|
|
<input
|
|
class="form-check-input"
|
|
type="radio"
|
|
id="chatgptRadio"
|
|
value="chatgpt"
|
|
v-model="selectedModel"
|
|
/>
|
|
<label class="form-check-label" for="chatgptRadio">
|
|
ChatGPT
|
|
</label>
|
|
</div>
|
|
<div class="form-check form-check-inline">
|
|
<input
|
|
class="form-check-input"
|
|
type="radio"
|
|
id="claudeRadio"
|
|
value="claude"
|
|
v-model="selectedModel"
|
|
/>
|
|
<label class="form-check-label" for="claudeRadio">
|
|
Claude
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row m-b-10">
|
|
<div class="col">
|
|
<validation-wrapper-component :validator="$v.parameters.key">
|
|
<label>Title</label>
|
|
<input type="text" class="form-control" v-model="parameters.key" :disabled="this.data">
|
|
</validation-wrapper-component>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<validation-wrapper-component :validator="$v.parameters.value">
|
|
<label>Prompt</label>
|
|
<textarea class="form-control h-75" v-model="parameters.value" rows="20"></textarea>
|
|
</validation-wrapper-component>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col p-r-5">
|
|
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :data-dismiss="closable ? 'modal' : ''" @click="$emit('close')">Cancel</div>
|
|
</div>
|
|
<div class="col p-l-5">
|
|
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">{{this.data?"Update":"Create"}}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
|
import { required } from "vuelidate/lib/validators";
|
|
export default {
|
|
props : {
|
|
closable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
},
|
|
data(){
|
|
return {
|
|
parameters: {
|
|
key: '',
|
|
value: '',
|
|
},
|
|
selectedModel: "claude", // default
|
|
}
|
|
},
|
|
validations: {
|
|
parameters: {
|
|
key: {
|
|
required
|
|
},
|
|
value: {
|
|
required
|
|
},
|
|
}
|
|
},
|
|
computed:{},
|
|
created(){},
|
|
methods: {
|
|
submitForm() {
|
|
let routeUrl;
|
|
let method;
|
|
|
|
if(this.data) {
|
|
if (this.data.key.startsWith("CHATGPT_PROMPT_")) {
|
|
routeUrl = this.route("api.kvp.chatgpt.prompt.update", this.data.id);
|
|
method = "put";
|
|
} else if (this.data.key.startsWith("CLAUDE_PROMPT_")) {
|
|
routeUrl = this.route("api.kvp.claude.prompt.update", this.data.id);
|
|
method = "put";
|
|
}
|
|
}
|
|
else{
|
|
if (this.selectedModel === "chatgpt") {
|
|
routeUrl = this.route("api.kvp.chatgpt.prompt.create");
|
|
method = "post";
|
|
} else if (this.selectedModel === "claude") {
|
|
routeUrl = this.route("api.kvp.claude.prompt.create");
|
|
method = "post";
|
|
}
|
|
}
|
|
this.submit(routeUrl, method, this.section, true, false);
|
|
},
|
|
},
|
|
mixins: [ModalFormHandler],
|
|
}
|
|
</script>
|