From 91d730a7bc9a5249d2d077b5921b77a22c4bb9b7 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Wed, 29 May 2024 19:07:08 +0530 Subject: [PATCH 1/3] feat: remote sources have clickable links --- application/retriever/classic_rag.py | 5 +++++ frontend/src/conversation/ConversationBubble.tsx | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/retriever/classic_rag.py b/application/retriever/classic_rag.py index 3eb0f202..2b77db34 100644 --- a/application/retriever/classic_rag.py +++ b/application/retriever/classic_rag.py @@ -69,6 +69,11 @@ class ClassicRAG(BaseRetriever): else i.page_content ), "text": i.page_content, + "source": ( + i.metadata.get("source") + if i.metadata.get("source") + else "local" + ), } for i in docs_temp ] diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 9877db66..aa9c4e3d 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -22,7 +22,7 @@ const ConversationBubble = forwardRef< className?: string; feedback?: FEEDBACK; handleFeedback?: (feedback: FEEDBACK) => void; - sources?: { title: string; text: string }[]; + sources?: { title: string; text: string; source: string }[]; } >(function ConversationBubble( { message, type, className, feedback, handleFeedback, sources }, @@ -177,7 +177,13 @@ const ConversationBubble = forwardRef< : 'bg-[#D7EBFD] hover:bg-[#BFE1FF]' }`} onClick={() => - setOpenSource(openSource === index ? null : index) + source.source !== 'local' + ? window.open( + source.source, + '_blank', + 'noopener, noreferrer', + ) + : setOpenSource(openSource === index ? null : index) } >

Date: Wed, 29 May 2024 22:54:46 +0530 Subject: [PATCH 2/3] (i18n): updated for conv history --- frontend/src/locale/en.json | 9 ++++++++- frontend/src/locale/es.json | 9 ++++++++- frontend/src/settings/General.tsx | 14 +++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index c4a93090..94df2e75 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -40,7 +40,14 @@ "prompt": "Active Prompt", "deleteAllLabel": "Delete all Conversation", "deleteAllBtn": "Delete all", - "addNew": "Add New" + "addNew": "Add New", + "convHistory":"Conversational history", + "none":"None", + "low":"Low", + "medium":"Medium", + "high":"High", + "unlimited":"Unlimited", + "default":"default" }, "documents": { "label": "Documents", diff --git a/frontend/src/locale/es.json b/frontend/src/locale/es.json index 04e1bdfa..9ab6f8c4 100644 --- a/frontend/src/locale/es.json +++ b/frontend/src/locale/es.json @@ -40,7 +40,14 @@ "prompt": "Prompt Activo", "deleteAllLabel": "Eliminar toda la Conversación", "deleteAllBtn": "Eliminar todo", - "addNew": "Agregar Nuevo" + "addNew": "Agregar Nuevo", + "convHistory":"Historia conversacional", + "none":"ninguno", + "low":"Bajo", + "medium":"Medio", + "high":"Alto", + "unlimited":"Ilimitado", + "default":"predeterminada" }, "documents": { "label": "Documentos", diff --git a/frontend/src/settings/General.tsx b/frontend/src/settings/General.tsx index a7c5d01a..377f8c37 100644 --- a/frontend/src/settings/General.tsx +++ b/frontend/src/settings/General.tsx @@ -35,12 +35,12 @@ const General: React.FC = () => { ]; const chunks = ['0', '2', '4', '6', '8', '10']; const token_limits = new Map([ - [0, 'None'], - [100, 'Low'], - [1000, 'Medium'], - [2000, 'Default'], - [4000, 'High'], - [1e9, 'Unlimited'], + [0, t('settings.general.none')], + [100, t('settings.general.low')], + [1000, t('settings.general.medium')], + [2000, t('settings.general.default')], + [4000, t('settings.general.high')], + [1e9, t('settings.general.unlimited')], ]); const [prompts, setPrompts] = React.useState< { name: string; id: string; type: string }[] @@ -126,7 +126,7 @@ const General: React.FC = () => {

- Conversational history + {t('settings.general.convHistory')}

({ From f1ed1e0f14db31f3212bb6084ae3c4d023fdd3a6 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Thu, 30 May 2024 15:33:16 +0530 Subject: [PATCH 3/3] fix: type error --- frontend/src/conversation/conversationModels.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/conversation/conversationModels.ts b/frontend/src/conversation/conversationModels.ts index 9fbd4437..347a2521 100644 --- a/frontend/src/conversation/conversationModels.ts +++ b/frontend/src/conversation/conversationModels.ts @@ -17,7 +17,7 @@ export interface Answer { answer: string; query: string; result: string; - sources: { title: string; text: string }[]; + sources: { title: string; text: string; source: string }[]; conversationId: string | null; title: string | null; } @@ -27,7 +27,7 @@ export interface Query { response?: string; feedback?: FEEDBACK; error?: string; - sources?: { title: string; text: string }[]; + sources?: { title: string; text: string; source: string }[]; conversationId?: string | null; title?: string | null; }