From 9412c88e660d82a25958d2ac07c582774ee4091d Mon Sep 17 00:00:00 2001 From: Bob Du Date: Wed, 18 Jun 2025 17:17:50 +0800 Subject: [PATCH 1/4] feat: enhance search query with advanced depth and refine result content parsing (#629) Signed-off-by: Bob Du --- service/src/chatgpt/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index e63dca34..e1369f56 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -137,9 +137,13 @@ async function chatReplyProcess(options: RequestOptions) { const response = await tvly.search( searchQuery, { + // https://docs.tavily.com/documentation/best-practices/best-practices-search#search-depth%3Dadvanced-ideal-for-higher-relevance-in-search-results + searchDepth: 'advanced', + chunksPerSource: 3, includeRawContent: true, // 0 <= x <= 20 https://docs.tavily.com/documentation/api-reference/endpoint/search#body-max-results - maxResults: 20, + // https://docs.tavily.com/documentation/best-practices/best-practices-search#max-results-limiting-the-number-of-results + maxResults: 10, // Max 120s, default to 60 https://github.com/tavily-ai/tavily-js/blob/de69e479c5d3f6c5d443465fa2c29407c0d3515d/src/search.ts#L118 timeout: 120, }, @@ -156,9 +160,9 @@ async function chatReplyProcess(options: RequestOptions) { }) let searchResultContent = JSON.stringify(searchResults) - // remove base64 image content - const base64Pattern = /data:image\/[a-zA-Z0-9+.-]+;base64,[A-Za-z0-9+/=]+/g - searchResultContent = searchResultContent.replace(base64Pattern, '') + // remove image url + const base64Pattern = /!\[([^\]]*)\]\([^)]*\)/g + searchResultContent = searchResultContent.replace(base64Pattern, '$1') messages.push({ role: 'user', From 4880b1f79f9ea0d426c2312edfceb128146eb839 Mon Sep 17 00:00:00 2001 From: Bob Du Date: Wed, 18 Jun 2025 18:26:12 +0800 Subject: [PATCH 2/4] refactor: prompt store table to use raw data and improve UI (#630) * refactor: prompt store table to use raw data and improve UI Signed-off-by: Bob Du * refactor: prompt store table improve UI in mobile Signed-off-by: Bob Du --------- Signed-off-by: Bob Du --- components.d.ts | 1 + src/components/common/PromptStore/index.vue | 41 ++++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/components.d.ts b/components.d.ts index 7c0b634f..34310d1a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -18,6 +18,7 @@ declare module 'vue' { NDatePicker: typeof import('naive-ui')['NDatePicker'] NDivider: typeof import('naive-ui')['NDivider'] NDropdown: typeof import('naive-ui')['NDropdown'] + NEllipsis: typeof import('naive-ui')['NEllipsis'] NIcon: typeof import('naive-ui')['NIcon'] NInput: typeof import('naive-ui')['NInput'] NInputNumber: typeof import('naive-ui')['NInputNumber'] diff --git a/src/components/common/PromptStore/index.vue b/src/components/common/PromptStore/index.vue index ce4bdbee..97d7e6a9 100644 --- a/src/components/common/PromptStore/index.vue +++ b/src/components/common/PromptStore/index.vue @@ -11,9 +11,6 @@ import PromptRecommend from '../../../assets/recommend.json' interface DataProps { _id?: string - renderKey: string - renderValue: string - renderType: string title: string value: string type: 'built-in' | 'user-defined' @@ -277,12 +274,8 @@ async function downloadPromptTemplate() { // 移动端自适应相关 function renderTemplate() { - const [keyLimit, valueLimit] = isMobile.value ? [10, 30] : [15, 50] return promptList.value.map((item: UserPrompt) => { return { - renderKey: item.title.length <= keyLimit ? item.title : `${item.title.substring(0, keyLimit)}...`, - renderValue: item.value.length <= valueLimit ? item.value : `${item.value.substring(0, valueLimit)}...`, - renderType: item.type === 'built-in' ? t('store.builtIn') : t('store.userDefined'), title: item.title, value: item.value, _id: item._id, @@ -304,15 +297,27 @@ function createColumns(): DataTableColumns { return [ { title: 'type', - key: 'renderType', + key: 'type', + width: 100, + align: 'center', + render: (row: DataProps) => row.type === 'built-in' ? t('store.builtIn') : t('store.userDefined'), }, { title: t('store.title'), - key: 'renderKey', + key: 'title', + width: 200, }, { title: t('store.description'), - key: 'renderValue', + key: 'value', + ellipsis: { + lineClamp: 6, + tooltip: { + contentClass: 'whitespace-pre-line text-xs max-h-100 max-w-200', + scrollable: true, + }, + }, + className: 'whitespace-pre-line', }, { title: t('common.action'), @@ -371,7 +376,7 @@ const dataSource = computed(() => { const value = searchValue.value if (value && value !== '') { return data.filter((item: DataProps) => { - return item.renderKey.includes(value) || item.renderValue.includes(value) + return item.title.includes(value) || item.value.includes(value) }) } return data @@ -445,9 +450,19 @@ async function handleGetUserPromptList() { /> - + + + >