From 0122829edec7a09c93f480c8c1d30589ade1e4b1 Mon Sep 17 00:00:00 2001
From: "Embruch, Gerd" <gerd.embruch@uni-hamburg.de>
Date: Sun, 21 Jul 2024 19:51:50 +0200
Subject: [PATCH] added source to message block

---
 ecosystem.config.cjs                | 2 +-
 src/components/chat/Message.jsx     | 3 ++-
 src/components/chat/Messages.jsx    | 1 +
 src/components/chat/PromptInput.jsx | 4 ++--
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs
index e97be0b..d89d655 100644
--- a/ecosystem.config.cjs
+++ b/ecosystem.config.cjs
@@ -2,7 +2,7 @@ module.exports = {
   apps: [{
     name: "RAGChat-Frontend",
     script: "npm",
-    args: "start",
+    args: "run dev",
     watch: false,
     error_file: 'logs/error.log',
     out_file: 'logs/output.log'
diff --git a/src/components/chat/Message.jsx b/src/components/chat/Message.jsx
index 5b83f88..4b1052a 100644
--- a/src/components/chat/Message.jsx
+++ b/src/components/chat/Message.jsx
@@ -1,6 +1,6 @@
 import React from 'react';
 
-function Message({ sender, message }) {
+function Message({ sender, message, source }) {
   // #################################
   // HOOKS
   // #################################
@@ -36,6 +36,7 @@ function Message({ sender, message }) {
       <div className={`p-3 mx-3 my-1 rounded-2xl ${tileBorder} ${tileColor} ${tileMargin}`}>
         <div className={`text-xs flex justify-between ${senderClasses}`} >
           <div>{sender}</div>
+          <div>{source}</div>
         </div>
         <div className={`${messageClasses} whitespace-pre-line`}>
           {message}
diff --git a/src/components/chat/Messages.jsx b/src/components/chat/Messages.jsx
index c29101d..665be9b 100644
--- a/src/components/chat/Messages.jsx
+++ b/src/components/chat/Messages.jsx
@@ -48,6 +48,7 @@ const Messages = () => {
           key={index}
           sender={prompt.type}
           message={prompt.data.content}
+          source={prompt.data.source}
         />
       ))
       }
diff --git a/src/components/chat/PromptInput.jsx b/src/components/chat/PromptInput.jsx
index accf0c0..9763f16 100644
--- a/src/components/chat/PromptInput.jsx
+++ b/src/components/chat/PromptInput.jsx
@@ -47,6 +47,7 @@ function PromptInput() {
       // send input to api
       const result = await api.post('/ai/chat', inputs);
       // update chat history
+      // BUG if currentChatId is null visible update fails
       updateChatHistory(currentChatId, result.data.chat.chatHistory);
       // clear input field
       methods.resetField('input');
@@ -58,8 +59,7 @@ function PromptInput() {
     }
   }
 
-  // TODO fetch available model names from backend
-  // TODO make model a dropdown
+  // TODO width of input field on large screens should increase
   // #################################
   // OUTPUT
   // #################################
-- 
GitLab