mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-20 21:29:08 +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,
|
res: Response,
|
||||||
},
|
},
|
||||||
auth: JinaEmbeddingsAuthDTO,
|
auth: JinaEmbeddingsAuthDTO,
|
||||||
@Param('count', { default: 5, validate: (v) => v >= 3 && v <= 10 })
|
@Param('count', { default: 5, validate: (v) => v >= 0 && v <= 10 })
|
||||||
count: number,
|
count: number,
|
||||||
crawlerOptions: CrawlerOptions,
|
crawlerOptions: CrawlerOptions,
|
||||||
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
||||||
@ -144,7 +144,7 @@ export class SearcherHost extends RPCHost {
|
|||||||
const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
|
const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
|
||||||
const r = await this.cachedWebSearch({
|
const r = await this.cachedWebSearch({
|
||||||
q: searchQuery,
|
q: searchQuery,
|
||||||
count: Math.floor(count + 2)
|
count: count ? Math.floor(count + 2) : 20
|
||||||
}, crawlerOptions.noCache);
|
}, crawlerOptions.noCache);
|
||||||
|
|
||||||
if (!r.web?.results.length) {
|
if (!r.web?.results.length) {
|
||||||
@ -300,6 +300,26 @@ export class SearcherHost extends RPCHost {
|
|||||||
if (!searchResults) {
|
if (!searchResults) {
|
||||||
return;
|
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 urls = searchResults.map((x) => new URL(x.url));
|
||||||
const snapshotMap = new WeakMap();
|
const snapshotMap = new WeakMap();
|
||||||
for await (const scrapped of this.crawler.scrapMany(urls, options, crawlerOptions)) {
|
for await (const scrapped of this.crawler.scrapMany(urls, options, crawlerOptions)) {
|
||||||
|
@ -300,9 +300,7 @@ export class CrawlerOptions extends AutoCastable {
|
|||||||
@Prop()
|
@Prop()
|
||||||
userAgent?: string;
|
userAgent?: string;
|
||||||
|
|
||||||
@Prop({
|
@Prop()
|
||||||
type: ENGINE_TYPE,
|
|
||||||
})
|
|
||||||
engine?: string;
|
engine?: string;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user