nomagick commited on
Commit
cc6d2f3
·
unverified ·
1 Parent(s): 234f61d

fix: search params

Browse files
backend/functions/src/cloud-functions/searcher.ts CHANGED
@@ -82,7 +82,7 @@ export class SearcherHost extends RPCHost {
82
  res: Response,
83
  },
84
  auth: JinaEmbeddingsAuthDTO,
85
- @Param('count', { default: 5, validate: (v) => v >= 3 && v <= 10 })
86
  count: number,
87
  crawlerOptions: CrawlerOptions,
88
  braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
@@ -144,7 +144,7 @@ export class SearcherHost extends RPCHost {
144
  const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
145
  const r = await this.cachedWebSearch({
146
  q: searchQuery,
147
- count: Math.floor(count + 2)
148
  }, crawlerOptions.noCache);
149
 
150
  if (!r.web?.results.length) {
@@ -300,6 +300,26 @@ export class SearcherHost extends RPCHost {
300
  if (!searchResults) {
301
  return;
302
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  const urls = searchResults.map((x) => new URL(x.url));
304
  const snapshotMap = new WeakMap();
305
  for await (const scrapped of this.crawler.scrapMany(urls, options, crawlerOptions)) {
 
82
  res: Response,
83
  },
84
  auth: JinaEmbeddingsAuthDTO,
85
+ @Param('count', { default: 5, validate: (v) => v >= 0 && v <= 10 })
86
  count: number,
87
  crawlerOptions: CrawlerOptions,
88
  braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
 
144
  const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
145
  const r = await this.cachedWebSearch({
146
  q: searchQuery,
147
+ count: count ? Math.floor(count + 2) : 20
148
  }, crawlerOptions.noCache);
149
 
150
  if (!r.web?.results.length) {
 
300
  if (!searchResults) {
301
  return;
302
  }
303
+ if (count === 0) {
304
+ const resultArray = searchResults.map((upstreamSearchResult, i) => ({
305
+ url: upstreamSearchResult.url,
306
+ title: upstreamSearchResult.title,
307
+ description: upstreamSearchResult.description,
308
+ content: ['html', 'text', 'screenshot'].includes(mode) ? undefined : '',
309
+ toString() {
310
+ return `[${i + 1}] Title: ${this.title}
311
+ [${i + 1}] URL Source: ${this.url}
312
+ [${i + 1}] Description: ${this.description}
313
+ `;
314
+ }
315
+
316
+ })) as FormattedPage[];
317
+ resultArray.toString = function () {
318
+ return this.map((x, i) => x ? x.toString() : '').join('\n\n').trimEnd() + '\n';
319
+ };
320
+ yield resultArray;
321
+ return;
322
+ }
323
  const urls = searchResults.map((x) => new URL(x.url));
324
  const snapshotMap = new WeakMap();
325
  for await (const scrapped of this.crawler.scrapMany(urls, options, crawlerOptions)) {
backend/functions/src/dto/scrapping-options.ts CHANGED
@@ -300,9 +300,7 @@ export class CrawlerOptions extends AutoCastable {
300
  @Prop()
301
  userAgent?: string;
302
 
303
- @Prop({
304
- type: ENGINE_TYPE,
305
- })
306
  engine?: string;
307
 
308
  @Prop({
 
300
  @Prop()
301
  userAgent?: string;
302
 
303
+ @Prop()
 
 
304
  engine?: string;
305
 
306
  @Prop({