Skip to content

Commit

Permalink
Okay
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed Apr 30, 2024
1 parent bfd3812 commit aea3476
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/frontend/components/blocks/Feedbacks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default function Feedbacks({
<ActionIcon
variant="transparent"
onClick={() => {
console.log("HERE")
if (feedback.thumb === "down") {
feedback.thumb = null
} else {
Expand Down
33 changes: 25 additions & 8 deletions packages/frontend/components/blocks/RunChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"]
Expand Down Expand Up @@ -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 (
<>
<BubbleMessage
Expand All @@ -85,9 +88,23 @@ function Message({
<Feedbacks
feedback={run.feedback}
updateFeedback={async (feedback) => {
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)
}
}}
/>
)}
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/components/blocks/RunInputOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@ export default function RunInputOutput({
<Feedbacks
feedback={run.feedback}
updateFeedback={async (feedback) => {
await updateFeedback(feedback)
// await mutateLogs()
try {
await updateFeedback(feedback)
await mutateLogs()
} catch (error) {
console.error(error)
}
}}
/>
)}
Expand Down
10 changes: 8 additions & 2 deletions packages/frontend/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit aea3476

Please sign in to comment.