+
+ >
+ );
+}
+
+export async function getServerSideProps(context) {
+ const csrfToken = await getCsrfToken();
+ const providers = await getProviders();
+ return {
+ props: {
+ csrfToken,
+ providers,
+ },
+ };
+}
diff --git a/website/src/pages/grading/grade-output.tsx b/website/src/pages/grading/grade-output.tsx
index b063672b..5fabe7ba 100644
--- a/website/src/pages/grading/grade-output.tsx
+++ b/website/src/pages/grading/grade-output.tsx
@@ -1,113 +1,150 @@
+import { HStack, Textarea } from "@chakra-ui/react";
import { QuestionMarkCircleIcon } from "@heroicons/react/20/solid";
+import { useSession, signIn, signOut } from "next-auth/react";
+import { useEffect, useRef, useState } from "react";
+import useSWRMutation from "swr/mutation";
+import useSWRImmutable from "swr/immutable";
+
+import RatingRadioGroup from "src/components/RatingRadioGroup";
+import fetcher from "src/lib/fetcher";
+import poster from "src/lib/poster";
+
+const GradeOutput = () => {
+ // Use an array of tasks that record the sequence of steps until a task is
+ // deemed complete.
+ const [tasks, setTasks] = useState([]);
+ const [rating, setRating] = useState(0);
+
+ // A quick reference to the input element. This should be factored into the
+ // component doing the actual task rendering.
+ const responseEl = useRef(null);
+
+ // Fetch the very fist task. We can ignore everything except isLoading
+ // because the onSuccess handler will update `tasks` when ready.
+ const { isLoading } = useSWRImmutable("/api/new_task/rate_summary", fetcher, {
+ onSuccess: (data) => {
+ console.log(data);
+ setTasks([data]);
+ },
+ });
+
+ // Every time we submit an answer to the latest task, let the backend handle
+ // all the interactions then add the resulting task to the queue. This ends
+ // when we hit the done task.
+ const { trigger, isMutating } = useSWRMutation("/api/update_task", poster, {
+ onSuccess: async (data) => {
+ const newTask = await data.json();
+ // This is the more efficient way to update a react state array.
+ setTasks((oldTasks) => [...oldTasks, newTask]);
+ },
+ });
+
+ // Trigger a mutation that updates the current task. We should probably
+ // signal somewhere that this interaction is being processed.
+ const submitResponse = (t) => {
+ trigger({
+ id: t.id,
+ content: {
+ rating: rating,
+ },
+ });
+ };
+
+ /**
+ * TODO: Make this a nicer loading screen.
+ */
+ if (tasks.length == 0) {
+ return ;
+ }
-export default function OutputDetail(): JSX.Element {
return (
- <>
-
);
-}
+};
+
+export default GradeOutput;
function AnnotationCheckboxLi(props: { option: annotationBool }): JSX.Element {
let AdditionalExplanation = null;
@@ -183,20 +220,3 @@ const ANNOTATION_FLAGS: annotationBool[] = [
labelText: "Expresses moral judgement",
},
];
-
-const SAMPLE_PROMPT = "Please make a list of aspects of a good pull request. Briefly describe each aspect.";
-
-const SAMPLE_OUTPUT = `Here are some aspects of a good pull request, which you may use to help your pull requests be good contributions and get accepted:
-
-1. Communicate:
-2. Pull request size:
- * Summary
- * Fix one problem
- * Limit the scope
- * Use commits
-3. Use coding conventions:
-4. Perform testing:
-5. Rebase onto the master branch before creating your PR
-6. Respond to reviews quickly
-7. Thank reviewers for their suggestions
-`;
diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx
index 2884cc2b..5c7b6acf 100644
--- a/website/src/pages/index.tsx
+++ b/website/src/pages/index.tsx
@@ -1,6 +1,7 @@
import { useSession } from "next-auth/react";
import Head from "next/head";
+import Link from "next/link";
import { CallToAction } from "../components/CallToAction";
import { Faq } from "../components/Faq";
@@ -35,14 +36,23 @@ export default function Home() {
);
}
return (
-
-
- {/* */}
-
+ <>
+
+ Open Assistant
+
+
+
+
Open Chat Gpt
You are logged in
-
-
+
+ ~Rate a prompt and output now~
+
+
+ >
);
}
diff --git a/website/src/pages/login.tsx b/website/src/pages/login.tsx
deleted file mode 100644
index 0f720af5..00000000
--- a/website/src/pages/login.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import Head from "next/head";
-import Link from "next/link";
-
-import { AuthLayout } from "../components/AuthLayout";
-
-export default function Login() {
- return (
- <>
-
- Log in
-
- >}>
-
-
- >
- );
-}
diff --git a/website/src/pages/new_task.js b/website/src/pages/new_task.js
deleted file mode 100644
index 123ee0a5..00000000
--- a/website/src/pages/new_task.js
+++ /dev/null
@@ -1,94 +0,0 @@
-import axios from "axios";
-import Head from "next/head";
-import Image from "next/image";
-import { useSession, signIn, signOut } from "next-auth/react";
-import { useEffect, useRef, useState } from "react";
-import useSWRImmutable from "swr/immutable";
-import useSWRMutation from "swr/mutation";
-
-const fetcher = (url) => axios.get(url).then((res) => res.data);
-
-/**
- * A helper function to post updates to tasks.
- * This ensures the content sent is serialized to JSON.
- */
-async function sendRequest(url, { arg }) {
- return fetch(url, {
- method: "POST",
- body: JSON.stringify(arg),
- });
-}
-
-export default function NewPage() {
- // Use an array of tasks that record the sequence of steps until a task is
- // deemed complete.
- const [tasks, setTasks] = useState([]);
-
- // A quick reference to the input element. This should be factored into the
- // component doing the actual task rendering.
- const responseEl = useRef(null);
-
- // Fetch the very fist task. We can ignore everything except isLoading
- // because the onSuccess handler will update `tasks` when ready.
- const { isLoading } = useSWRImmutable("/api/new_task", fetcher, {
- onSuccess: (data) => {
- setTasks([data]);
- },
- });
-
- // Every time we submit an answer to the latest task, let the backend handle
- // all the interactions then add the resulting task to the queue. This ends
- // when we hit the done task.
- const { trigger, isMutating } = useSWRMutation("/api/update_task", sendRequest, {
- onSuccess: async (data) => {
- const newTask = await data.json();
- // This is the more efficient way to update a react state array.
- setTasks((oldTasks) => [...oldTasks, newTask]);
- },
- });
-
- // Trigger a mutation that updates the current task. We should probably
- // signal somewhere that this interaction is being processed.
- const submitResponse = (t) => {
- trigger({
- id: t.id,
- content: {
- rating: responseEl.current.value,
- },
- });
- };
-
- // Show something informative while loading the first task.
- if (isLoading) {
- return
Loading
;
- }
-
- // Iterate through each of the tasks and show it's contents, get a response to it, or show the done state.
- //
- // Right now this just works for the rating task.
- //
- // Displaying and fetching results for each task type should be factored into
- // different components that handle the presentation and response structures.
- // The results should be packaged into a single object with all the fields
- // sent to the backend.
- return (
-