-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/(playground)/p/[agentId]/beta-proto/giselle-node/components/panel/feedback-block.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Langfuse } from "langfuse"; | ||
import { | ||
type FC, | ||
useCallback, | ||
useEffect, | ||
useMemo, | ||
useRef, | ||
useState, | ||
} from "react"; | ||
|
||
export const FeedbackBlock = (props: { traceId: string }) => { | ||
const [selectedOption, setSelectedOption] = useState<string>(""); | ||
const [feedbackComment, setFeedbackComment] = useState<string>(""); | ||
|
||
const handleFeedbackCommentChange = (event) => { | ||
setFeedbackComment(event.target.value); | ||
}; | ||
|
||
const submit = (e) => { | ||
e.preventDefault(); | ||
const lf = new Langfuse(); | ||
lf.score({ | ||
traceId: props.traceId, | ||
name: "user_feedback", | ||
value: selectedOption || "", | ||
comment: feedbackComment, | ||
}); | ||
setFeedbackComment(""); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<label> | ||
<input | ||
type="radio" | ||
value="5" | ||
checked={selectedOption === "5"} | ||
onChange={(event) => { | ||
setSelectedOption(event.target.value); | ||
}} | ||
/> | ||
😊 | ||
</label> | ||
<label> | ||
<input | ||
type="radio" | ||
value="4" | ||
checked={selectedOption === "4"} | ||
onChange={(event) => { | ||
setSelectedOption(event.target.value); | ||
}} | ||
/> | ||
😢 | ||
</label> | ||
<br /> | ||
<div className="grid gap-[8px] pb-[14px]"> | ||
<textarea | ||
value={feedbackComment} | ||
onChange={handleFeedbackCommentChange} | ||
className="w-full text-[14px] h-[200px] bg-[hsla(222,21%,40%,0.3)] rounded-[8px] text-white p-[14px] font-rosart outline-none resize-none" | ||
/> | ||
</div> | ||
<br /> | ||
<button type="button" onClick={submit}> | ||
Submit | ||
</button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters