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

polishing

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