From 9f2760d8b89145f1a3dbfd18d9bb686589dfb52e Mon Sep 17 00:00:00 2001 From: AnotiaWang Date: Wed, 12 Feb 2025 15:46:11 +0800 Subject: [PATCH] chore: remove lodash --- lib/deep-research.ts | 5 ++--- package.json | 2 -- pnpm-lock.yaml | 23 ----------------------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/lib/deep-research.ts b/lib/deep-research.ts index bd688e7..5083084 100644 --- a/lib/deep-research.ts +++ b/lib/deep-research.ts @@ -1,5 +1,4 @@ import { streamText } from 'ai' -import { compact } from 'lodash-es' import pLimit from 'p-limit' import { z } from 'zod' import { parseStreamingJson, type DeepPartial } from '~/utils/json' @@ -136,7 +135,7 @@ function processSearchResult({ ), }) const jsonSchema = JSON.stringify(zodToJsonSchema(schema)) - const contents = compact(result.results.map((item) => item.content)).map( + const contents = result.results.map((item) => item.content).filter(Boolean).map( (content) => trimPrompt(content, 25_000), ) const prompt = [ @@ -267,7 +266,7 @@ export async function deepResearch({ ) // Collect URLs from this search - const newUrls = compact(result.results.map((item) => item.url)) + const newUrls = result.results.map((item) => item.url).filter(Boolean) onProgress({ type: 'search_complete', urls: newUrls, diff --git a/package.json b/package.json index 22d1934..0bfd18b 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,9 @@ "@pinia/nuxt": "^0.10.0", "@tailwindcss/typography": "^0.5.16", "@tavily/core": "^0.0.3", - "@types/lodash-es": "^4.17.12", "ai": "^4.1.28", "html2pdf.js": "^0.9.3", "js-tiktoken": "^1.0.18", - "lodash-es": "^4.17.21", "marked": "^15.0.7", "nuxt": "^3.15.4", "p-limit": "^6.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 782a1d6..9f22d1c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,6 @@ importers: '@tavily/core': specifier: ^0.0.3 version: 0.0.3 - '@types/lodash-es': - specifier: ^4.17.12 - version: 4.17.12 ai: specifier: ^4.1.28 version: 4.1.28(react@19.0.0)(zod@3.24.1) @@ -50,9 +47,6 @@ importers: js-tiktoken: specifier: ^1.0.18 version: 1.0.18 - lodash-es: - specifier: ^4.17.21 - version: 4.17.21 marked: specifier: ^15.0.7 version: 15.0.7 @@ -1184,12 +1178,6 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/lodash-es@4.17.12': - resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} - - '@types/lodash@4.17.15': - resolution: {integrity: sha512-w/P33JFeySuhN6JLkysYUK2gEmy9kHHFN7E8ro0tkfmlDOgxBDzWEZ/J8cWA+fHqFevpswDTFZnDx+R9lbL6xw==} - '@types/node@22.13.1': resolution: {integrity: sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==} @@ -2797,9 +2785,6 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} - lodash-es@4.17.21: - resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} - lodash.castarray@4.4.0: resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==} @@ -5806,12 +5791,6 @@ snapshots: '@types/json-schema@7.0.15': {} - '@types/lodash-es@4.17.12': - dependencies: - '@types/lodash': 4.17.15 - - '@types/lodash@4.17.15': {} - '@types/node@22.13.1': dependencies: undici-types: 6.20.0 @@ -7521,8 +7500,6 @@ snapshots: dependencies: p-locate: 5.0.0 - lodash-es@4.17.21: {} - lodash.castarray@4.4.0: {} lodash.defaults@4.2.0: {}