mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-16 11:05:59 +08:00
fix: retry for brave search
This commit is contained in:
parent
ec7c2ab52c
commit
09dbbd3b0f
@ -1,4 +1,4 @@
|
|||||||
import { AsyncService, AutoCastable, DownstreamServiceFailureError, Prop, RPC_CALL_ENVIRONMENT, marshalErrorLike } from 'civkit';
|
import { AsyncService, AutoCastable, DownstreamServiceFailureError, Prop, RPC_CALL_ENVIRONMENT, marshalErrorLike, retry } from 'civkit';
|
||||||
import { singleton } from 'tsyringe';
|
import { singleton } from 'tsyringe';
|
||||||
import { Logger } from '../shared/services/logger';
|
import { Logger } from '../shared/services/logger';
|
||||||
import { SecretExposer } from '../shared/services/secrets';
|
import { SecretExposer } from '../shared/services/secrets';
|
||||||
@ -31,6 +31,7 @@ export class BraveSearchService extends AsyncService {
|
|||||||
this.braveSearchHTTP = new BraveSearchHTTP(this.secretExposer.BRAVE_SEARCH_API_KEY);
|
this.braveSearchHTTP = new BraveSearchHTTP(this.secretExposer.BRAVE_SEARCH_API_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@retry(3, Math.ceil(500 + 500 * Math.random()))
|
||||||
async webSearch(query: WebSearchQueryParams) {
|
async webSearch(query: WebSearchQueryParams) {
|
||||||
const ip = this.threadLocal.get('ip');
|
const ip = this.threadLocal.get('ip');
|
||||||
const extraHeaders: WebSearchOptionalHeaderOptions = {};
|
const extraHeaders: WebSearchOptionalHeaderOptions = {};
|
||||||
@ -145,7 +146,7 @@ export class BraveSearchExplicitOperatorsDto extends AutoCastable {
|
|||||||
return [searchTerm, opPart].join(' ');
|
return [searchTerm, opPart].join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchTerm
|
return searchTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static override from(input: any) {
|
static override from(input: any) {
|
||||||
@ -163,7 +164,7 @@ export class BraveSearchExplicitOperatorsDto extends AutoCastable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filtered = customValue.split(', ').filter(Boolean)
|
const filtered = customValue.split(', ').filter(Boolean);
|
||||||
if (filtered.length) {
|
if (filtered.length) {
|
||||||
Reflect.set(instance, p, filtered);
|
Reflect.set(instance, p, filtered);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user