Skip to content

Commit

Permalink
chore(frontend): update lodash imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ardaerzin committed Dec 5, 2024
1 parent 0dbae65 commit d0a2a90
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion agenta-web/src/components/ChatInputs/ChatInputs.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/components/Filters/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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,
})
}
Expand All @@ -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 || "",
Expand Down Expand Up @@ -125,8 +126,8 @@ const AddToTestSetDrawer: React.FC<Props> = ({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 {
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -512,7 +512,7 @@ const EvaluationCompareMode: React.FC<Props> = () => {
<Space size={10}>
<FilterColumns
items={generateFilterItems(
_.uniqBy(
uniqBy(
colDefs.filter((item) => !item.headerName?.startsWith("Input")),
"headerName",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -85,7 +85,7 @@ const EvaluationScenarios: React.FC<Props> = () => {
}
}

const uniqueCorrectAnswers: CorrectAnswer[] = _.uniqBy(
const uniqueCorrectAnswers: CorrectAnswer[] = uniqBy(
scenarios[0]?.correct_answers || [],
"key",
)
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/hooks/useDeepCompareEffect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isEqual} from "lodash"
import isEqual from "lodash/isEqual"
import React, {useEffect, useRef} from "react"
import {useUpdateEffect} from "usehooks-ts"

Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/lib/helpers/axiosConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion agenta-web/src/lib/helpers/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions agenta-web/src/lib/helpers/llmProviders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import cloneDeep from "lodash/cloneDeep"
import {camelToSnake} from "./utils"

const llmAvailableProvidersToken = "llmAvailableProvidersToken"
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions agenta-web/src/services/evaluations/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -214,7 +214,7 @@ export const fetchAllComparisonResults = async (evaluationIds: string[]) => {
const inputNames = Array.from(inputsNameSet)
const inputValuesSet = new Set<string>()
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",
)
Expand Down

0 comments on commit d0a2a90

Please sign in to comment.