Skip to content

feat: add include raw content option for search settings #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service/src/chatgpt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async function chatReplyProcess(options: RequestOptions) {
// 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,
includeRawContent: searchConfig.options?.includeRawContent ?? false,
// 0 <= x <= 20 https://docs.tavily.com/documentation/api-reference/endpoint/search#body-max-results
// https://docs.tavily.com/documentation/best-practices/best-practices-search#max-results-limiting-the-number-of-results
maxResults: searchConfig.options?.maxResults || 10,
Expand Down
2 changes: 1 addition & 1 deletion service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ router.post('/search-test', rootAuth, async (req, res) => {
{
searchDepth: 'advanced',
chunksPerSource: 3,
includeRawContent: true,
includeRawContent: search.options?.includeRawContent ?? false,
maxResults,
timeout: 120,
},
Expand Down
2 changes: 1 addition & 1 deletion service/src/storage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function getOriginConfig() {
if (!config.searchConfig) {
config.searchConfig = new SearchConfig()
config.searchConfig.enabled = false
config.searchConfig.options = { apiKey: '', maxResults: 10 }
config.searchConfig.options = { apiKey: '', maxResults: 10, includeRawContent: false }
}

if (!isNotEmptyString(config.siteConfig.chatModels))
Expand Down
1 change: 1 addition & 0 deletions service/src/storage/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export enum SearchServiceProvider {
export class SearchServiceOptions {
public apiKey: string
public maxResults?: number
public includeRawContent?: boolean
}

export class Config {
Expand Down
11 changes: 11 additions & 0 deletions src/components/common/Setting/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async function fetchConfig() {
data.searchConfig.options = { apiKey: '' }
if (!data.searchConfig.options.maxResults)
data.searchConfig.options.maxResults = 10
if (data.searchConfig.options.includeRawContent === undefined)
data.searchConfig.options.includeRawContent = false
config.value = data.searchConfig
}
finally {
Expand Down Expand Up @@ -111,6 +113,15 @@ onMounted(() => {
/>
</div>
</div>
<div v-if="config && config.enabled" class="flex items-center space-x-4">
<span class="shrink-0 w-[100px]">{{ t('setting.searchIncludeRawContent') }}</span>
<div class="flex-1">
<NSwitch
:round="false" :value="config && config.options.includeRawContent"
@update:value="(val) => { if (config && config.options) config.options.includeRawContent = val }"
/>
</div>
</div>
<div v-if="config && config.enabled" class="flex items-center space-x-4">
<span class="shrink-0 w-[100px]">{{ t('setting.searchTest') }}</span>
<div class="flex-1">
Expand Down
1 change: 1 addition & 0 deletions src/components/common/Setting/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export type SearchServiceProvider = 'tavily' | ''
export interface SearchServiceOptions {
apiKey: string
maxResults?: number
includeRawContent?: boolean
}

export class SearchConfig {
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"searchProvider": "Search Provider",
"searchApiKey": "Search API Key",
"searchMaxResults": "Max Search Results",
"searchIncludeRawContent": "Include Raw Content",
"systemMessageWithSearchResult": "System message for conversations with search results",
"systemMessageGetSearchQuery": "System message for getting search query",
"systemMessageWithSearchResultPlaceholder": "System message template when with search results. Use {'{current_time}'} as placeholder for current time.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"searchProvider": "검색 공급자",
"searchApiKey": "검색 API 키",
"searchMaxResults": "최대 검색 결과 수",
"searchIncludeRawContent": "원시 콘텐츠 포함",
"systemMessageWithSearchResult": "검색 결과가 포함된 대화 시스템 프롬프트",
"systemMessageGetSearchQuery": "검색 쿼리어를 가져오는 시스템 프롬프트",
"systemMessageWithSearchResultPlaceholder": "검색 결과가 포함된 시스템 메시지 템플릿, {'{current_time}'}를 현재 시간의 플레이스홀더로 사용",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"searchProvider": "搜索提供商",
"searchApiKey": "搜索 API 密钥",
"searchMaxResults": "最大搜索结果数",
"searchIncludeRawContent": "包含原始内容",
"systemMessageWithSearchResult": "包含搜索结果时的对话系统提示词",
"systemMessageGetSearchQuery": "用于获取搜索查询词的系统提示词",
"systemMessageWithSearchResultPlaceholder": "携带搜索结果时的系统消息模板, 使用 {'{current_time}'} 作为当前时间的占位符",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"searchProvider": "搜尋提供商",
"searchApiKey": "搜尋 API 密鑰",
"searchMaxResults": "最大搜尋結果數",
"searchIncludeRawContent": "包含原始內容",
"systemMessageWithSearchResult": "包含搜尋結果時的對話系統提示詞",
"systemMessageGetSearchQuery": "用於獲取搜尋查詢詞的系統提示詞",
"systemMessageWithSearchResultPlaceholder": "攜帶搜尋結果時的系統訊息模板, 使用 {'{current_time}'} 作為當前時間的佔位符",
Expand Down