mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-18 19:15:56 +08:00
chore: serp provider tweak
This commit is contained in:
parent
845e441b0a
commit
e9f5be541b
@ -26,6 +26,7 @@ import { SerperBingSearchService, SerperGoogleSearchService } from '../services/
|
||||
import type { JinaEmbeddingsTokenAccount } from '../shared/db/jina-embeddings-token-account';
|
||||
import { LRUCache } from 'lru-cache';
|
||||
import { API_CALL_STATUS } from '../shared/db/api-roll';
|
||||
import { InternalJinaSerpService } from '../services/serp/internal';
|
||||
|
||||
const WORLD_COUNTRY_CODES = Object.keys(WORLD_COUNTRIES).map((x) => x.toLowerCase());
|
||||
|
||||
@ -92,6 +93,7 @@ export class SerpHost extends RPCHost {
|
||||
protected googleSerp: GoogleSERP,
|
||||
protected serperGoogle: SerperGoogleSearchService,
|
||||
protected serperBing: SerperBingSearchService,
|
||||
protected jinaSerp: InternalJinaSerpService,
|
||||
) {
|
||||
super(...arguments);
|
||||
|
||||
@ -449,7 +451,7 @@ export class SerpHost extends RPCHost {
|
||||
return result;
|
||||
}
|
||||
|
||||
*iterProviders(preference?: string) {
|
||||
*iterProviders(preference?: string, variant?: string) {
|
||||
if (preference === 'bing') {
|
||||
yield this.serperBing;
|
||||
yield this.serperGoogle;
|
||||
@ -466,9 +468,9 @@ export class SerpHost extends RPCHost {
|
||||
return;
|
||||
}
|
||||
|
||||
yield variant === 'web' ? this.jinaSerp : this.serperGoogle;
|
||||
yield this.serperGoogle;
|
||||
yield this.googleSerp;
|
||||
yield this.googleSerp;
|
||||
}
|
||||
|
||||
async cachedSearch(variant: 'web' | 'news' | 'images', query: Record<string, any>, opts: CrawlerOptions) {
|
||||
@ -501,7 +503,7 @@ export class SerpHost extends RPCHost {
|
||||
let r: any[] | undefined;
|
||||
let lastError;
|
||||
outerLoop:
|
||||
for (const client of this.iterProviders(provider)) {
|
||||
for (const client of this.iterProviders(provider, variant)) {
|
||||
const t0 = Date.now();
|
||||
try {
|
||||
switch (variant) {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a23636b2161908eefd897b6976c10a5924e2cd57
|
||||
Subproject commit 69808307131d4fbd8ef0026f5d2dcb90ebdfad8c
|
Loading…
x
Reference in New Issue
Block a user