nomagick commited on
Commit
e9f5be5
·
unverified ·
1 Parent(s): 845e441

chore: serp provider tweak

Browse files
Files changed (2) hide show
  1. src/api/serp.ts +5 -3
  2. thinapps-shared +1 -1
src/api/serp.ts CHANGED
@@ -26,6 +26,7 @@ import { SerperBingSearchService, SerperGoogleSearchService } from '../services/
26
  import type { JinaEmbeddingsTokenAccount } from '../shared/db/jina-embeddings-token-account';
27
  import { LRUCache } from 'lru-cache';
28
  import { API_CALL_STATUS } from '../shared/db/api-roll';
 
29
 
30
  const WORLD_COUNTRY_CODES = Object.keys(WORLD_COUNTRIES).map((x) => x.toLowerCase());
31
 
@@ -92,6 +93,7 @@ export class SerpHost extends RPCHost {
92
  protected googleSerp: GoogleSERP,
93
  protected serperGoogle: SerperGoogleSearchService,
94
  protected serperBing: SerperBingSearchService,
 
95
  ) {
96
  super(...arguments);
97
 
@@ -449,7 +451,7 @@ export class SerpHost extends RPCHost {
449
  return result;
450
  }
451
 
452
- *iterProviders(preference?: string) {
453
  if (preference === 'bing') {
454
  yield this.serperBing;
455
  yield this.serperGoogle;
@@ -466,9 +468,9 @@ export class SerpHost extends RPCHost {
466
  return;
467
  }
468
 
 
469
  yield this.serperGoogle;
470
  yield this.googleSerp;
471
- yield this.googleSerp;
472
  }
473
 
474
  async cachedSearch(variant: 'web' | 'news' | 'images', query: Record<string, any>, opts: CrawlerOptions) {
@@ -501,7 +503,7 @@ export class SerpHost extends RPCHost {
501
  let r: any[] | undefined;
502
  let lastError;
503
  outerLoop:
504
- for (const client of this.iterProviders(provider)) {
505
  const t0 = Date.now();
506
  try {
507
  switch (variant) {
 
26
  import type { JinaEmbeddingsTokenAccount } from '../shared/db/jina-embeddings-token-account';
27
  import { LRUCache } from 'lru-cache';
28
  import { API_CALL_STATUS } from '../shared/db/api-roll';
29
+ import { InternalJinaSerpService } from '../services/serp/internal';
30
 
31
  const WORLD_COUNTRY_CODES = Object.keys(WORLD_COUNTRIES).map((x) => x.toLowerCase());
32
 
 
93
  protected googleSerp: GoogleSERP,
94
  protected serperGoogle: SerperGoogleSearchService,
95
  protected serperBing: SerperBingSearchService,
96
+ protected jinaSerp: InternalJinaSerpService,
97
  ) {
98
  super(...arguments);
99
 
 
451
  return result;
452
  }
453
 
454
+ *iterProviders(preference?: string, variant?: string) {
455
  if (preference === 'bing') {
456
  yield this.serperBing;
457
  yield this.serperGoogle;
 
468
  return;
469
  }
470
 
471
+ yield variant === 'web' ? this.jinaSerp : this.serperGoogle;
472
  yield this.serperGoogle;
473
  yield this.googleSerp;
 
474
  }
475
 
476
  async cachedSearch(variant: 'web' | 'news' | 'images', query: Record<string, any>, opts: CrawlerOptions) {
 
503
  let r: any[] | undefined;
504
  let lastError;
505
  outerLoop:
506
+ for (const client of this.iterProviders(provider, variant)) {
507
  const t0 = Date.now();
508
  try {
509
  switch (variant) {
thinapps-shared CHANGED
@@ -1 +1 @@
1
- Subproject commit a23636b2161908eefd897b6976c10a5924e2cd57
 
1
+ Subproject commit 69808307131d4fbd8ef0026f5d2dcb90ebdfad8c