mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 14:30:17 +08:00
feat: improve dedup with jina embeddings
This commit is contained in:
parent
814d539dac
commit
21b4b00e90
@ -14,7 +14,7 @@ import {TokenTracker} from "./utils/token-tracker";
|
||||
import {ActionTracker} from "./utils/action-tracker";
|
||||
import {StepAction, AnswerAction} from "./types";
|
||||
import {TrackerContext} from "./types";
|
||||
import {jinaSearch} from "./tools/jinaSearch";
|
||||
import {search} from "./tools/jina-search";
|
||||
|
||||
async function sleep(ms: number) {
|
||||
const seconds = Math.ceil(ms / 1000);
|
||||
@ -510,7 +510,7 @@ But then you realized you have asked them before. You decided to to think out of
|
||||
switch (SEARCH_PROVIDER) {
|
||||
case 'jina':
|
||||
// use jinaSearch
|
||||
results = {results: (await jinaSearch(query, context.tokenTracker)).response?.data || []};
|
||||
results = {results: (await search(query, context.tokenTracker)).response?.data || []};
|
||||
break;
|
||||
case 'duck':
|
||||
results = await duckSearch(query, {safeSearch: SafeSearchType.STRICT});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { jinaSearch } from '../jinaSearch';
|
||||
import { search } from '../jina-search';
|
||||
import { TokenTracker } from '../../utils/token-tracker';
|
||||
|
||||
describe('search', () => {
|
||||
it.skip('should perform search with Jina API (skipped due to insufficient balance)', async () => {
|
||||
const tokenTracker = new TokenTracker();
|
||||
const { response } = await jinaSearch('TypeScript programming', tokenTracker);
|
||||
const { response } = await search('TypeScript programming', tokenTracker);
|
||||
expect(response).toBeDefined();
|
||||
expect(response.data).toBeDefined();
|
||||
if (response.data === null) {
|
||||
@ -15,7 +15,7 @@ describe('search', () => {
|
||||
}, 15000);
|
||||
|
||||
it('should handle empty query', async () => {
|
||||
await expect(jinaSearch('')).rejects.toThrow();
|
||||
await expect(search('')).rejects.toThrow();
|
||||
}, 15000);
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -3,7 +3,7 @@ import { TokenTracker } from "../utils/token-tracker";
|
||||
import { SearchResponse } from '../types';
|
||||
import { JINA_API_KEY } from "../config";
|
||||
|
||||
export function jinaSearch(query: string, tracker?: TokenTracker): Promise<{ response: SearchResponse, tokens: number }> {
|
||||
export function search(query: string, tracker?: TokenTracker): Promise<{ response: SearchResponse, tokens: number }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!query.trim()) {
|
||||
reject(new Error('Query cannot be empty'));
|
||||
Loading…
x
Reference in New Issue
Block a user