before refactor
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div v-for="(msg, index) in messages" :key="index" :class="['chat-message', msg.sender]">
|
||||
<div class="message-bubble">
|
||||
<div v-if="msg.sender === 'bot'">
|
||||
<MdPreview class="editor" theme="light" previewTheme="github" v-model="msg.text" language="en-US" :key="index" />
|
||||
<MarkdownViewer class="editor" theme="light" previewTheme="github" v-model="msg.text" :key="index" />
|
||||
</div>
|
||||
<p v-else>{{ msg.text }}</p>
|
||||
</div>
|
||||
@@ -19,15 +19,11 @@
|
||||
<!-- <p-button icon="pi pi-cog" @click="showSettings = !showSettings" class="p-button-normal" /> -->
|
||||
</p-inputGroup>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { marked } from 'marked';
|
||||
import { MdPreview } from 'md-editor-v3';
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
import Button from 'primevue/button';
|
||||
import Card from 'primevue/card';
|
||||
import Checkbox from 'primevue/checkbox';
|
||||
@@ -35,6 +31,7 @@ import InputGroup from 'primevue/inputgroup';
|
||||
import InputGroupAddon from 'primevue/inputgroupaddon';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import ScrollPanel from 'primevue/scrollpanel';
|
||||
import MarkdownViewer from './MarkdownViewer.vue';
|
||||
|
||||
import { UserPrefStore } from '../stores/UserPrefStore.js';
|
||||
const userPrefStore = UserPrefStore();
|
||||
@@ -49,11 +46,11 @@ export default {
|
||||
'p-card': Card,
|
||||
'p-inputGroup': InputGroup,
|
||||
'p-inputGroupAddon': InputGroupAddon,
|
||||
MdPreview
|
||||
MarkdownViewer
|
||||
},
|
||||
props: {
|
||||
scenarioExecutionId: {
|
||||
type: String,
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
@@ -73,8 +70,7 @@ export default {
|
||||
previousMessagesLength: 0
|
||||
};
|
||||
},
|
||||
//
|
||||
|
||||
//
|
||||
|
||||
mounted() {
|
||||
console.log('userPrefStore', userPrefStore);
|
||||
@@ -83,9 +79,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
async updateConversationId() {
|
||||
this.conversationId = this.scenarioExecutionId
|
||||
? `${userPrefStore.user.id}-${this.scenarioExecutionId}`
|
||||
: `${userPrefStore.user.id}-${userPrefStore.user.selectedProject.internal_name}`;
|
||||
this.conversationId = this.scenarioExecutionId ? `${userPrefStore.user.id}-${this.scenarioExecutionId}` : `${userPrefStore.user.id}-${userPrefStore.user.selectedProject.internal_name}`;
|
||||
await this.fetchChatHistory();
|
||||
if (this.scenarioExecutionId && this.messages.length === 0) {
|
||||
this.loadContext();
|
||||
@@ -98,7 +92,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL.replace("/hermione", "")}/chatservice/get-history?conversationId=${this.conversationId}&lastN=100`, {
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL.replace('/hermione', '')}/chatservice/get-history?conversationId=${this.conversationId}&lastN=100`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json', authorization: 'Bearer ' + this.$auth.token() }
|
||||
});
|
||||
@@ -143,7 +137,7 @@ export default {
|
||||
|
||||
try {
|
||||
this.waitingData = true;
|
||||
const response = await fetch(import.meta.env.VITE_BACKEND_URL.replace("/hermione", "")+'/chatservice/chat', {
|
||||
const response = await fetch(import.meta.env.VITE_BACKEND_URL.replace('/hermione', '') + '/chatservice/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', authorization: this.authorization },
|
||||
body: JSON.stringify(payload)
|
||||
@@ -205,7 +199,7 @@ export default {
|
||||
|
||||
async clearHistory() {
|
||||
try {
|
||||
const response = await fetch( `${import.meta.env.VITE_BACKEND_URL.replace("/hermione", "")}/chatservice/delete-history?conversationId=${this.conversationId}`, {
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL.replace('/hermione', '')}/chatservice/delete-history?conversationId=${this.conversationId}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json', authorization: this.authorization }
|
||||
});
|
||||
@@ -221,7 +215,7 @@ export default {
|
||||
|
||||
async loadContext() {
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL.replace("/hermione", "")}/chatservice/load-context-to-conversation?conversationId=${this.conversationId}&scenarioExecutionId=${this.scenarioExecutionId}`, {
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL.replace('/hermione', '')}/chatservice/load-context-to-conversation?conversationId=${this.conversationId}&scenarioExecutionId=${this.scenarioExecutionId}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json', authorization: this.authorization }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user