File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -137,9 +137,13 @@ async function chatReplyProcess(options: RequestOptions) {
137137 const response = await tvly . search (
138138 searchQuery ,
139139 {
140+ // https://docs.tavily.com/documentation/best-practices/best-practices-search#search-depth%3Dadvanced-ideal-for-higher-relevance-in-search-results
141+ searchDepth : 'advanced' ,
142+ chunksPerSource : 3 ,
140143 includeRawContent : true ,
141144 // 0 <= x <= 20 https://docs.tavily.com/documentation/api-reference/endpoint/search#body-max-results
142- maxResults : 20 ,
145+ // https://docs.tavily.com/documentation/best-practices/best-practices-search#max-results-limiting-the-number-of-results
146+ maxResults : 10 ,
143147 // Max 120s, default to 60 https://github.com/tavily-ai/tavily-js/blob/de69e479c5d3f6c5d443465fa2c29407c0d3515d/src/search.ts#L118
144148 timeout : 120 ,
145149 } ,
@@ -156,9 +160,9 @@ async function chatReplyProcess(options: RequestOptions) {
156160 } )
157161
158162 let searchResultContent = JSON . stringify ( searchResults )
159- // remove base64 image content
160- const base64Pattern = / d a t a : i m a g e \/ [ a - z A - Z 0 - 9 + . - ] + ; b a s e 6 4 , [ A - Z a - z 0 - 9 + / = ] + / g
161- searchResultContent = searchResultContent . replace ( base64Pattern , '' )
163+ // remove image url
164+ const base64Pattern = / ! \[ ( [ ^ \] ] * ) \] \( [ ^ ) ] * \) / g
165+ searchResultContent = searchResultContent . replace ( base64Pattern , '$1 ' )
162166
163167 messages . push ( {
164168 role : 'user' ,
You can’t perform that action at this time.
0 commit comments