Skip to content
Snippets Groups Projects
Commit 0f5c632a authored by Embruch, Gerd's avatar Embruch, Gerd
Browse files

polishing

parent 1f26d15f
Branches
No related tags found
No related merge requests found
......@@ -121,9 +121,7 @@ export const getChat = async (req, res, next) => {
*/
export const getChats = async (req, res, next) => {
try {
// TODO sort chats by createdAt
const chats = await findRecords(Chat, { createdBy: global.currentUserId });
// const chats = await Chat.find({ createdBy: global.currentUserId }).sort({ 'createdAt': 1 });
return res.json({ chats });
} catch (error) {
next(error);
......
<!doctype html>
<html lang="en">
......@@ -52,7 +51,8 @@
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the
previous block.
</p>
<template id="filterTemplate">
<div class="quiet">
......@@ -348,10 +348,13 @@ router.post('/chat', verifyAccessToken, validate(chatSchema), checkRequestedMode
* @header {authorization} Bearer [required] access token
* @return {object} list of found conversations, ordered by updated
*/
// TODO sort chats by createdAt
router.get('/chats', verifyAccessToken, getChats);
&nbsp;
export default router;</pre></td></tr></table></pre>
export default router;</pre>
</td>
</tr>
</table>
</pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
......@@ -369,5 +372,5 @@ export default router;</pre></td></tr></table></pre>
<script src="../../sorter.js"></script>
<script src="../../block-navigation.js"></script>
</body>
</html>
</html>
\ No newline at end of file
......@@ -60,7 +60,7 @@ ChatSchema.pre('save', async function (next) {
ChatSchema.pre('find', function (next) {
// set default sort
if (typeof this.options.sort === 'undefined') {
this.options.sort = { createdAt: 1 };
this.options.sort = { createdAt: -1 };
}
next();
});
......
......@@ -189,16 +189,13 @@ export const chat = async (req, res, next) => {
// if history given
if (invokeInput.chat_history.length > 0) {
// input into contextualized question
console.log('contextualizing input');
return contextualizeQChain;
}
// simply return input if no history given
console.log('keeping input as is');
return invokeInput.input;
}
}).assign({
docs: async (invokeInput) => {
console.log('question', invokeInput.question);
// fetch question related docs from retriever
return await retriever.invoke(invokeInput.question);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment