feat(prompt): enhance context and intent classification in templates
- Updated context template to include runtime metadata such as current time and week, improving contextual awareness in user queries. - Enhanced rewrite template with critical instructions for intent classification, ensuring that rewritten questions preserve essential entities and keywords. - Refined intent classification logic to prioritize user intents more effectively, improving the accuracy of responses based on user queries. - Added examples to clarify expected input and output formats for intent classification, enhancing usability for developers.
This commit is contained in:
@@ -1825,6 +1825,14 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
triggerSend(text: string) {
|
||||
if (!text.trim()) return;
|
||||
query.value = text;
|
||||
nextTick(() => createSession(text));
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div class="answers-input" @drop="onDrop" @dragover="onDragOver">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
<script setup lang="ts">
|
||||
import { marked } from "marked";
|
||||
import type { Tokens } from 'marked';
|
||||
|
||||
import hljs from "highlight.js";
|
||||
import "highlight.js/styles/github.css";
|
||||
import mermaid from "mermaid";
|
||||
@@ -172,13 +172,11 @@ const checkImage = (url) => {
|
||||
img.src = url;
|
||||
});
|
||||
};
|
||||
renderer.image = function ({href, title, text}: Tokens.Image) {
|
||||
// 安全地处理图片链接
|
||||
renderer.image = function (href: string, title: string | null, text: string) {
|
||||
if (!isValidImageURL(href)) {
|
||||
return `<p>${t('error.invalidImageLink')}</p>`;
|
||||
}
|
||||
|
||||
// 使用安全的图片创建函数
|
||||
|
||||
const safeImage = createSafeImage(href, text || '', title || '');
|
||||
return `<figure>
|
||||
${safeImage}
|
||||
@@ -187,7 +185,7 @@ renderer.image = function ({href, title, text}: Tokens.Image) {
|
||||
};
|
||||
|
||||
// 自定义代码块渲染器,只显示语言标签
|
||||
renderer.code = function ({text, lang}: Tokens.Code) {
|
||||
renderer.code = function (text: string, lang?: string) {
|
||||
// Mermaid 图表处理
|
||||
if (lang === 'mermaid') {
|
||||
// 生成唯一ID
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import hljs from 'highlight.js';
|
||||
import 'highlight.js/styles/github.css';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {Tokens} from 'marked';
|
||||
|
||||
|
||||
const VueOfficePptx = defineAsyncComponent(() => import('@vue-office/pptx'));
|
||||
|
||||
@@ -197,7 +197,7 @@ async function renderMarkdown(blob: Blob) {
|
||||
gfm: true,
|
||||
});
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.code = function ({lang, text}: Tokens.Code) {
|
||||
renderer.code = function (text: string, lang?: string) {
|
||||
let highlighted = '';
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
try { highlighted = hljs.highlight(text, { language: lang }).value; }
|
||||
|
||||
Reference in New Issue
Block a user