Skip to content
Merged
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
12 changes: 8 additions & 4 deletions service/src/chatgpt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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',
Expand Down