enh: auto tag feedback

This commit is contained in:
Timothy J. Baek
2024-10-23 20:18:51 -07:00
parent 73ab84efe6
commit 076f9fd9c0
9 changed files with 132 additions and 52 deletions
@@ -19,7 +19,8 @@
extractSentencesForAudio,
cleanText,
getMessageContentParts,
sanitizeResponseContent
sanitizeResponseContent,
createMessagesList
} from '$lib/utils';
import { WEBUI_BASE_URL } from '$lib/constants';
@@ -42,6 +43,7 @@
import ContentRenderer from './ContentRenderer.svelte';
import { createNewFeedback, getFeedbackById, updateFeedbackById } from '$lib/apis/evaluations';
import { getChatById } from '$lib/apis/chats';
import { generateTags } from '$lib/apis';
interface MessageType {
id: string;
@@ -355,6 +357,24 @@
return;
}
if (!annotation) {
const messages = createMessagesList(history, message.id);
const tags = await generateTags(
localStorage.token,
message?.selectedModelId ?? message.model,
messages,
chatId
).catch((error) => {
console.error(error);
return [];
});
console.log(tags);
if (tags) {
updatedMessage.annotation.tags = tags;
}
}
let feedbackItem = {
type: 'rating',
data: {
@@ -1183,6 +1203,7 @@
bind:show={showRateComment}
on:save={async (e) => {
await feedbackHandler(null, {
tags: e.detail.tags,
comment: e.detail.comment,
reason: e.detail.reason
});