feat(api): add support for saving messages to database

fix(api): change arrowParens prettier option to always
fix(api): update addToCache to include endpointOption and latestMessage
fix(api): update askOpenAI to include endpointOption in abortControllers
fix(client): remove abortKey state and add currentParent state to MessageHandler
This commit is contained in:
Daniel Avila 2023-04-09 11:17:08 -04:00
parent 6246ffff1e
commit a81bd27b39
5 changed files with 78 additions and 32 deletions

View file

@ -15,7 +15,8 @@ export default function MessageHandler() {
const [lastResponse, setLastResponse] = useRecoilState(store.lastResponse);
const setSubmission = useSetRecoilState(store.submission);
const [source, setSource] = useState(null);
const [abortKey, setAbortKey] = useState(null);
// const [abortKey, setAbortKey] = useState(null);
const [currentParent, setCurrentParent] = useState(null);
const { refreshConversations } = store.useConversations();
@ -174,8 +175,9 @@ export default function MessageHandler() {
'Content-Type': 'application/json'
},
body: JSON.stringify({
abortKey,
message: latestMessage,
abortKey: currentParent.conversationId,
latestMessage,
parentMessageId: currentParent.messageId,
})
})
.then(response => {
@ -219,7 +221,8 @@ export default function MessageHandler() {
};
createdHandler(data, { ...submission, message });
console.log('created', message);
setAbortKey(message?.conversationId);
// setAbortKey(message?.conversationId);
setCurrentParent(message);
} else {
let text = data.text || data.response;
if (data.initial) console.log(data);