mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-18 15:35:55 +08:00
fix: search params
This commit is contained in:
parent
234f61d066
commit
cc6d2f3e29
@ -82,7 +82,7 @@ export class SearcherHost extends RPCHost {
|
||||
res: Response,
|
||||
},
|
||||
auth: JinaEmbeddingsAuthDTO,
|
||||
@Param('count', { default: 5, validate: (v) => v >= 3 && v <= 10 })
|
||||
@Param('count', { default: 5, validate: (v) => v >= 0 && v <= 10 })
|
||||
count: number,
|
||||
crawlerOptions: CrawlerOptions,
|
||||
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
||||
@ -144,7 +144,7 @@ export class SearcherHost extends RPCHost {
|
||||
const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
|
||||
const r = await this.cachedWebSearch({
|
||||
q: searchQuery,
|
||||
count: Math.floor(count + 2)
|
||||
count: count ? Math.floor(count + 2) : 20
|
||||
}, crawlerOptions.noCache);
|
||||
|
||||
if (!r.web?.results.length) {
|
||||
@ -300,6 +300,26 @@ export class SearcherHost extends RPCHost {
|
||||
if (!searchResults) {
|
||||
return;
|
||||
}
|
||||
if (count === 0) {
|
||||
const resultArray = searchResults.map((upstreamSearchResult, i) => ({
|
||||
url: upstreamSearchResult.url,
|
||||
title: upstreamSearchResult.title,
|
||||
description: upstreamSearchResult.description,
|
||||
content: ['html', 'text', 'screenshot'].includes(mode) ? undefined : '',
|
||||
toString() {
|
||||
return `[${i + 1}] Title: ${this.title}
|
||||
[${i + 1}] URL Source: ${this.url}
|
||||
[${i + 1}] Description: ${this.description}
|
||||
`;
|
||||
}
|
||||
|
||||
})) as FormattedPage[];
|
||||
resultArray.toString = function () {
|
||||
return this.map((x, i) => x ? x.toString() : '').join('\n\n').trimEnd() + '\n';
|
||||
};
|
||||
yield resultArray;
|
||||
return;
|
||||
}
|
||||
const urls = searchResults.map((x) => new URL(x.url));
|
||||
const snapshotMap = new WeakMap();
|
||||
for await (const scrapped of this.crawler.scrapMany(urls, options, crawlerOptions)) {
|
||||
|
@ -300,9 +300,7 @@ export class CrawlerOptions extends AutoCastable {
|
||||
@Prop()
|
||||
userAgent?: string;
|
||||
|
||||
@Prop({
|
||||
type: ENGINE_TYPE,
|
||||
})
|
||||
@Prop()
|
||||
engine?: string;
|
||||
|
||||
@Prop({
|
||||
|
Loading…
x
Reference in New Issue
Block a user