diff --git a/agenta-web/src/components/ChatInputs/ChatInputs.tsx b/agenta-web/src/components/ChatInputs/ChatInputs.tsx index c64df839c4..66cacb365a 100644 --- a/agenta-web/src/components/ChatInputs/ChatInputs.tsx +++ b/agenta-web/src/components/ChatInputs/ChatInputs.tsx @@ -1,7 +1,7 @@ import {ChatMessage, ChatRole, JSSTheme} from "@/lib/Types" import {MinusOutlined, PlusOutlined} from "@ant-design/icons" import {Button, Input, Select, Space, Tooltip} from "antd" -import {cloneDeep} from "lodash" +import cloneDeep from "lodash/cloneDeep" import React, {useEffect, useRef, useState} from "react" import {createUseStyles} from "react-jss" import {useUpdateEffect} from "usehooks-ts" diff --git a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx index 9f215d1559..9149471ef7 100644 --- a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx @@ -46,7 +46,7 @@ import {testsetRowToChatMessages} from "@/lib/helpers/testset" import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel" import VariantAlphabet from "../Evaluations/EvaluationCardView/VariantAlphabet" import {ParamsFormWithRun} from "./SingleModelEvaluationTable" -import {debounce} from "lodash" +import debounce from "lodash/debounce" import {variantNameWithRev} from "@/lib/helpers/variantHelper" import {isBaseResponse, isFuncResponse} from "@/lib/helpers/playgroundResp" diff --git a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx index 3de68306b1..8c0e624fc6 100644 --- a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx @@ -40,7 +40,7 @@ import { getStringOrJson, } from "@/lib/helpers/utils" import {testsetRowToChatMessages} from "@/lib/helpers/testset" -import {debounce} from "lodash" +import debounce from "lodash/debounce" import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel" import ParamsForm from "../Playground/ParamsForm/ParamsForm" import SaveTestsetModal from "../SaveTestsetModal/SaveTestsetModal" diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx index b46b868e7e..f3fbd01e2d 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx @@ -16,7 +16,7 @@ import {ABTestingEvaluationTableRow} from "@/components/EvaluationTable/ABTestin import AlertPopup from "@/components/AlertPopup/AlertPopup" import {useLocalStorage} from "usehooks-ts" import {testsetRowToChatMessages} from "@/lib/helpers/testset" -import {debounce} from "lodash" +import debounce from "lodash/debounce" import {EvaluationType} from "@/lib/enums" import ParamsForm from "@/components/Playground/ParamsForm/ParamsForm" import {useVariants} from "@/lib/hooks/useVariant" diff --git a/agenta-web/src/components/Filters/Filters.tsx b/agenta-web/src/components/Filters/Filters.tsx index 73f705b857..fc46fe6633 100644 --- a/agenta-web/src/components/Filters/Filters.tsx +++ b/agenta-web/src/components/Filters/Filters.tsx @@ -4,7 +4,7 @@ import {ArrowCounterClockwise, CaretDown, Funnel, Plus, Trash, X} from "@phospho import {Button, Divider, Input, Popover, Select, Space, Typography} from "antd" import {createUseStyles} from "react-jss" import {useUpdateEffect} from "usehooks-ts" -import {isEqual} from "lodash" +import isEqual from "lodash/isEqual" const useStyles = createUseStyles((theme: JSSTheme) => ({ popover: { diff --git a/agenta-web/src/components/Playground/AddToTestSetDrawer/AddToTestSetDrawer.tsx b/agenta-web/src/components/Playground/AddToTestSetDrawer/AddToTestSetDrawer.tsx index 1768e534a7..75a2b7c4cb 100644 --- a/agenta-web/src/components/Playground/AddToTestSetDrawer/AddToTestSetDrawer.tsx +++ b/agenta-web/src/components/Playground/AddToTestSetDrawer/AddToTestSetDrawer.tsx @@ -26,7 +26,8 @@ import React, {useCallback, useEffect, useLayoutEffect, useRef, useState} from " import {createUseStyles} from "react-jss" import {useLocalStorage, useUpdateEffect} from "usehooks-ts" import ChatInputs from "@/components/ChatInputs/ChatInputs" -import _ from "lodash" +import cloneDeep from "lodash/cloneDeep" +import clone from "lodash/clone" const useStyles = createUseStyles({ footer: { @@ -56,16 +57,16 @@ function flatToTurn({ chat?: ChatMessage[] correct_answer?: ChatMessage | string }) { - const flatChat = _.cloneDeep(chat || []) + const flatChat = cloneDeep(chat || []) if (correct_answer && typeof correct_answer !== "string") - flatChat.push(_.cloneDeep(correct_answer)) + flatChat.push(cloneDeep(correct_answer)) const turns: {chat: ChatMessage[]; correct_answer: ChatMessage}[] = [] let currentTurn: ChatMessage[] = [] flatChat.forEach((item) => { if (item.role !== ChatRole.User) { turns.push({ - chat: _.clone(currentTurn || []), + chat: clone(currentTurn || []), correct_answer: item, }) } @@ -75,7 +76,7 @@ function flatToTurn({ } function turnToFlat(turns: {chat: ChatMessage[]; correct_answer: ChatMessage}[]) { - const flat = _.cloneDeep(turns.at(-1)) + const flat = cloneDeep(turns.at(-1)) return { chat: flat?.chat || [], correct_answer: flat?.correct_answer || "", @@ -125,8 +126,8 @@ const AddToTestSetDrawer: React.FC = ({params, isChatVariant, ...props}) //reset to defaults form.resetFields() - chatParams.chat = _.cloneDeep(params.chat || []) - chatParams.correct_answer = _.cloneDeep(params.correct_answer || "") + chatParams.chat = cloneDeep(params.chat || []) + chatParams.correct_answer = cloneDeep(params.correct_answer || "") setTurnModeChat(null) setShouldRender(true) } else { diff --git a/agenta-web/src/components/Playground/Views/TestView.tsx b/agenta-web/src/components/Playground/Views/TestView.tsx index 2f0cc86450..e724bc6fc7 100644 --- a/agenta-web/src/components/Playground/Views/TestView.tsx +++ b/agenta-web/src/components/Playground/Views/TestView.tsx @@ -27,7 +27,7 @@ import {v4 as uuidv4} from "uuid" import {testsetRowToChatMessages} from "@/lib/helpers/testset" import ParamsForm from "../ParamsForm/ParamsForm" import {TestContext} from "../TestContextProvider" -import {isEqual} from "lodash" +import isEqual from "lodash/isEqual" import {useAppTheme} from "@/components/Layout/ThemeContextProvider" import dayjs from "dayjs" import relativeTime from "dayjs/plugin/relativeTime" diff --git a/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx b/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx index 707b27f45f..add70ab20c 100644 --- a/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx +++ b/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx @@ -39,7 +39,7 @@ import {runningStatuses, statusMapper} from "../../evaluations/cellRenderers/cel import {useUpdateEffect} from "usehooks-ts" import {shortPoll} from "@/lib/helpers/utils" import {getFilterParams} from "./Filters/SearchFilter" -import {uniqBy} from "lodash" +import uniqBy from "lodash/uniqBy" import EvaluationErrorPopover from "../EvaluationErrorProps/EvaluationErrorPopover" import dayjs from "dayjs" import {convertToCsv, downloadCsv} from "@/lib/helpers/fileManipulations" diff --git a/agenta-web/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator/Messages.tsx b/agenta-web/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator/Messages.tsx index 25c84ee152..34607e6ea8 100644 --- a/agenta-web/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator/Messages.tsx +++ b/agenta-web/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator/Messages.tsx @@ -4,7 +4,7 @@ import {MinusCircleOutlined, PlusOutlined} from "@ant-design/icons" import {Form} from "antd" import Editor from "@monaco-editor/react" import {createUseStyles} from "react-jss" -import {isEqual} from "lodash" +import isEqual from "lodash/isEqual" const {TextArea} = Input diff --git a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx index 6b67367368..c8d7de665f 100644 --- a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx @@ -27,7 +27,7 @@ import {evaluatorsAtom} from "@/lib/atoms/evaluation" import CompareOutputDiff from "@/components/CompareOutputDiff/CompareOutputDiff" import {formatCurrency, formatLatency} from "@/lib/helpers/formatters" import FilterColumns, {generateFilterItems} from "../FilterColumns/FilterColumns" -import _ from "lodash" +import uniqBy from "lodash/uniqBy" import {variantNameWithRev} from "@/lib/helpers/variantHelper" import {escapeNewlines} from "@/lib/helpers/fileManipulations" import EvaluationErrorModal from "../EvaluationErrorProps/EvaluationErrorModal" @@ -512,7 +512,7 @@ const EvaluationCompareMode: React.FC = () => { !item.headerName?.startsWith("Input")), "headerName", ), diff --git a/agenta-web/src/components/pages/evaluations/evaluationScenarios/EvaluationScenarios.tsx b/agenta-web/src/components/pages/evaluations/evaluationScenarios/EvaluationScenarios.tsx index 9af52c0e4a..0fe867e6d2 100644 --- a/agenta-web/src/components/pages/evaluations/evaluationScenarios/EvaluationScenarios.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluationScenarios/EvaluationScenarios.tsx @@ -31,7 +31,7 @@ import CompareOutputDiff from "@/components/CompareOutputDiff/CompareOutputDiff" import {formatCurrency, formatLatency} from "@/lib/helpers/formatters" import EvaluationErrorModal from "../EvaluationErrorProps/EvaluationErrorModal" import EvaluationErrorText from "../EvaluationErrorProps/EvaluationErrorText" -import _ from "lodash" +import uniqBy from "lodash/uniqBy" import FilterColumns, {generateFilterItems} from "../FilterColumns/FilterColumns" import {variantNameWithRev} from "@/lib/helpers/variantHelper" import {escapeNewlines} from "@/lib/helpers/fileManipulations" @@ -85,10 +85,7 @@ const EvaluationScenarios: React.FC = () => { } } - const uniqueCorrectAnswers: CorrectAnswer[] = _.uniqBy( - scenarios[0]?.correct_answers || [], - "key", - ) + const uniqueCorrectAnswers: CorrectAnswer[] = uniqBy(scenarios[0]?.correct_answers || [], "key") const [modalErrorMsg, setModalErrorMsg] = useState({message: "", stackTrace: ""}) const [isErrorModalOpen, setIsErrorModalOpen] = useState(false) diff --git a/agenta-web/src/hooks/useDeepCompareEffect.ts b/agenta-web/src/hooks/useDeepCompareEffect.ts index daf2d9ca3e..e86fb2056c 100644 --- a/agenta-web/src/hooks/useDeepCompareEffect.ts +++ b/agenta-web/src/hooks/useDeepCompareEffect.ts @@ -1,4 +1,4 @@ -import {isEqual} from "lodash" +import isEqual from "lodash/isEqual" import React, {useEffect, useRef} from "react" import {useUpdateEffect} from "usehooks-ts" diff --git a/agenta-web/src/lib/helpers/axiosConfig.ts b/agenta-web/src/lib/helpers/axiosConfig.ts index 9637a9a0b4..0961ebe87c 100644 --- a/agenta-web/src/lib/helpers/axiosConfig.ts +++ b/agenta-web/src/lib/helpers/axiosConfig.ts @@ -3,7 +3,7 @@ import {getErrorMessage, globalErrorHandler} from "./errorHandler" import {signOut} from "supertokens-auth-react/recipe/session" import router from "next/router" import {getAgentaApiUrl} from "./utils" -import {isObject} from "lodash" +import isObject from "lodash/isObject" import AlertPopup from "@/components/AlertPopup/AlertPopup" export const PERMISSION_ERR_MSG = diff --git a/agenta-web/src/lib/helpers/evaluate.ts b/agenta-web/src/lib/helpers/evaluate.ts index 4fb80b8fb9..2ad8ce4ee8 100644 --- a/agenta-web/src/lib/helpers/evaluate.ts +++ b/agenta-web/src/lib/helpers/evaluate.ts @@ -11,7 +11,8 @@ import {convertToCsv, downloadCsv} from "./fileManipulations" import {fetchEvaluatonIdsByResource} from "@/services/evaluations/api" import {getAppValues} from "@/contexts/app.context" import AlertPopup from "@/components/AlertPopup/AlertPopup" -import {capitalize, round} from "lodash" +import capitalize from "lodash/capitalize" +import round from "lodash/round" import dayjs from "dayjs" import {runningStatuses} from "@/components/pages/evaluations/cellRenderers/cellRenderers" import {formatCurrency, formatLatency} from "./formatters" diff --git a/agenta-web/src/lib/helpers/llmProviders.ts b/agenta-web/src/lib/helpers/llmProviders.ts index 90687675e8..5d2b3105fa 100644 --- a/agenta-web/src/lib/helpers/llmProviders.ts +++ b/agenta-web/src/lib/helpers/llmProviders.ts @@ -1,4 +1,4 @@ -import _ from "lodash" +import cloneDeep from "lodash/cloneDeep" import {camelToSnake} from "./utils" const llmAvailableProvidersToken = "llmAvailableProvidersToken" @@ -59,7 +59,7 @@ export const getLlmProviderKey = (providerName: string) => getAllProviderLlmKeys().find((item: LlmProvider) => item.title === providerName)?.key export const getAllProviderLlmKeys = () => { - const providers = _.cloneDeep(llmAvailableProviders) + const providers = cloneDeep(llmAvailableProviders) try { if (typeof window !== "undefined") { const providersInStorage: LlmProvider[] = JSON.parse( diff --git a/agenta-web/src/services/evaluations/api/index.ts b/agenta-web/src/services/evaluations/api/index.ts index 6ab6dd3d5f..e747856832 100644 --- a/agenta-web/src/services/evaluations/api/index.ts +++ b/agenta-web/src/services/evaluations/api/index.ts @@ -21,7 +21,7 @@ import codeImg from "@/media/browser.png" import bracketCurlyImg from "@/media/bracket-curly.png" import {fetchTestset} from "@/services/testsets/api" import {calcEvalDuration} from "@/lib/helpers/evaluate" -import _ from "lodash" +import uniqBy from "lodash/uniqBy" import {getCurrentProject} from "@/contexts/project.context" //Prefix convention: @@ -214,7 +214,7 @@ export const fetchAllComparisonResults = async (evaluationIds: string[]) => { const inputNames = Array.from(inputsNameSet) const inputValuesSet = new Set() const variants = scenarioGroups.map((group) => group[0].evaluation.variants[0]) - const correctAnswers = _.uniqBy( + const correctAnswers = uniqBy( scenarioGroups.map((group) => group[0].correct_answers).flat(), "key", )