Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/chat/llm-msg-feedback.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Button, Space } from "antd";6import { redux } from "@cocalc/frontend/app-framework";7import { HelpIcon, Icon, Text } from "@cocalc/frontend/components";8import { useProjectContext } from "../project/context";9import { ChatActions } from "./actions";10import { ChatMessageTyped, Feedback } from "./types";1112interface FeedackLLMProps {13actions?: ChatActions;14message: ChatMessageTyped;15}1617export function FeedbackLLM({ actions, message }: FeedackLLMProps) {18const { onCoCalcCom } = useProjectContext();1920if (actions == null) return null;21const account_id = redux.getStore("account").get_account_id();2223//const date = message.get("date")?.getTime() ?? 0;24const val = message.getIn(["feedback", account_id]);2526function feedback(what: Feedback) {27return `Give ${what} feedback about this answer written by the language model.`;28}2930const isNegative = val === "negative";31const isPositive = val === "positive";3233function renderUnhappy() {34if (!isNegative) return null;3536return (37<>38<Text type="secondary">39Try another model!{" "}40<HelpIcon title={"Different Language Models"}>41Try a different language models by selecting it in the "Regenerate"42dropdown or pick another one the next time you query it. No language43model is like another one and answers vary from one another.{" "}44{onCoCalcCom ? (45<>46In particular, there is a significant difference between free47and paid models. Paid models are more expensive, because they48process the information with a larger model, using more49computational resources. They usually have a deeper50understanding and are more accurate than free models.51</>52) : undefined}53</HelpIcon>54</Text>55</>56);57}5859return (60<Space size="small" wrap>61<Space>62<Button63style={{ color: "#555" }}64size="small"65type={isPositive ? "dashed" : "text"}66onClick={() =>67actions?.feedback(message, isPositive ? null : "positive")68}69title={feedback("positive")}70>71<Icon name="thumbs-up" />72</Button>73<Button74style={{ color: "#555" }}75size="small"76type={isNegative ? "dashed" : "text"}77onClick={() =>78actions?.feedback(message, isNegative ? null : "negative")79}80title={feedback("negative")}81>82<Icon name="thumbs-down" />83</Button>84</Space>85{renderUnhappy()}86</Space>87);88}899091