2023-03-28 20:36:21 +08:00
|
|
|
import React from "react";
|
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
|
|
import {
|
|
|
|
|
RecoilRoot,
|
|
|
|
|
atom,
|
|
|
|
|
selector,
|
|
|
|
|
useRecoilState,
|
|
|
|
|
useRecoilValue,
|
|
|
|
|
useSetRecoilState,
|
|
|
|
|
} from "recoil";
|
|
|
|
|
import buildTree from "~/utils/buildTree";
|
|
|
|
|
|
|
|
|
|
// current submission
|
|
|
|
|
// submit any new value to this state will cause new message to be send.
|
|
|
|
|
// set to null to give up any submission
|
|
|
|
|
// {
|
|
|
|
|
// conversation, // target submission, must have: model, chatGptLabel, promptPrefix
|
|
|
|
|
// messages, // old messages
|
|
|
|
|
// message, // request message
|
|
|
|
|
// initialResponse, // response message
|
|
|
|
|
// isRegenerate=false, // isRegenerate?
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
const submission = atom({
|
|
|
|
|
key: "submission",
|
|
|
|
|
default: null,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const isSubmitting = atom({
|
|
|
|
|
key: "isSubmitting",
|
|
|
|
|
default: false,
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-08 23:19:29 -04:00
|
|
|
const lastResponse = atom({
|
|
|
|
|
key: "lastResponse",
|
|
|
|
|
default: '',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const source = atom({
|
|
|
|
|
key: "source",
|
|
|
|
|
default: null,
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-28 20:36:21 +08:00
|
|
|
export default {
|
|
|
|
|
submission,
|
|
|
|
|
isSubmitting,
|
2023-04-08 23:19:29 -04:00
|
|
|
lastResponse,
|
|
|
|
|
source,
|
2023-03-28 20:36:21 +08:00
|
|
|
};
|