Added context messages to fix #339

This commit is contained in:
Kostia
2023-01-04 01:59:15 +02:00
parent 1cc0eecd10
commit c80f89f545
3 changed files with 28 additions and 1 deletions
@@ -0,0 +1,19 @@
import { Box } from "@chakra-ui/react";
import { Message } from "./Messages";
export const ContextMessages = ({ messages } : { messages: Message[]}) => {
console.log(messages)
return (
<Box className="flex flex-col gap-1">
{messages.map((message, i) => {
return (
<Box key={i}>
<span>{message.is_assistant ? "Assistant: " : "User: "}</span>
<span>{message.text}</span>
</Box>
);
})}
</Box>
);
};
@@ -1,7 +1,9 @@
import { useColorMode } from "@chakra-ui/react";
import Head from "next/head";
import { useState } from "react";
import { ContextMessages } from "src/components/ContextMessages";
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
import { Message } from "src/components/Messages";
import { Sortable } from "src/components/Sortable/Sortable";
import { SurveyCard } from "src/components/Survey/SurveyCard";
import { TaskControls } from "src/components/Survey/TaskControls";
@@ -64,7 +66,8 @@ const RankAssistantReplies = () => {
}
const replies = tasks[0].task.replies as string[];
const messages = tasks[0].task.conversation.messages as Message[];
return (
<>
<Head>
@@ -77,6 +80,7 @@ const RankAssistantReplies = () => {
<p className="text-lg py-1">
Given the following replies, sort them from best to worst, best being first, worst being last.
</p>
<ContextMessages messages={messages} />
<Sortable items={replies} onChange={setRanking} className="my-8" />
</SurveyCard>
@@ -9,6 +9,8 @@ import fetcher from "src/lib/fetcher";
import poster from "src/lib/poster";
import useSWRImmutable from "swr/immutable";
import useSWRMutation from "swr/mutation";
import {Message} from "src/components/Messages"
import { ContextMessages } from "src/components/ContextMessages";
const RankUserReplies = () => {
const [tasks, setTasks] = useState([]);
@@ -63,6 +65,7 @@ const RankUserReplies = () => {
);
}
const replies = tasks[0].task.replies as string[];
const messages = tasks[0].task.conversation.messages as Message[];
return (
<>
@@ -76,6 +79,7 @@ const RankUserReplies = () => {
<p className="text-lg py-1">
Given the following replies, sort them from best to worst, best being first, worst being last.
</p>
<ContextMessages messages={messages} />
<Sortable items={replies} onChange={setRanking} className="my-8" />
</SurveyCard>