From aea3476f529f14bcb5f5ef5af6be9d68cadf1409 Mon Sep 17 00:00:00 2001 From: hughcrt Date: Mon, 29 Apr 2024 21:27:10 -0300 Subject: [PATCH] Okay --- .../components/blocks/Feedbacks/index.tsx | 1 - .../frontend/components/blocks/RunChat.tsx | 33 ++++++++++++++----- .../components/blocks/RunInputOutput.tsx | 8 +++-- packages/frontend/pages/logs/index.tsx | 10 ++++-- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/packages/frontend/components/blocks/Feedbacks/index.tsx b/packages/frontend/components/blocks/Feedbacks/index.tsx index 1d7d4708..e2bfb23e 100644 --- a/packages/frontend/components/blocks/Feedbacks/index.tsx +++ b/packages/frontend/components/blocks/Feedbacks/index.tsx @@ -48,7 +48,6 @@ export default function Feedbacks({ { - console.log("HERE") if (feedback.thumb === "down") { feedback.thumb = null } else { diff --git a/packages/frontend/components/blocks/RunChat.tsx b/packages/frontend/components/blocks/RunChat.tsx index f1c2dad5..bb853e0d 100644 --- a/packages/frontend/components/blocks/RunChat.tsx +++ b/packages/frontend/components/blocks/RunChat.tsx @@ -2,6 +2,8 @@ import { useCallback, useMemo, useState } from "react" import { BubbleMessage } from "@/components/SmartViewer/Message" +import { useProjectSWR, useRun } from "@/utils/dataHooks" +import { formatDateTime } from "@/utils/format" import { Button, Card, @@ -12,11 +14,10 @@ import { Text, Title, } from "@mantine/core" -import AppUserAvatar from "./AppUserAvatar" -import { formatDateTime } from "@/utils/format" -import Router from "next/router" import { IconNeedleThread } from "@tabler/icons-react" -import { useLogs, useProjectSWR, useRun } from "@/utils/dataHooks" +import Router, { useRouter } from "next/router" +import { mutate } from "swr" +import AppUserAvatar from "./AppUserAvatar" import Feedbacks from "./Feedbacks" const OUTPUT_ROLES = ["assistant", "ai", "tool"] @@ -66,8 +67,10 @@ function Message({ run, mutateLogs, }) { + const router = useRouter() + const runId = router?.query?.selected const { updateFeedback } = useRun(msg.id) - const { data: relatedRuns, mutate } = useProjectSWR(`/runs/${run.id}/related`) + const { data: relatedRuns } = useProjectSWR(runId && `/runs/${runId}/related`) return ( <> { - await updateFeedback(feedback) - await mutateLogs() - await mutate() + try { + const newRelatedRuns = [...relatedRuns] + await updateFeedback(feedback) + + newRelatedRuns.find(({ id }, i) => { + if (id === msg.id) { + newRelatedRuns[i].feedback = feedback + } + }) + + await mutate(`/runs/${runId}/related`, () => relatedRuns, { + revalidate: false, + }) + await mutateLogs() + } catch (error) { + console.error(error) + } }} /> )} diff --git a/packages/frontend/components/blocks/RunInputOutput.tsx b/packages/frontend/components/blocks/RunInputOutput.tsx index 2d7338c0..d7597831 100644 --- a/packages/frontend/components/blocks/RunInputOutput.tsx +++ b/packages/frontend/components/blocks/RunInputOutput.tsx @@ -344,8 +344,12 @@ export default function RunInputOutput({ { - await updateFeedback(feedback) - // await mutateLogs() + try { + await updateFeedback(feedback) + await mutateLogs() + } catch (error) { + console.error(error) + } }} /> )} diff --git a/packages/frontend/pages/logs/index.tsx b/packages/frontend/pages/logs/index.tsx index 1c3fe17a..bcccba02 100644 --- a/packages/frontend/pages/logs/index.tsx +++ b/packages/frontend/pages/logs/index.tsx @@ -122,12 +122,18 @@ const CHECKS_BY_TYPE = { "tags", "users", "status", - "feedback", + // "feedback", "duration", "metadata", "radar", ], - thread: ["tags", "users", "feedback", "metadata", "radar"], + thread: [ + "tags", + "users", + // "feedback", + "metadata", + "radar", + ], } const editCheck = (filters, id, params) => {